|
2 | 2 | MIT License http://www.opensource.org/licenses/mit-license.php |
3 | 3 | Author Tobias Koppers @sokra |
4 | 4 | */ |
5 | | -var CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning"); |
| 5 | +"use strict"; |
6 | 6 |
|
7 | | -function WarnCaseSensitiveModulesPlugin() {} |
8 | | -module.exports = WarnCaseSensitiveModulesPlugin; |
| 7 | +const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning"); |
9 | 8 |
|
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", () => { |
| 13 | + const moduleWithoutCase = Object.create(null); |
| 14 | + compilation.modules.forEach(module => { |
| 15 | + const identifier = module.identifier().toLowerCase(); |
| 16 | + if(moduleWithoutCase[identifier]) { |
| 17 | + moduleWithoutCase[identifier].push(module); |
| 18 | + } else { |
| 19 | + moduleWithoutCase[identifier] = [module]; |
| 20 | + } |
| 21 | + }); |
| 22 | + Object.keys(moduleWithoutCase).forEach(key => { |
| 23 | + if(moduleWithoutCase[key].length > 1) |
| 24 | + compilation.warnings.push(new CaseSensitiveModulesWarning(moduleWithoutCase[key])); |
| 25 | + }); |
| 26 | + }); |
26 | 27 | }); |
27 | | - }); |
28 | | -}; |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +module.exports = WarnCaseSensitiveModulesPlugin; |
0 commit comments