fix: avoid infinite loops in crawlCSS (#1956)
This commit is contained in:
parent
902405f4a3
commit
8775730eb9
2 changed files with 8 additions and 0 deletions
5
.changeset/six-rockets-jump.md
Normal file
5
.changeset/six-rockets-jump.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix CSS scanning bug that could lead to infinite loops
|
|
@ -18,6 +18,9 @@ export function getStylesForURL(filePath: URL, viteServer: vite.ViteDevServer):
|
||||||
function crawlCSS(entryModule: string, scanned = new Set<string>()) {
|
function crawlCSS(entryModule: string, scanned = new Set<string>()) {
|
||||||
const moduleName = idToModuleMap.get(entryModule);
|
const moduleName = idToModuleMap.get(entryModule);
|
||||||
if (!moduleName) return;
|
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) {
|
for (const importedModule of moduleName.importedModules) {
|
||||||
if (!importedModule.id || scanned.has(importedModule.id)) continue;
|
if (!importedModule.id || scanned.has(importedModule.id)) continue;
|
||||||
const ext = path.extname(importedModule.id.toLowerCase());
|
const ext = path.extname(importedModule.id.toLowerCase());
|
||||||
|
|
Loading…
Add table
Reference in a new issue