2014-03-31 17:33:17 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2017-01-04 15:32:10 +08:00
|
|
|
"use strict";
|
2014-03-31 17:33:17 +08:00
|
|
|
|
2017-01-04 15:32:10 +08:00
|
|
|
const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
|
2014-03-31 17:33:17 +08:00
|
|
|
|
2017-01-04 15:32:10 +08:00
|
|
|
class WarnCaseSensitiveModulesPlugin {
|
|
|
|
apply(compiler) {
|
|
|
|
compiler.plugin("compilation", compilation => {
|
|
|
|
compilation.plugin("seal", function() {
|
2017-01-05 19:12:15 +08:00
|
|
|
const moduleWithoutCase = new Map();
|
2017-01-04 15:32:10 +08:00
|
|
|
this.modules.forEach(module => {
|
2017-01-05 19:12:15 +08:00
|
|
|
const identifier = module.identifier().toLowerCase();
|
|
|
|
const moduleInstance = moduleWithoutCase.get(`$${identifier}`)
|
|
|
|
if(moduleInstance) {
|
|
|
|
moduleWithoutCase.set(`$${identifier}`, moduleInstance.push(module));
|
2017-01-04 15:32:10 +08:00
|
|
|
} else {
|
2017-01-05 19:12:15 +08:00
|
|
|
moduleWithoutCase.set(`$${identifier}`, [module]);
|
2017-01-04 15:32:10 +08:00
|
|
|
}
|
2017-01-05 19:12:15 +08:00
|
|
|
});
|
2017-01-04 15:32:10 +08:00
|
|
|
Object.keys(moduleWithoutCase).forEach(key => {
|
2017-01-05 19:12:15 +08:00
|
|
|
const moduleInstance = moduleWithoutCase.get(key);
|
|
|
|
if(moduleInstance.length > 1)
|
|
|
|
this.warnings.push(new CaseSensitiveModulesWarning(moduleInstance));
|
2017-01-04 15:32:10 +08:00
|
|
|
}, this);
|
|
|
|
});
|
2014-03-31 17:33:17 +08:00
|
|
|
});
|
2017-01-04 15:32:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = WarnCaseSensitiveModulesPlugin;
|