source: imaps-frontend/node_modules/webpack/lib/ModuleNotFoundError.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: 2.6 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("./Dependency").DependencyLocation} DependencyLocation */
11/** @typedef {import("./Module")} Module */
12
13const previouslyPolyfilledBuiltinModules = {
14 assert: "assert/",
15 buffer: "buffer/",
16 console: "console-browserify",
17 constants: "constants-browserify",
18 crypto: "crypto-browserify",
19 domain: "domain-browser",
20 events: "events/",
21 http: "stream-http",
22 https: "https-browserify",
23 os: "os-browserify/browser",
24 path: "path-browserify",
25 punycode: "punycode/",
26 process: "process/browser",
27 querystring: "querystring-es3",
28 stream: "stream-browserify",
29 _stream_duplex: "readable-stream/duplex",
30 _stream_passthrough: "readable-stream/passthrough",
31 _stream_readable: "readable-stream/readable",
32 _stream_transform: "readable-stream/transform",
33 _stream_writable: "readable-stream/writable",
34 string_decoder: "string_decoder/",
35 sys: "util/",
36 timers: "timers-browserify",
37 tty: "tty-browserify",
38 url: "url/",
39 util: "util/",
40 vm: "vm-browserify",
41 zlib: "browserify-zlib"
42};
43
44class ModuleNotFoundError extends WebpackError {
45 /**
46 * @param {Module | null} module module tied to dependency
47 * @param {Error&any} err error thrown
48 * @param {DependencyLocation} loc location of dependency
49 */
50 constructor(module, err, loc) {
51 let message = `Module not found: ${err.toString()}`;
52
53 // TODO remove in webpack 6
54 const match = err.message.match(/Can't resolve '([^']+)'/);
55 if (match) {
56 const request = match[1];
57 const alias =
58 previouslyPolyfilledBuiltinModules[
59 /** @type {keyof previouslyPolyfilledBuiltinModules} */ (request)
60 ];
61 if (alias) {
62 const pathIndex = alias.indexOf("/");
63 const dependency = pathIndex > 0 ? alias.slice(0, pathIndex) : alias;
64 message +=
65 "\n\n" +
66 "BREAKING CHANGE: " +
67 "webpack < 5 used to include polyfills for node.js core modules by default.\n" +
68 "This is no longer the case. Verify if you need this module and configure a polyfill for it.\n\n";
69 message +=
70 "If you want to include a polyfill, you need to:\n" +
71 `\t- add a fallback 'resolve.fallback: { "${request}": require.resolve("${alias}") }'\n` +
72 `\t- install '${dependency}'\n`;
73 message +=
74 "If you don't want to include a polyfill, you can use an empty module like this:\n" +
75 `\tresolve.fallback: { "${request}": false }`;
76 }
77 }
78
79 super(message);
80
81 this.name = "ModuleNotFoundError";
82 this.details = err.details;
83 this.module = module;
84 this.error = err;
85 this.loc = loc;
86 }
87}
88
89module.exports = ModuleNotFoundError;
Note: See TracBrowser for help on using the repository browser.