@@ -18,6 +18,7 @@ import {
1818 ssrEntryFile ,
1919 type UserNitroConfig
2020} from "./nitroPlugin.js" ;
21+ import { BaseFileSystemRouter } from "./fs-routes/router.js" ;
2122
2223const DEFAULT_EXTENSIONS = [ "js" , "jsx" , "ts" , "tsx" ] ;
2324
@@ -112,6 +113,8 @@ function solidStartVitePlugin(options?: SolidStartOptions): Array<PluginOption>
112113 server : `${ start . appRoot } /entry-server${ entryExtension } `
113114 } ;
114115
116+ const root = process . cwd ( ) ;
117+
115118 return [
116119 {
117120 name : "solid-start:vite-config" ,
@@ -123,7 +126,24 @@ function solidStartVitePlugin(options?: SolidStartOptions): Array<PluginOption>
123126 }
124127 } ;
125128 } ,
126- config ( _ , env ) {
129+ async config ( _ , env ) {
130+ let clientInput = [ handlers . client ] ;
131+
132+ if ( env . command === "build" ) {
133+ const clientRouter : BaseFileSystemRouter = ( globalThis as any ) . ROUTERS . client
134+ for ( const route of await clientRouter . getRoutes ( ) ) {
135+ for ( const [ key , value ] of Object . entries ( route ) ) {
136+ if ( value && key . startsWith ( "$" ) && ! key . startsWith ( "$$" ) ) {
137+ function toRouteId ( route : any ) {
138+ return `${ route . src } ?${ route . pick . map ( ( p : string ) => `pick=${ p } ` ) . join ( "&" ) } ` ;
139+ }
140+
141+ clientInput . push ( toRouteId ( value ) ) ;
142+ }
143+ }
144+ }
145+ }
146+
127147 return {
128148 base : env . command === "build" ? `/${ CLIENT_BASE_PATH } ` : undefined ,
129149 environments : {
@@ -134,13 +154,13 @@ function solidStartVitePlugin(options?: SolidStartOptions): Array<PluginOption>
134154 write : true ,
135155 manifest : true ,
136156 rollupOptions : {
137- input : {
138- client : handlers . client
139- } ,
157+ input : clientInput ,
140158 output : {
141159 dir : path . resolve ( process . cwd ( ) , clientDistDir , CLIENT_BASE_PATH )
142160 } ,
143- external : [ "node:fs" , "node:path" , "node:os" , "node:crypto" ]
161+ external : [ "node:fs" , "node:path" , "node:os" , "node:crypto" ] ,
162+ treeshake : true ,
163+ preserveEntrySignatures : "exports-only" ,
144164 }
145165 }
146166 } ,
@@ -196,14 +216,14 @@ function solidStartVitePlugin(options?: SolidStartOptions): Array<PluginOption>
196216 css ( ) ,
197217 fsRoutes ( {
198218 routers : {
199- client : config =>
219+ client :
200220 new SolidStartClientFileRouter ( {
201- dir : absolute ( routeDir , config . root ) ,
221+ dir : absolute ( routeDir , root ) ,
202222 extensions
203223 } ) ,
204- server : config =>
224+ server :
205225 new SolidStartServerFileRouter ( {
206- dir : absolute ( routeDir , config . root ) ,
226+ dir : absolute ( routeDir , root ) ,
207227 extensions,
208228 dataOnly : ! start . ssr
209229 } )
0 commit comments