1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 | const { cleanUp } = require("./ErrorHelpers");
|
9 | const WebpackError = require("./WebpackError");
|
10 | const makeSerializable = require("./util/makeSerializable");
|
11 |
|
12 | class ModuleWarning extends WebpackError {
|
13 | |
14 |
|
15 |
|
16 |
|
17 | constructor(warning, { from = null } = {}) {
|
18 | let message = "Module Warning";
|
19 |
|
20 | if (from) {
|
21 | message += ` (from ${from}):\n`;
|
22 | } else {
|
23 | message += ": ";
|
24 | }
|
25 |
|
26 | if (warning && typeof warning === "object" && warning.message) {
|
27 | message += warning.message;
|
28 | } else if (warning) {
|
29 | message += String(warning);
|
30 | }
|
31 |
|
32 | super(message);
|
33 |
|
34 | this.name = "ModuleWarning";
|
35 | this.warning = warning;
|
36 | this.details =
|
37 | warning && typeof warning === "object" && warning.stack
|
38 | ? cleanUp(warning.stack, this.message)
|
39 | : undefined;
|
40 |
|
41 | Error.captureStackTrace(this, this.constructor);
|
42 | }
|
43 |
|
44 | serialize(context) {
|
45 | const { write } = context;
|
46 |
|
47 | write(this.warning);
|
48 |
|
49 | super.serialize(context);
|
50 | }
|
51 |
|
52 | deserialize(context) {
|
53 | const { read } = context;
|
54 |
|
55 | this.warning = read();
|
56 |
|
57 | super.deserialize(context);
|
58 | }
|
59 | }
|
60 |
|
61 | makeSerializable(ModuleWarning, "webpack/lib/ModuleWarning");
|
62 |
|
63 | module.exports = ModuleWarning;
|