UNPKG

901 BJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5"use strict";
6
7const WebpackError = require("./WebpackError");
8const { cleanUp } = require("./ErrorHelpers");
9
10class ModuleWarning extends WebpackError {
11 constructor(module, warning, { from = null } = {}) {
12 let message = "Module Warning";
13 if (from) {
14 message += ` (from ${from}):\n`;
15 } else {
16 message += ": ";
17 }
18 if (warning && typeof warning === "object" && warning.message) {
19 message += warning.message;
20 } else if (warning) {
21 message += warning;
22 }
23 super(message);
24 this.name = "ModuleWarning";
25 this.module = module;
26 this.warning = warning;
27 this.details =
28 warning && typeof warning === "object" && warning.stack
29 ? cleanUp(warning.stack, this.message)
30 : undefined;
31
32 Error.captureStackTrace(this, this.constructor);
33 }
34}
35
36module.exports = ModuleWarning;