11import { defu } from "defu" ;
22import { globSync } from "node:fs" ;
33import { extname , isAbsolute , join } from "node:path" ;
4- import { fileURLToPath } from "node:url" ;
5- import { normalizePath , type PluginOption } from "vite" ;
4+ import type { PluginOption } from "vite" ;
65import solid , { type Options as SolidOptions } from "vite-plugin-solid" ;
7- import { serverFunctionsPlugin } from "../directives/index.ts" ;
6+ import { type ServerFunctionsOptions , serverFunctionsPlugin } from "../directives/index.ts" ;
87import { DEFAULT_EXTENSIONS , VIRTUAL_MODULES , VITE_ENVIRONMENTS } from "./constants.ts" ;
98import { devServer } from "./dev-server.ts" ;
10- import { type EnvPluginOptions , envPlugin } from "./env.ts" ;
9+ import { envPlugin , type EnvPluginOptions } from "./env.ts" ;
1110import { SolidStartClientFileRouter , SolidStartServerFileRouter } from "./fs-router.ts" ;
1211import { fsRoutes } from "./fs-routes/index.ts" ;
1312import type { BaseFileSystemRouter } from "./fs-routes/router.ts" ;
@@ -33,6 +32,7 @@ export interface SolidStartOptions {
3332 mode ?: "js" | "json" ;
3433 } ;
3534 env ?: EnvPluginOptions ;
35+ serverFunctions ?: Pick < ServerFunctionsOptions , "filter" > ;
3636}
3737
3838const absolute = ( path : string , root : string ) =>
@@ -144,6 +144,9 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
144144 }
145145 : { } ) ,
146146 } ,
147+ // Depending on the package manager and dependency structure Vite externalizes @solidjs /start
148+ // This makes sure that @solidjs /start goes through the Vite build process
149+ noExternal : [ "@solidjs/start" ] ,
147150 } ,
148151 define : {
149152 "import.meta.env.MANIFEST" : `globalThis.MANIFEST` ,
@@ -192,13 +195,10 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
192195 serverFunctionsPlugin ( {
193196 manifest : VIRTUAL_MODULES . serverFnManifest ,
194197 runtime : {
195- server : normalizePath (
196- fileURLToPath ( new URL ( "../server/server-fns-runtime.ts" , import . meta. url ) ) ,
197- ) ,
198- client : normalizePath (
199- fileURLToPath ( new URL ( "../server/server-runtime.ts" , import . meta. url ) ) ,
200- ) ,
198+ server : '@solidjs/start/fns/server' ,
199+ client : '@solidjs/start/fns/client' ,
201200 } ,
201+ filter : options ?. serverFunctions ?. filter ,
202202 } ) ,
203203 {
204204 name : "solid-start:virtual-modules" ,
0 commit comments