Skip to content

Commit 414350d

Browse files
committed
rm collect css
1 parent 814e3b5 commit 414350d

1 file changed

Lines changed: 1 addition & 55 deletions

File tree

packages/plugin-vite/src/plugins/server_snapshot.ts

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ export function serverSnapshot(options: ResolvedFreshViteConfig): Plugin[] {
493493
filter: {
494494
id: /^\0fresh-route-css::/,
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,11 +503,6 @@ export function serverSnapshot(options: ResolvedFreshViteConfig): Plugin[] {
503503
return `export default ["__FRESH_CSS_PLACEHOLDER__"];`;
504504
}
505505

506-
// Re-collected on every load for HMR correctness.
507-
route.css = server === undefined
508-
? route.css
509-
: await collectRouteCss(server, route.filePath);
510-
511506
const imports = route.css.map((css) => `import "${css}";`).join("\n");
512507
return `${imports}
513508
export default ${JSON.stringify(route.css)}
@@ -599,55 +594,6 @@ export default mod.default;
599594
];
600595
}
601596

602-
async function collectRouteCss(
603-
server: ViteDevServer,
604-
id: string,
605-
): Promise<string[]> {
606-
const env = server.environments.ssr;
607-
const out = new Set<string>();
608-
const seen = new Set<string>();
609-
const queue = [id];
610-
611-
let current: string | undefined;
612-
while ((current = queue.pop()) !== undefined) {
613-
if (seen.has(current)) continue;
614-
seen.add(current);
615-
616-
// Modules may be registered under either their public id or Vite's
617-
// internal "\0" id, depending on when they entered the graph.
618-
let mod = env.moduleGraph.getModuleById(current) ??
619-
env.moduleGraph.getModuleById(`\0${current}`);
620-
621-
if (mod?.transformResult == null) {
622-
// Dev transforms are lazy. Force Vite to load the module before we
623-
// inspect its imports for CSS dependencies.
624-
await env.fetchModule(current);
625-
mod = env.moduleGraph.getModuleById(current) ??
626-
env.moduleGraph.getModuleById(`\0${current}`);
627-
}
628-
629-
// Some ids still won't resolve into the SSR graph (for example, if Vite
630-
// does not materialize the module after fetch). Skip those and keep
631-
// collecting CSS from the remaining graph.
632-
if (mod === undefined) continue;
633-
634-
if (mod.id !== null && CSS_LANG_REG.test(mod.id)) {
635-
out.add(mod.url);
636-
continue;
637-
}
638-
639-
// Layout/app/error utility files can reach CSS through nested component
640-
// imports, so walk the full SSR import graph for this route module.
641-
mod.importedModules.forEach((imported) => {
642-
if (imported.id !== null) {
643-
queue.push(imported.id);
644-
}
645-
});
646-
}
647-
648-
return Array.from(out);
649-
}
650-
651597
function walkUp(
652598
mod: EnvironmentModuleNode,
653599
fn: (mod: EnvironmentModuleNode) => boolean,

0 commit comments

Comments
 (0)