Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/plenty-geese-enter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/start": minor
---

seroval json mode
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
},
"typescript.tsdk": "node_modules/typescript/lib",
"editor.formatOnSave": true,
"editor.defaultFormatter": "oxc.oxc-vscode"
"editor.defaultFormatter": "oxc.oxc-vscode",
"[typescript]": {
"editor.defaultFormatter": "oxc.oxc-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "oxc.oxc-vscode"
}
}
14 changes: 14 additions & 0 deletions apps/tests/src/e2e/server-function.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,18 @@ test.describe("server-function", () => {
await page.goto("http://localhost:3000/generator-server-function");
await expect(page.locator("#server-fn-test")).toContainText("¡Hola, Mundo!");
});

test("should build with a server function ping", async ({ page }) => {
await page.goto("http://localhost:3000/server-function-ping");
await expect(page.locator("#server-fn-test")).toContainText('{"result":true}');
});

test("should build with a server function w/ form data", async ({ page }) => {
await page.goto("http://localhost:3000/server-function-form-data");
await expect(page.locator("#server-fn-test")).toContainText('{"result":true}');
Comment on lines +71 to +78
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New assertions use single-quoted string literals, but the repo formatter config uses double quotes (singleQuote: false). Please update these to double quotes to avoid formatting churn.

Copilot uses AI. Check for mistakes.
});
test("should build with a server function w/ blob data", async ({ page }) => {
await page.goto("http://localhost:3000/server-function-blob");
await expect(page.locator("#server-fn-test")).toContainText('{"result":true}');
});
});
29 changes: 29 additions & 0 deletions apps/tests/src/routes/server-function-blob.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { createEffect, createSignal } from "solid-js";

async function ping(value: Blob) {
"use server";
return value;
}

const blobURI =
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAxNjYgMTU1LjMnPjxwYXRoIGQ9J00xNjMgMzVTMTEwLTQgNjkgNWwtMyAxYy02IDItMTEgNS0xNCA5bC0yIDMtMTUgMjYgMjYgNWMxMSA3IDI1IDEwIDM4IDdsNDYgOSAxOC0zMHonIGZpbGw9JyM3NmIzZTEnLz48bGluZWFyR3JhZGllbnQgaWQ9J2EnIGdyYWRpZW50VW5pdHM9J3VzZXJTcGFjZU9uVXNlJyB4MT0nMjcuNScgeTE9JzMnIHgyPScxNTInIHkyPSc2My41Jz48c3RvcCBvZmZzZXQ9Jy4xJyBzdG9wLWNvbG9yPScjNzZiM2UxJy8+PHN0b3Agb2Zmc2V0PScuMycgc3RvcC1jb2xvcj0nI2RjZjJmZCcvPjxzdG9wIG9mZnNldD0nMScgc3RvcC1jb2xvcj0nIzc2YjNlMScvPjwvbGluZWFyR3JhZGllbnQ+PHBhdGggZD0nTTE2MyAzNVMxMTAtNCA2OSA1bC0zIDFjLTYgMi0xMSA1LTE0IDlsLTIgMy0xNSAyNiAyNiA1YzExIDcgMjUgMTAgMzggN2w0NiA5IDE4LTMweicgb3BhY2l0eT0nLjMnIGZpbGw9J3VybCgjYSknLz48cGF0aCBkPSdNNTIgMzVsLTQgMWMtMTcgNS0yMiAyMS0xMyAzNSAxMCAxMyAzMSAyMCA0OCAxNWw2Mi0yMVM5MiAyNiA1MiAzNXonIGZpbGw9JyM1MThhYzgnLz48bGluZWFyR3JhZGllbnQgaWQ9J2InIGdyYWRpZW50VW5pdHM9J3VzZXJTcGFjZU9uVXNlJyB4MT0nOTUuOCcgeTE9JzMyLjYnIHgyPSc3NCcgeTI9JzEwNS4yJz48c3RvcCBvZmZzZXQ9JzAnIHN0b3AtY29sb3I9J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wMC00OC0xNUw0IDEyMHM1MyA0MCA5NCAzMGwzLTFjMTctNSAyMy0yMSAxMy0zNHonIGZpbGw9J3VybCgjZCknLz48L3N2Zz4=";

