Skip to content

Commit 462194c

Browse files
willmendesnetosokra
authored andcommitted
refactor(WarnCaseSensitiveModulesPlugin): Using Map in moduleWithoutCase
1 parent 7140b7d commit 462194c

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

lib/WarnCaseSensitiveModulesPlugin.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ class WarnCaseSensitiveModulesPlugin {
1010
apply(compiler) {
1111
compiler.plugin("compilation", compilation => {
1212
compilation.plugin("seal", function() {
13-
const moduleWithoutCase = {};
13+
const moduleWithoutCase = new Map();
1414
this.modules.forEach(module => {
15-
const ident = module.identifier().toLowerCase();
16-
if(moduleWithoutCase[`$${ident}`]) {
17-
moduleWithoutCase[`$${ident}`].push(module);
15+
const identifier = module.identifier().toLowerCase();
16+
const moduleInstance = moduleWithoutCase.get(`$${identifier}`)
17+
if(moduleInstance) {
18+
moduleWithoutCase.set(`$${identifier}`, moduleInstance.push(module));
1819
} else {
19-
moduleWithoutCase[`$${ident}`] = [module];
20+
moduleWithoutCase.set(`$${identifier}`, [module]);
2021
}
21-
}, this);
22+
});
2223
Object.keys(moduleWithoutCase).forEach(key => {
23-
if(moduleWithoutCase[key].length > 1)
24-
this.warnings.push(new CaseSensitiveModulesWarning(moduleWithoutCase[key]));
24+
const moduleInstance = moduleWithoutCase.get(key);
25+
if(moduleInstance.length > 1)
26+
this.warnings.push(new CaseSensitiveModulesWarning(moduleInstance));
2527
}, this);
2628
});
2729
});

0 commit comments

Comments
 (0)