2016-06-24 07:51:52 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2018-07-30 23:08:51 +08:00
|
|
|
|
2017-01-10 13:00:03 +08:00
|
|
|
"use strict";
|
2017-01-10 00:11:34 +08:00
|
|
|
|
2017-03-25 05:17:47 +08:00
|
|
|
const WebpackError = require("./WebpackError");
|
2021-01-08 21:50:15 +08:00
|
|
|
const makeSerializable = require("./util/makeSerializable");
|
2017-01-10 13:00:03 +08:00
|
|
|
|
2020-08-03 02:09:36 +08:00
|
|
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
2018-11-07 21:03:25 +08:00
|
|
|
/** @typedef {import("./Module")} Module */
|
2025-03-27 08:07:25 +08:00
|
|
|
/** @typedef {import("./ModuleDependencyError").ErrorWithHideStack} ErrorWithHideStack */
|
2018-11-07 21:03:25 +08:00
|
|
|
|
2021-01-08 21:50:15 +08:00
|
|
|
class ModuleDependencyWarning extends WebpackError {
|
2018-11-07 21:03:25 +08:00
|
|
|
/**
|
|
|
|
* @param {Module} module module tied to dependency
|
2025-03-27 08:07:25 +08:00
|
|
|
* @param {ErrorWithHideStack} err error thrown
|
2020-08-03 02:09:36 +08:00
|
|
|
* @param {DependencyLocation} loc location of dependency
|
2018-11-07 21:03:25 +08:00
|
|
|
*/
|
2017-01-10 13:00:03 +08:00
|
|
|
constructor(module, err, loc) {
|
2021-01-08 21:50:15 +08:00
|
|
|
super(err ? err.message : "");
|
2016-06-24 07:51:52 +08:00
|
|
|
|
2017-01-10 13:00:03 +08:00
|
|
|
this.name = "ModuleDependencyWarning";
|
2021-02-05 22:55:31 +08:00
|
|
|
this.details =
|
2025-03-27 08:07:25 +08:00
|
|
|
err && !err.hideStack
|
2023-06-13 01:24:59 +08:00
|
|
|
? /** @type {string} */ (err.stack).split("\n").slice(1).join("\n")
|
2021-02-05 22:55:31 +08:00
|
|
|
: undefined;
|
2018-06-04 16:10:23 +08:00
|
|
|
this.module = module;
|
|
|
|
this.loc = loc;
|
2021-01-08 21:50:15 +08:00
|
|
|
/** error is not (de)serialized, so it might be undefined after deserialization */
|
2017-01-10 13:00:03 +08:00
|
|
|
this.error = err;
|
2017-02-16 03:55:54 +08:00
|
|
|
|
2025-03-27 08:07:25 +08:00
|
|
|
if (err && err.hideStack && err.stack) {
|
2024-07-31 10:39:30 +08:00
|
|
|
this.stack = /** @type {string} */ `${err.stack
|
|
|
|
.split("\n")
|
|
|
|
.slice(1)
|
|
|
|
.join("\n")}\n\n${this.stack}`;
|
2021-02-05 22:55:31 +08:00
|
|
|
}
|
2017-01-10 13:00:03 +08:00
|
|
|
}
|
2021-01-08 21:50:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
makeSerializable(
|
|
|
|
ModuleDependencyWarning,
|
|
|
|
"webpack/lib/ModuleDependencyWarning"
|
|
|
|
);
|
|
|
|
|
|
|
|
module.exports = ModuleDependencyWarning;
|