diff --git a/src/node/utils/cssUtils.ts b/src/node/utils/cssUtils.ts index e20c1ce601d7f9..a6ee3153ced38f 100644 --- a/src/node/utils/cssUtils.ts +++ b/src/node/utils/cssUtils.ts @@ -159,13 +159,15 @@ export function getCssImportBoundaries( return boundaries } -export function recordCssImportChain(dependencies: string[], filePath: string) { +export function recordCssImportChain( + dependencies: Set, + filePath: string +) { const preImportees = cssImporteeMap.get(filePath) - const currentImportees = new Set(dependencies) // if import code change, should removed unused previous importee if (preImportees) { for (const preImportee of preImportees) { - if (!currentImportees.has(preImportee)) { + if (!dependencies.has(preImportee)) { const importers = cssImporterMap.get(preImportee) if (importers) { importers.delete(filePath) @@ -174,7 +176,7 @@ export function recordCssImportChain(dependencies: string[], filePath: string) { } } - currentImportees.forEach((dependency) => { + dependencies.forEach((dependency) => { if (cssImporterMap.has(dependency)) { cssImporterMap.get(dependency)!.add(filePath) } else { @@ -182,5 +184,5 @@ export function recordCssImportChain(dependencies: string[], filePath: string) { } }) - cssImporteeMap.set(filePath, currentImportees) + cssImporteeMap.set(filePath, dependencies) }