UNPKG

1.22 kBJavaScriptView Raw
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");
9const makeSerializable = require("./util/makeSerializable");
10
11/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
12/** @typedef {import("./Module")} Module */
13
14class ModuleDependencyWarning extends WebpackError {
15 /**
16 * @param {Module} module module tied to dependency
17 * @param {Error} err error thrown
18 * @param {DependencyLocation} loc location of dependency
19 */
20 constructor(module, err, loc) {
21 super(err ? err.message : "");
22
23 this.name = "ModuleDependencyWarning";
24 this.details =
25 err && !(/** @type {any} */ (err).hideStack)
26 ? err.stack.split("\n").slice(1).join("\n")
27 : undefined;
28 this.module = module;
29 this.loc = loc;
30 /** error is not (de)serialized, so it might be undefined after deserialization */
31 this.error = err;
32
33 if (err && /** @type {any} */ (err).hideStack) {
34 this.stack =
35 err.stack.split("\n").slice(1).join("\n") + "\n\n" + this.stack;
36 }
37 }
38}
39
40makeSerializable(
41 ModuleDependencyWarning,
42 "webpack/lib/ModuleDependencyWarning"
43);
44
45module.exports = ModuleDependencyWarning;