Skip to content

Commit e83c493

Browse files
committed
fix: lint issues
1 parent 3c0db60 commit e83c493

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

src/plugin.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,40 +57,33 @@ export class FilterChunkWebpackPlugin {
5757

5858
if (isIncludeMode) {
5959
// Include mode: collect matches from all rules (union), remove non-matched
60-
const toKeep = new Set<string>();
61-
const keepLabels = new Map<string, string>();
60+
const toKeep = new Map<string, string>();
6261

6362
for (const filename of filenames) {
6463
const asset = assets[filename];
6564
for (const { matcher, label } of ruleMatchers) {
6665
if (await matcher(filename, asset)) {
67-
toKeep.add(filename);
68-
keepLabels.set(filename, label);
66+
toKeep.set(filename, label);
6967
break;
7068
}
7169
}
7270
}
7371

7472
// Remove files not in the keep set
75-
const toRemove: Array<{ filename: string; label: string }> = [];
73+
let removedCount = 0;
7674
for (const filename of filenames) {
7775
if (!toKeep.has(filename)) {
78-
toRemove.push({ filename, label: "[not matched]" });
76+
compilation.deleteAsset(filename);
77+
removedCount++;
7978
}
8079
}
8180

82-
for (const { filename } of toRemove) {
83-
compilation.deleteAsset(filename);
84-
}
85-
86-
// Log kept files instead of removed
87-
for (const filename of toKeep) {
88-
// Label is guaranteed to exist since we set it when adding to toKeep
89-
const label = keepLabels.get(filename)!;
81+
// Log kept files
82+
for (const [filename, label] of toKeep) {
9083
logger.kept(filename, label);
9184
}
9285

93-
logger.summary(filenames.length, toRemove.length, isIncludeMode);
86+
logger.summary(filenames.length, removedCount, isIncludeMode);
9487
} else {
9588
// Exclude mode: pipeline, remove matches
9689
const toRemove: Array<{ filename: string; label: string }> = [];

0 commit comments

Comments
 (0)