MCPcopy
hub / github.com/webpack/webpack / apply

Method apply

lib/WarnCaseSensitiveModulesPlugin.js:91–130  ·  lib/WarnCaseSensitiveModulesPlugin.js::WarnCaseSensitiveModulesPlugin.apply

* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}

(compiler)

Source from the content-addressed store, hash-verified

89 * @returns {void}
90 */
91 apply(compiler) {
92 compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
93 compilation.hooks.seal.tap(PLUGIN_NAME, () => {
94 /** @type {Map<string, Map<string, Module>>} */
95 const moduleWithoutCase = new Map();
96 for (const module of compilation.modules) {
97 const identifier = module.identifier();
98
99 class="cm">// Ignore `data:` URLs, because it's not a real path
100 if (
101 /** @type {NormalModule} */
102 (module).resourceResolveData !== undefined &&
103 /** @type {NormalModule} */
104 (module).resourceResolveData.encodedContent !== undefined
105 ) {
106 continue;
107 }
108
109 const lowerIdentifier = identifier.toLowerCase();
110 let map = moduleWithoutCase.get(lowerIdentifier);
111 if (map === undefined) {
112 map = new Map();
113 moduleWithoutCase.set(lowerIdentifier, map);
114 }
115 map.set(identifier, module);
116 }
117 for (const pair of moduleWithoutCase) {
118 const map = pair[1];
119 if (map.size > 1) {
120 compilation.warnings.push(
121 new CaseSensitiveModulesWarning(
122 map.values(),
123 compilation.moduleGraph
124 )
125 );
126 }
127 }
128 });
129 });
130 }
131}
132
133module.exports = WarnCaseSensitiveModulesPlugin;

Callers

nothing calls this directly

Calls 6

tapMethod · 0.80
identifierMethod · 0.45
getMethod · 0.45
setMethod · 0.45
pushMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected