/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
lib/errors/ModuleWarning.js
67 строк
2 KB
Alexander Akait
refactor: annotate constructor fields with @type to improve type coverage (#21265)
24 июн 2026, 13:36
Не верифицирован
24 июн 2026, 13:36
e8f9334
Код
Авторство
О чём код?
/* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ "use strict"; const { cleanUp } = require("../ErrorHelpers"); const makeSerializable = require("../util/makeSerializable"); const WebpackError = require("./WebpackError"); /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[Error]>} ObjectDeserializerContext */ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[Error]>} ObjectSerializerContext */ class ModuleWarning extends WebpackError { /** * Creates an instance of ModuleWarning. * @param {Error} warning error thrown * @param {{ from?: string | null }} info additional info */ constructor(warning, { from = null } = {}) { let message = "Module Warning"; message += from ? ` (from ${from}):\n` : ": "; if (warning && typeof warning === "object" && warning.message) { message += warning.message; } else if (warning) { message += String(warning); } super(message); /** @type {string} */ this.name = "ModuleWarning"; /** @type {Error} */ this.warning = warning; /** @type {string | undefined} */ this.details = warning && typeof warning === "object" && warning.stack ? cleanUp(warning.stack, this.message) : undefined; } /** * Serializes this instance into the provided serializer context. * @param {ObjectSerializerContext} context context */ serialize(context) { context.write(this.warning); super.serialize(context); } /** * Restores this instance from the provided deserializer context. * @param {ObjectDeserializerContext} context context */ deserialize(context) { this.warning = context.read(); super.deserialize(context.rest); } } makeSerializable(ModuleWarning, "webpack/lib/errors/ModuleWarning"); /** @type {typeof ModuleWarning} */ module.exports = ModuleWarning;