@@ -21,6 +21,17 @@ export interface SolidStartOptions {
2121 routeDir ?: string ;
2222 extensions ?: string [ ] ;
2323 middleware ?: string ;
24+ serialization ?: {
25+ /**
26+ * The serialization mode to use for server functions/actions.
27+ * The "js" mode uses a custom binary format that is more efficient than JSON, but requires a custom deserializer (with `eval()`) on the client.
28+ * A strong CSP should block `eval()` executions, which would prevent the "js" mode from working.
29+ * The "json" mode uses JSON for serialization, which is less efficient but can be deserialized with `JSON.parse` on the client.
30+ *
31+ * @default "json"
32+ */
33+ mode ?: "js" | "json" ;
34+ } ;
2435}
2536
2637const absolute = ( path : string , root : string ) =>
@@ -131,6 +142,7 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
131142 "import.meta.env.START_APP_ENTRY" : JSON . stringify ( appEntryPath ) ,
132143 "import.meta.env.START_CLIENT_ENTRY" : JSON . stringify ( handlers . client ) ,
133144 "import.meta.env.START_DEV_OVERLAY" : JSON . stringify ( start . devOverlay ) ,
145+ "import.meta.env.SEROVAL_MODE" : JSON . stringify ( start . serialization ?. mode || "json" ) ,
134146 } ,
135147 builder : {
136148 sharedPlugins : true ,
@@ -176,7 +188,7 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
176188 envName : VITE_ENVIRONMENTS . client ,
177189 getRuntimeCode : ( ) =>
178190 `import { createServerReference } from "${ normalizePath (
179- fileURLToPath ( new URL ( "../server/server-runtime" , import . meta. url ) )
191+ fileURLToPath ( new URL ( "../server/server-runtime" , import . meta. url ) ) ,
180192 ) } "`,
181193 replacer : opts => `createServerReference('${ opts . functionId } ')` ,
182194 } ,
@@ -185,7 +197,7 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
185197 envName : VITE_ENVIRONMENTS . server ,
186198 getRuntimeCode : ( ) =>
187199 `import { createServerReference } from '${ normalizePath (
188- fileURLToPath ( new URL ( "../server/server-fns-runtime" , import . meta. url ) )
200+ fileURLToPath ( new URL ( "../server/server-fns-runtime" , import . meta. url ) ) ,
189201 ) } '`,
190202 replacer : opts => `createServerReference(${ opts . fn } , '${ opts . functionId } ')` ,
191203 } ,
@@ -194,7 +206,7 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
194206 envName : VITE_ENVIRONMENTS . server ,
195207 getRuntimeCode : ( ) =>
196208 `import { createServerReference } from '${ normalizePath (
197- fileURLToPath ( new URL ( "../server/server-fns-runtime" , import . meta. url ) )
209+ fileURLToPath ( new URL ( "../server/server-fns-runtime" , import . meta. url ) ) ,
198210 ) } '`,
199211 replacer : opts => `createServerReference(${ opts . fn } , '${ opts . functionId } ')` ,
200212 } ,
0 commit comments