@@ -493,7 +493,7 @@ export function serverSnapshot(options: ResolvedFreshViteConfig): Plugin[] {
493493 filter : {
494494 id : / ^ \0 f r e s h - r o u t e - c s s : : / ,
495495 } ,
496- async handler ( id ) {
496+ handler ( id ) {
497497 const name = id . slice ( "\0fresh-route-css::" . length ) ;
498498
499499 const route = routes . get ( name ) ;
@@ -503,10 +503,6 @@ export function serverSnapshot(options: ResolvedFreshViteConfig): Plugin[] {
503503 return `export default ["__FRESH_CSS_PLACEHOLDER__"];` ;
504504 }
505505
506- route . css = server === undefined
507- ? route . css
508- : await collectRouteCss ( server , route . filePath ) ;
509-
510506 const imports = route . css . map ( ( css ) => `import "${ css } ";` ) . join ( "\n" ) ;
511507 return `${ imports }
512508export default ${ JSON . stringify ( route . css ) }
@@ -598,55 +594,6 @@ export default mod.default;
598594 ] ;
599595}
600596
601- async function collectRouteCss (
602- server : ViteDevServer ,
603- id : string ,
604- ) : Promise < string [ ] > {
605- const env = server . environments . ssr ;
606- const out = new Set < string > ( ) ;
607- const seen = new Set < string > ( ) ;
608- const queue = [ id ] ;
609-
610- let current : string | undefined ;
611- while ( ( current = queue . pop ( ) ) !== undefined ) {
612- if ( seen . has ( current ) ) continue ;
613- seen . add ( current ) ;
614-
615- // Modules may be registered under either their public id or Vite's
616- // internal "\0" id, depending on when they entered the graph.
617- let mod = env . moduleGraph . getModuleById ( current ) ??
618- env . moduleGraph . getModuleById ( `\0${ current } ` ) ;
619-
620- if ( mod ?. transformResult == null ) {
621- // Dev transforms are lazy. Force Vite to load the module before we
622- // inspect its imports for CSS dependencies.
623- await env . fetchModule ( current ) ;
624- mod = env . moduleGraph . getModuleById ( current ) ??
625- env . moduleGraph . getModuleById ( `\0${ current } ` ) ;
626- }
627-
628- // Some ids still won't resolve into the SSR graph (for example, if Vite
629- // does not materialize the module after fetch). Skip those and keep
630- // collecting CSS from the remaining graph.
631- if ( mod === undefined ) continue ;
632-
633- if ( mod . id !== null && CSS_LANG_REG . test ( mod . id ) ) {
634- out . add ( mod . url ) ;
635- continue ;
636- }
637-
638- // Layout/app/error utility files can reach CSS through nested component
639- // imports, so walk the full SSR import graph for this route module.
640- mod . importedModules . forEach ( ( imported ) => {
641- if ( imported . id !== null ) {
642- queue . push ( imported . id ) ;
643- }
644- } ) ;
645- }
646-
647- return Array . from ( out ) ;
648- }
649-
650597function walkUp (
651598 mod : EnvironmentModuleNode ,
652599 fn : ( mod : EnvironmentModuleNode ) => boolean ,
0 commit comments