1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- "use strict";
- const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
- class WarnCaseSensitiveModulesPlugin {
-
- apply(compiler) {
- 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();
-
- if (
-
- (module).resourceResolveData !== undefined &&
-
- (module).resourceResolveData.encodedContent !== undefined
- ) {
- continue;
- }
- const lowerIdentifier = identifier.toLowerCase();
- let map = moduleWithoutCase.get(lowerIdentifier);
- if (map === undefined) {
- map = new Map();
- moduleWithoutCase.set(lowerIdentifier, map);
- }
- map.set(identifier, module);
- }
- for (const pair of moduleWithoutCase) {
- const map = pair[1];
- if (map.size > 1) {
- compilation.warnings.push(
- new CaseSensitiveModulesWarning(
- map.values(),
- compilation.moduleGraph
- )
- );
- }
- }
- });
- }
- );
- }
- }
- module.exports = WarnCaseSensitiveModulesPlugin;
|