source: imaps-frontend/node_modules/webpack/lib/CaseSensitiveModulesWarning.js

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

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[79a0317]1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const WebpackError = require("./WebpackError");
9
10/** @typedef {import("./Module")} Module */
11/** @typedef {import("./ModuleGraph")} ModuleGraph */
12
13/**
14 * @param {Module[]} modules the modules to be sorted
15 * @returns {Module[]} sorted version of original modules
16 */
17const sortModules = modules =>
18 modules.sort((a, b) => {
19 const aIdent = a.identifier();
20 const bIdent = b.identifier();
21 /* istanbul ignore next */
22 if (aIdent < bIdent) return -1;
23 /* istanbul ignore next */
24 if (aIdent > bIdent) return 1;
25 /* istanbul ignore next */
26 return 0;
27 });
28
29/**
30 * @param {Module[]} modules each module from throw
31 * @param {ModuleGraph} moduleGraph the module graph
32 * @returns {string} each message from provided modules
33 */
34const createModulesListMessage = (modules, moduleGraph) =>
35 modules
36 .map(m => {
37 let message = `* ${m.identifier()}`;
38 const validReasons = Array.from(
39 moduleGraph.getIncomingConnectionsByOriginModule(m).keys()
40 ).filter(Boolean);
41
42 if (validReasons.length > 0) {
43 message += `\n Used by ${validReasons.length} module(s), i. e.`;
44 message += `\n ${
45 /** @type {Module[]} */ (validReasons)[0].identifier()
46 }`;
47 }
48 return message;
49 })
50 .join("\n");
51
52class CaseSensitiveModulesWarning extends WebpackError {
53 /**
54 * Creates an instance of CaseSensitiveModulesWarning.
55 * @param {Iterable<Module>} modules modules that were detected
56 * @param {ModuleGraph} moduleGraph the module graph
57 */
58 constructor(modules, moduleGraph) {
59 const sortedModules = sortModules(Array.from(modules));
60 const modulesList = createModulesListMessage(sortedModules, moduleGraph);
61 super(`There are multiple modules with names that only differ in casing.
62This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
63Use equal casing. Compare these module identifiers:
64${modulesList}`);
65
66 this.name = "CaseSensitiveModulesWarning";
67 this.module = sortedModules[0];
68 }
69}
70
71module.exports = CaseSensitiveModulesWarning;
Note: See TracBrowser for help on using the repository browser.