Skip to content

Commit 7140b7d

Browse files
willmendesnetosokra
authored andcommitted
refactor(ES6): upgrade WarnCaseSensitiveModulesPlugin to ES6
1 parent 93ac8e9 commit 7140b7d

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

lib/WarnCaseSensitiveModulesPlugin.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,30 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
var CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
5+
"use strict";
66

7-
function WarnCaseSensitiveModulesPlugin() {}
8-
module.exports = WarnCaseSensitiveModulesPlugin;
7+
const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
98

10-
WarnCaseSensitiveModulesPlugin.prototype.apply = function(compiler) {
11-
compiler.plugin("compilation", function(compilation) {
12-
compilation.plugin("seal", function() {
13-
var moduleWithoutCase = {};
14-
this.modules.forEach(function(module) {
15-
var ident = module.identifier().toLowerCase();
16-
if(moduleWithoutCase["$" + ident]) {
17-
moduleWithoutCase["$" + ident].push(module);
18-
} else {
19-
moduleWithoutCase["$" + ident] = [module];
20-
}
21-
}, this);
22-
Object.keys(moduleWithoutCase).forEach(function(key) {
23-
if(moduleWithoutCase[key].length > 1)
24-
this.warnings.push(new CaseSensitiveModulesWarning(moduleWithoutCase[key]));
25-
}, this);
9+
class WarnCaseSensitiveModulesPlugin {
10+
apply(compiler) {
11+
compiler.plugin("compilation", compilation => {
12+
compilation.plugin("seal", function() {
13+
const moduleWithoutCase = {};
14+
this.modules.forEach(module => {
15+
const ident = module.identifier().toLowerCase();
16+
if(moduleWithoutCase[`$${ident}`]) {
17+
moduleWithoutCase[`$${ident}`].push(module);
18+
} else {
19+
moduleWithoutCase[`$${ident}`] = [module];
20+
}
21+
}, this);
22+
Object.keys(moduleWithoutCase).forEach(key => {
23+
if(moduleWithoutCase[key].length > 1)
24+
this.warnings.push(new CaseSensitiveModulesWarning(moduleWithoutCase[key]));
25+
}, this);
26+
});
2627
});
27-
});
28-
};
28+
}
29+
}
30+
31+
module.exports = WarnCaseSensitiveModulesPlugin;

0 commit comments

Comments
 (0)