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) {
|
2018-02-25 09:00:20 +08:00
|
|
|
compiler.hooks.compilation.tap(
|
|
|
|
"WarnCaseSensitiveModulesPlugin",
|
|
|
|
compilation => {
|
|
|
|
compilation.hooks.seal.tap("WarnCaseSensitiveModulesPlugin", () => {
|
|
|
|
const moduleWithoutCase = new Map();
|
|
|
|
for (const module of compilation.modules) {
|
|
|
|
const identifier = module.identifier().toLowerCase();
|
|
|
|
const array = moduleWithoutCase.get(identifier);
|
|
|
|
if (array) {
|
|
|
|
array.push(module);
|
|
|
|
} else {
|
|
|
|
moduleWithoutCase.set(identifier, [module]);
|
|
|
|
}
|
2017-01-04 15:32:10 +08:00
|
|
|
}
|
2018-02-25 09:00:20 +08:00
|
|
|
for (const pair of moduleWithoutCase) {
|
|
|
|
const array = pair[1];
|
|
|
|
if (array.length > 1)
|
|
|
|
compilation.warnings.push(new CaseSensitiveModulesWarning(array));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
2017-01-04 15:32:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = WarnCaseSensitiveModulesPlugin;
|