export default function App() {
const [output, setOutput] = createSignal<{ result?: boolean }>({});

createEffect(async () => {
const request = await fetch(blobURI);
const blob = await request.blob();
const result = await ping(blob);
const value = await blob.text();
const test = await result.text();

setOutput(prev => ({ ...prev, result: value === test }));
});

return (
<main>
<span id="server-fn-test">{JSON.stringify(output())}</span>
</main>
);
}
26 changes: 26 additions & 0 deletions apps/tests/src/routes/server-function-form-data.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { createEffect, createSignal } from "solid-js";

async function ping(value: FormData) {
"use server";
const file = value.get("example") as File;
return await file.text();
}

export default function App() {
const [output, setOutput] = createSignal<{ result?: boolean }>({});

createEffect(async () => {
const file = new File(["Hello, World!"], "hello-world.txt");
const formData = new FormData();
formData.append("example", file);
const result = await ping(formData);
const value = await file.text();
setOutput(prev => ({ ...prev, result: value === result }));
});

return (
<main>
<span id="server-fn-test">{JSON.stringify(output())}</span>
</main>
);
}
23 changes: 23 additions & 0 deletions apps/tests/src/routes/server-function-ping.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createEffect, createSignal } from "solid-js";

async function ping(value: string) {
"use server";

return await Promise.resolve(value);
}

export default function App() {
const [output, setOutput] = createSignal<{ result?: boolean }>({});

createEffect(async () => {
const value = `${Math.random() * 1000}`;
const result = await ping(value);
setOutput(prev => ({ ...prev, result: value === result }));
});

return (
<main>
<span id="server-fn-test">{JSON.stringify(output())}</span>
</main>
);
}
4 changes: 2 additions & 2 deletions packages/start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"path-to-regexp": "^8.2.0",
"pathe": "^2.0.3",
"radix3": "^1.1.2",
"seroval": "^1.4.1",
"seroval-plugins": "^1.4.0",
"seroval": "^1.5.0",
"seroval-plugins": "^1.5.0",
"shiki": "^1.26.1",
"solid-js": "^1.9.9",
"source-map-js": "^1.2.1",
Expand Down
18 changes: 15 additions & 3 deletions packages/start/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ export interface SolidStartOptions {
routeDir?: string;
extensions?: string[];
middleware?: string;
serialization?: {
/**
* The serialization mode to use for server functions/actions.
* The "js" mode uses a custom binary format that is more efficient than JSON, but requires a custom deserializer (with `eval()`) on the client.
* A strong CSP should block `eval()` executions, which would prevent the "js" mode from working.
* The "json" mode uses JSON for serialization, which is less efficient but can be deserialized with `JSON.parse` on the client.
*
* @default "json"
*/
mode?: "js" | "json";
};
}

const absolute = (path: string, root: string) =>
Expand Down Expand Up @@ -131,6 +142,7 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
"import.meta.env.START_APP_ENTRY": JSON.stringify(appEntryPath),
"import.meta.env.START_CLIENT_ENTRY": JSON.stringify(handlers.client),
"import.meta.env.START_DEV_OVERLAY": JSON.stringify(start.devOverlay),
"import.meta.env.SEROVAL_MODE": JSON.stringify(start.serialization?.mode || "json"),
},
builder: {
sharedPlugins: true,
Expand Down Expand Up @@ -176,7 +188,7 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
envName: VITE_ENVIRONMENTS.client,
getRuntimeCode: () =>
`import { createServerReference } from "${normalizePath(
fileURLToPath(new URL("../server/server-runtime", import.meta.url))
fileURLToPath(new URL("../server/server-runtime", import.meta.url)),
)}"`,
replacer: opts => `createServerReference('${opts.functionId}')`,
},
Expand All @@ -185,7 +197,7 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
envName: VITE_ENVIRONMENTS.server,
getRuntimeCode: () =>
`import { createServerReference } from '${normalizePath(
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url))
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)),
)}'`,
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
},
Expand All @@ -194,7 +206,7 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
envName: VITE_ENVIRONMENTS.server,
getRuntimeCode: () =>
`import { createServerReference } from '${normalizePath(
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url))
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)),
)}'`,
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
},
Expand Down
Loading
Loading