1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 | const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
|
9 |
|
10 |
|
11 |
|
12 | class WarnCaseSensitiveModulesPlugin {
|
13 | |
14 |
|
15 |
|
16 |
|
17 |
|
18 | apply(compiler) {
|
19 | compiler.hooks.compilation.tap(
|
20 | "WarnCaseSensitiveModulesPlugin",
|
21 | compilation => {
|
22 | compilation.hooks.seal.tap("WarnCaseSensitiveModulesPlugin", () => {
|
23 | const moduleWithoutCase = new Map();
|
24 | for (const module of compilation.modules) {
|
25 | const identifier = module.identifier().toLowerCase();
|
26 | const array = moduleWithoutCase.get(identifier);
|
27 | if (array) {
|
28 | array.push(module);
|
29 | } else {
|
30 | moduleWithoutCase.set(identifier, [module]);
|
31 | }
|
32 | }
|
33 | for (const pair of moduleWithoutCase) {
|
34 | const array = pair[1];
|
35 | if (array.length > 1) {
|
36 | compilation.warnings.push(
|
37 | new CaseSensitiveModulesWarning(array, compilation.moduleGraph)
|
38 | );
|
39 | }
|
40 | }
|
41 | });
|
42 | }
|
43 | );
|
44 | }
|
45 | }
|
46 |
|
47 | module.exports = WarnCaseSensitiveModulesPlugin;
|