UNPKG

1.02 kBJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5"use strict";
6
7const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
8
9class WarnCaseSensitiveModulesPlugin {
10 apply(compiler) {
11 compiler.hooks.compilation.tap(
12 "WarnCaseSensitiveModulesPlugin",
13 compilation => {
14 compilation.hooks.seal.tap("WarnCaseSensitiveModulesPlugin", () => {
15 const moduleWithoutCase = new Map();
16 for (const module of compilation.modules) {
17 const identifier = module.identifier().toLowerCase();
18 const array = moduleWithoutCase.get(identifier);
19 if (array) {
20 array.push(module);
21 } else {
22 moduleWithoutCase.set(identifier, [module]);
23 }
24 }
25 for (const pair of moduleWithoutCase) {
26 const array = pair[1];
27 if (array.length > 1) {
28 compilation.warnings.push(new CaseSensitiveModulesWarning(array));
29 }
30 }
31 });
32 }
33 );
34 }
35}
36
37module.exports = WarnCaseSensitiveModulesPlugin;