source: imaps-frontend/node_modules/webpack/lib/WarnCaseSensitiveModulesPlugin.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
9
10/** @typedef {import("./Compiler")} Compiler */
11/** @typedef {import("./Module")} Module */
12/** @typedef {import("./NormalModule")} NormalModule */
13
14class WarnCaseSensitiveModulesPlugin {
15 /**
16 * Apply the plugin
17 * @param {Compiler} compiler the compiler instance
18 * @returns {void}
19 */
20 apply(compiler) {
21 compiler.hooks.compilation.tap(
22 "WarnCaseSensitiveModulesPlugin",
23 compilation => {
24 compilation.hooks.seal.tap("WarnCaseSensitiveModulesPlugin", () => {
25 /** @type {Map<string, Map<string, Module>>} */
26 const moduleWithoutCase = new Map();
27 for (const module of compilation.modules) {
28 const identifier = module.identifier();
29
30 // Ignore `data:` URLs, because it's not a real path
31 if (
32 /** @type {NormalModule} */
33 (module).resourceResolveData !== undefined &&
34 /** @type {NormalModule} */
35 (module).resourceResolveData.encodedContent !== undefined
36 ) {
37 continue;
38 }
39
40 const lowerIdentifier = identifier.toLowerCase();
41 let map = moduleWithoutCase.get(lowerIdentifier);
42 if (map === undefined) {
43 map = new Map();
44 moduleWithoutCase.set(lowerIdentifier, map);
45 }
46 map.set(identifier, module);
47 }
48 for (const pair of moduleWithoutCase) {
49 const map = pair[1];
50 if (map.size > 1) {
51 compilation.warnings.push(
52 new CaseSensitiveModulesWarning(
53 map.values(),
54 compilation.moduleGraph
55 )
56 );
57 }
58 }
59 });
60 }
61 );
62 }
63}
64
65module.exports = WarnCaseSensitiveModulesPlugin;
Note: See TracBrowser for help on using the repository browser.