diff --git a/.changeset/six-rockets-jump.md b/.changeset/six-rockets-jump.md new file mode 100644 index 000000000..c03f87c49 --- /dev/null +++ b/.changeset/six-rockets-jump.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix CSS scanning bug that could lead to infinite loops diff --git a/packages/astro/src/core/ssr/css.ts b/packages/astro/src/core/ssr/css.ts index 550af10b7..15898cdab 100644 --- a/packages/astro/src/core/ssr/css.ts +++ b/packages/astro/src/core/ssr/css.ts @@ -18,6 +18,9 @@ export function getStylesForURL(filePath: URL, viteServer: vite.ViteDevServer): function crawlCSS(entryModule: string, scanned = new Set()) { const moduleName = idToModuleMap.get(entryModule); if (!moduleName) return; + if (!moduleName.id) return; + // mark the entrypoint as scanned to avoid an infinite loop + scanned.add(moduleName.id) for (const importedModule of moduleName.importedModules) { if (!importedModule.id || scanned.has(importedModule.id)) continue; const ext = path.extname(importedModule.id.toLowerCase());