fix: respect the `cause` of any errors and the `errors` of `AggregateError` in stats

This commit is contained in:
alexander-akait 2025-04-23 00:24:52 +03:00
parent f8d7638eea
commit e6ed2acecf
19 changed files with 373 additions and 80 deletions

View File

@ -239,10 +239,7 @@ export type IgnoreWarnings = (
*/
module?: RegExp;
}
| ((
warning: import("../lib/WebpackError"),
compilation: import("../lib/Compilation")
) => boolean)
| ((warning: Error, compilation: import("../lib/Compilation")) => boolean)
)[];
/**
* Filtering values.
@ -823,7 +820,7 @@ export type HttpUriOptionsAllowedUris = (
* Ignore specific warnings.
*/
export type IgnoreWarningsNormalized = ((
warning: import("../lib/WebpackError"),
warning: Error,
compilation: import("../lib/Compilation")
) => boolean)[];
/**
@ -2600,10 +2597,18 @@ export interface StatsOptions {
* Add --env information.
*/
env?: boolean;
/**
* Add cause to errors.
*/
errorCause?: "auto" | boolean;
/**
* Add details to errors (like resolving log).
*/
errorDetails?: "auto" | boolean;
/**
* Add nested errors to errors (like in AggregateError).
*/
errorErrors?: "auto" | boolean;
/**
* Add internal stack trace to errors.
*/

View File

@ -973,9 +973,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
/** @type {SyncBailHook<[string, LogEntry], boolean | void>} */
log: new SyncBailHook(["origin", "logEntry"]),
/** @type {SyncWaterfallHook<[WebpackError[]]>} */
/** @type {SyncWaterfallHook<[Error[]]>} */
processWarnings: new SyncWaterfallHook(["warnings"]),
/** @type {SyncWaterfallHook<[WebpackError[]]>} */
/** @type {SyncWaterfallHook<[Error[]]>} */
processErrors: new SyncWaterfallHook(["errors"]),
/** @type {HookMap<SyncHook<[Partial<NormalizedStatsOptions>, CreateStatsOptionsContext]>>} */
@ -1143,9 +1143,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
this.assetsInfo = new Map();
/** @type {Map<string, Map<string, Set<string>>>} */
this._assetsRelatedIn = new Map();
/** @type {WebpackError[]} */
/** @type {Error[]} */
this.errors = [];
/** @type {WebpackError[]} */
/** @type {Error[]} */
this.warnings = [];
/** @type {Compilation[]} */
this.children = [];
@ -5486,9 +5486,9 @@ This prevents using hashes of each other and should be avoided.`);
if (strictModuleExceptionHandling) {
if (id) delete moduleCache[id];
} else if (strictModuleErrorHandling) {
moduleObject.error = /** @type {WebpackError} */ (
execErr
);
moduleObject.error =
/** @type {WebpackError} */
(execErr);
}
if (!(/** @type {WebpackError} */ (execErr).module)) {
/** @type {WebpackError} */
@ -5515,7 +5515,8 @@ This prevents using hashes of each other and should be avoided.`);
`Execution of module code from module graph (${
/** @type {Module} */
(module).readableIdentifier(this.requestShortener)
}) failed: ${message}`
}) failed: ${message}`,
{ cause: execErr }
);
err.stack = stack;
err.module = module;

View File

@ -625,7 +625,8 @@ class Compiler {
callback(err, entries, compilation);
} catch (runAsChildErr) {
const err = new WebpackError(
`compiler.runAsChild callback error: ${runAsChildErr}`
`compiler.runAsChild callback error: ${runAsChildErr}`,
{ cause: runAsChildErr }
);
err.details = /** @type {Error} */ (runAsChildErr).stack;
/** @type {Compilation} */

View File

@ -18,9 +18,10 @@ class WebpackError extends Error {
/**
* Creates an instance of WebpackError.
* @param {string=} message error message
* @param {{ cause?: unknown }} options error options
*/
constructor(message) {
super(message);
constructor(message, options = {}) {
super(message, options);
/** @type {string=} */
this.details = undefined;
@ -37,7 +38,11 @@ class WebpackError extends Error {
}
[inspect]() {
return this.stack + (this.details ? `\n${this.details}` : "");
return (
this.stack +
(this.details ? `\n${this.details}` : "") +
(this.cause ? `\n${this.cause}` : "")
);
}
/**
@ -47,6 +52,7 @@ class WebpackError extends Error {
write(this.name);
write(this.message);
write(this.stack);
write(this.cause);
write(this.details);
write(this.loc);
write(this.hideStack);
@ -59,6 +65,7 @@ class WebpackError extends Error {
this.name = read();
this.message = read();
this.stack = read();
this.cause = read();
this.details = read();
this.loc = read();
this.hideStack = read();

View File

@ -22,6 +22,7 @@ const util = require("util");
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */
/** @typedef {import("../Entrypoint")} Entrypoint */
/** @typedef {import("../WebpackError")} WebpackError */
const handledDeprecatedNoEmitOnErrors = util.deprecate(
/**
@ -210,14 +211,19 @@ const getNormalizedWebpackOptions = config => ({
}
if (
i.module &&
(!warning.module ||
(!(/** @type {WebpackError} */ (warning).module) ||
!i.module.test(
warning.module.readableIdentifier(requestShortener)
/** @type {WebpackError} */
(warning).module.readableIdentifier(requestShortener)
))
) {
return false;
}
if (i.file && (!warning.file || !i.file.test(warning.file))) {
if (
i.file &&
(!(/** @type {WebpackError} */ (warning).file) ||
!i.file.test(/** @type {WebpackError} */ (warning).file))
) {
return false;
}
return true;

View File

@ -0,0 +1,39 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
*/
"use strict";
/** @typedef {import("./ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("./ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
class AggregateErrorSerializer {
/**
* @param {AggregateError} obj error
* @param {ObjectSerializerContext} context context
*/
serialize(obj, context) {
context.write(obj.errors);
context.write(obj.message);
context.write(obj.stack);
context.write(obj.cause);
}
/**
* @param {ObjectDeserializerContext} context context
* @returns {AggregateError} error
*/
deserialize(context) {
const errors = context.read();
// eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax
const err = new AggregateError(errors);
err.message = context.read();
err.stack = context.read();
err.cause = context.read();
return err;
}
}
module.exports = AggregateErrorSerializer;

View File

@ -22,7 +22,7 @@ class ErrorObjectSerializer {
serialize(obj, context) {
context.write(obj.message);
context.write(obj.stack);
context.write(/** @type {Error & { cause: "unknown" }} */ (obj).cause);
context.write(obj.cause);
}
/**
@ -34,8 +34,7 @@ class ErrorObjectSerializer {
err.message = context.read();
err.stack = context.read();
/** @type {Error & { cause: "unknown" }} */
(err).cause = context.read();
err.cause = context.read();
return err;
}

View File

@ -6,6 +6,7 @@
const { DEFAULTS } = require("../config/defaults");
const createHash = require("../util/createHash");
const AggregateErrorSerializer = require("./AggregateErrorSerializer");
const ArraySerializer = require("./ArraySerializer");
const DateObjectSerializer = require("./DateObjectSerializer");
const ErrorObjectSerializer = require("./ErrorObjectSerializer");
@ -140,6 +141,7 @@ const loadedRequests = new Set();
const NOT_SERIALIZABLE = {};
const jsTypes = new Map();
jsTypes.set(Object, new PlainObjectSerializer());
jsTypes.set(Array, new ArraySerializer());
jsTypes.set(null, new NullPrototypeObjectSerializer());
@ -154,6 +156,15 @@ jsTypes.set(ReferenceError, new ErrorObjectSerializer(ReferenceError));
jsTypes.set(SyntaxError, new ErrorObjectSerializer(SyntaxError));
jsTypes.set(TypeError, new ErrorObjectSerializer(TypeError));
// eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax
if (typeof AggregateError !== "undefined") {
jsTypes.set(
// eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax
AggregateError,
new AggregateErrorSerializer()
);
}
// If in a sandboxed environment (e.g. jest), this escapes the sandbox and registers
// real Object and Array types to. These types may occur in the wild too, e.g. when
// using Structured Clone in postMessage.

View File

@ -307,6 +307,8 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
* @property {StatsModuleTraceItem[]=} moduleTrace
* @property {string=} details
* @property {string=} stack
* @property {KnownStatsError=} cause
* @property {KnownStatsError[]=} errors
* @property {string=} compilerPath
*/
@ -336,6 +338,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
* @property {ExtractorsByOption<OriginRecord, StatsChunkOrigin>} chunkOrigin
* @property {ExtractorsByOption<WebpackError, StatsError>} error
* @property {ExtractorsByOption<WebpackError, StatsError>} warning
* @property {ExtractorsByOption<WebpackError, StatsError>} cause
* @property {ExtractorsByOption<ModuleTrace, StatsModuleTraceItem>} moduleTraceItem
* @property {ExtractorsByOption<Dependency, StatsModuleTraceDependency>} moduleTraceDependency
*/
@ -405,47 +408,63 @@ const countWithChildren = (compilation, getItems) => {
return count;
};
/** @type {ExtractorsByOption<WebpackError | string, StatsError>} */
/** @type {ExtractorsByOption<string | Error | AggregateError | WebpackError, StatsError>} */
const EXTRACT_ERROR = {
_: (object, error, context, { requestShortener }) => {
// TODO webpack 6 disallow strings in the errors/warnings list
if (typeof error === "string") {
object.message = error;
} else {
if (error.chunk) {
if (/** @type {WebpackError} */ (error).chunk) {
const chunk = /** @type {WebpackError} */ (error).chunk;
object.chunkName =
/** @type {string | undefined} */
(error.chunk.name);
object.chunkEntry = error.chunk.hasRuntime();
object.chunkInitial = error.chunk.canBeInitial();
(chunk.name);
object.chunkEntry = chunk.hasRuntime();
object.chunkInitial = chunk.canBeInitial();
}
if (error.file) {
object.file = error.file;
if (/** @type {WebpackError} */ (error).file) {
object.file = /** @type {WebpackError} */ (error).file;
}
if (error.module) {
object.moduleIdentifier = error.module.identifier();
object.moduleName = error.module.readableIdentifier(requestShortener);
if (/** @type {WebpackError} */ (error).module) {
object.moduleIdentifier =
/** @type {WebpackError} */
(error).module.identifier();
object.moduleName =
/** @type {WebpackError} */
(error).module.readableIdentifier(requestShortener);
}
if (error.loc) {
object.loc = formatLocation(error.loc);
if (/** @type {WebpackError} */ (error).loc) {
object.loc = formatLocation(/** @type {WebpackError} */ (error).loc);
}
object.message = error.message;
}
},
ids: (object, error, { compilation: { chunkGraph } }) => {
if (typeof error !== "string") {
if (error.chunk) {
object.chunkId = /** @type {ChunkId} */ (error.chunk.id);
if (/** @type {WebpackError} */ (error).chunk) {
object.chunkId = /** @type {ChunkId} */ (
/** @type {WebpackError} */
(error).chunk.id
);
}
if (error.module) {
if (/** @type {WebpackError} */ (error).module) {
object.moduleId =
/** @type {ModuleId} */
(chunkGraph.getModuleId(error.module));
(chunkGraph.getModuleId(/** @type {WebpackError} */ (error).module));
}
}
},
moduleTrace: (object, error, context, options, factory) => {
if (typeof error !== "string" && error.module) {
if (
typeof error !== "string" &&
/** @type {WebpackError} */ (error).module
) {
const {
type,
compilation: { moduleGraph }
@ -454,7 +473,7 @@ const EXTRACT_ERROR = {
const visitedModules = new Set();
/** @type {ModuleTrace[]} */
const moduleTrace = [];
let current = error.module;
let current = /** @type {WebpackError} */ (error).module;
while (current) {
if (visitedModules.has(current)) break; // circular (technically impossible, but how knows)
visitedModules.add(current);
@ -481,13 +500,41 @@ const EXTRACT_ERROR = {
(errorDetails === true ||
(type.endsWith(".error") && cachedGetErrors(compilation).length < 3))
) {
object.details = error.details;
object.details = /** @type {WebpackError} */ (error).details;
}
},
errorStack: (object, error) => {
if (typeof error !== "string") {
object.stack = error.stack;
}
},
errorCause: (object, error, context, options, factory) => {
if (typeof error !== "string" && error.cause) {
/** @type {Error} */
const cause =
typeof error.cause === "string"
? /** @type {Error} */ ({ message: error.cause })
: /** @type {Error} */ (error.cause);
const { type } = context;
object.cause = factory.create(`${type}.cause`, cause, context);
}
},
errorErrors: (object, error, context, options, factory) => {
if (
typeof error !== "string" &&
/** @type {AggregateError} */
(error).errors
) {
const { type } = context;
object.errors = factory.create(
`${type}.errors`,
/** @type {Error[]} */
(/** @type {AggregateError} */ (error).errors),
context
);
}
}
};
@ -1560,6 +1607,7 @@ const SIMPLE_EXTRACTORS = {
},
error: EXTRACT_ERROR,
warning: EXTRACT_ERROR,
cause: EXTRACT_ERROR,
moduleTraceItem: {
_: (object, { origin, module }, context, { requestShortener }, factory) => {
const {
@ -2474,6 +2522,8 @@ const ITEM_NAMES = {
"compilation.namedChunkGroups[]": "chunkGroup",
"compilation.errors[]": "error",
"compilation.warnings[]": "warning",
"error.errors[]": "error",
"warning.errors[]": "error",
"chunk.modules[]": "module",
"chunk.rootModules[]": "module",
"chunk.origins[]": "chunkOrigin",

View File

@ -55,6 +55,8 @@ const NAMED_PRESETS = {
optimizationBailout: true,
errorDetails: true,
errorStack: true,
errorCause: true,
errorErrors: true,
publicPath: true,
logging: "verbose",
orphanModules: true,
@ -84,6 +86,8 @@ const NAMED_PRESETS = {
providedExports: true,
optimizationBailout: true,
errorDetails: true,
errorCause: true,
errorErrors: true,
publicPath: true,
logging: true,
runtimeModules: true,
@ -260,6 +264,8 @@ const DEFAULTS = {
errorsCount: NORMAL_ON,
errorDetails: AUTO_FOR_TO_STRING,
errorStack: OFF_FOR_TO_STRING,
errorCause: AUTO_FOR_TO_STRING,
errorErrors: AUTO_FOR_TO_STRING,
warnings: NORMAL_ON,
warningsCount: NORMAL_ON,
publicPath: OFF_FOR_TO_STRING,

View File

@ -819,6 +819,16 @@ const ERROR_PRINTERS = {
"error.filteredDetails": filteredDetails =>
filteredDetails ? `+ ${filteredDetails} hidden lines` : undefined,
"error.stack": stack => stack,
"error.cause": (cause, context, printer) =>
cause
? indent(
`[cause]: ${
/** @type {string} */
(printer.print(`${context.type}.error`, cause, context))
}`,
" "
)
: undefined,
"error.moduleTrace": moduleTrace => undefined,
"error.separator!": () => "\n"
};
@ -925,6 +935,7 @@ const ITEM_NAMES = {
"loggingEntry.children[]": logEntry =>
`loggingEntry(${logEntry.type}).loggingEntry`,
"error.moduleTrace[]": "moduleTraceItem",
"error.errors[]": "error",
"moduleTraceItem.dependencies[]": "moduleTraceDependency"
};
@ -946,6 +957,8 @@ const ERROR_PREFERRED_ORDER = [
"separator!",
"stack",
"separator!",
"cause",
"separator!",
"missing",
"separator!",
"moduleTrace"
@ -1388,28 +1401,6 @@ const SIMPLE_ELEMENT_JOINERS = {
chunkGroupAsset: joinOneLine,
chunkGroupChildGroup: joinOneLine,
chunkGroupChild: joinOneLine,
// moduleReason: (items, { moduleReason }) => {
// let hasName = false;
// return joinOneLine(
// items.filter(item => {
// switch (item.element) {
// case "moduleId":
// if (moduleReason.moduleId === moduleReason.module && item.content)
// hasName = true;
// break;
// case "module":
// if (hasName) return false;
// break;
// case "resolvedModule":
// return (
// moduleReason.module !== moduleReason.resolvedModule &&
// item.content
// );
// }
// return true;
// })
// );
// },
moduleReason: (items, { moduleReason }) => {
let hasName = false;
return joinExplicitNewLine(
@ -1445,6 +1436,9 @@ const SIMPLE_ELEMENT_JOINERS = {
chunkOrigin: items => `> ${joinOneLine(items)}`,
"errors[].error": joinError(true),
"warnings[].error": joinError(false),
error: items => joinExplicitNewLine(items, ""),
"error.errors[].error": items =>
indent(`[errors]: ${joinExplicitNewLine(items, "")}`, " "),
loggingGroup: items => joinExplicitNewLine(items, "").trimEnd(),
moduleTraceItem: items => ` @ ${joinOneLine(items)}`,
moduleTraceDependency: joinOneLine

File diff suppressed because one or more lines are too long

View File

@ -1733,7 +1733,7 @@
{
"description": "A custom function to select warnings based on the raw warning instance.",
"instanceof": "Function",
"tsType": "((warning: import('../lib/WebpackError'), compilation: import('../lib/Compilation')) => boolean)"
"tsType": "((warning: Error, compilation: import('../lib/Compilation')) => boolean)"
}
]
}
@ -1744,7 +1744,7 @@
"items": {
"description": "A function to select warnings based on the raw warning instance.",
"instanceof": "Function",
"tsType": "((warning: import('../lib/WebpackError'), compilation: import('../lib/Compilation')) => boolean)"
"tsType": "((warning: Error, compilation: import('../lib/Compilation')) => boolean)"
}
},
"Iife": {
@ -5048,6 +5048,17 @@
"description": "Add --env information.",
"type": "boolean"
},
"errorCause": {
"description": "Add cause to errors.",
"anyOf": [
{
"enum": ["auto"]
},
{
"type": "boolean"
}
]
},
"errorDetails": {
"description": "Add details to errors (like resolving log).",
"anyOf": [
@ -5059,6 +5070,17 @@
}
]
},
"errorErrors": {
"description": "Add nested errors to errors (like in AggregateError).",
"anyOf": [
{
"enum": ["auto"]
},
{
"type": "boolean"
}
]
},
"errorStack": {
"description": "Add internal stack trace to errors.",
"type": "boolean"

View File

@ -45,6 +45,7 @@ describe("Compiler (filesystem caching)", () => {
const isErrorCaseSupported =
typeof new Error("test", { cause: new Error("cause") }).cause !==
"undefined";
const isAggregateErrorSupported = typeof AggregateError !== "undefined";
options.plugins = [
{
@ -78,6 +79,17 @@ describe("Compiler (filesystem caching)", () => {
expect(result.error1.cause.number).toBe(42);
}
if (isAggregateErrorSupported) {
expect(result.aggregateError.errors).toEqual([
new Error("first", { cause: "nested cause" }),
"second"
]);
expect(result.aggregateError.message).toEqual(
"aggregate error"
);
expect(result.aggregateError.cause.message).toBe("cause");
}
if (isBigIntSupported) {
expect(result.bigint).toEqual(5n);
expect(result.bigint1).toEqual(124n);
@ -114,6 +126,14 @@ describe("Compiler (filesystem caching)", () => {
});
}
if (isAggregateErrorSupported) {
storeValue.aggregateError = new AggregateError(
[new Error("first", { cause: "nested cause" }), "second"],
"aggregate error",
{ cause: new Error("cause") }
);
}
if (isBigIntSupported) {
storeValue.bigint = BigInt(5);
storeValue.bigint1 = BigInt(124);

View File

@ -498,6 +498,69 @@ all:
all (webpack x.x.x) compiled successfully"
`;
exports[`StatsTestCases should print correct stats for cause-error 1`] = `
"asset main.js X KiB [emitted] (name: main)
./index.js X bytes [built] [code generated]
WARNING in aggregate error
[cause]: cause
cause
cause
[cause]: nested string cause
[errors]: first error
[cause]: cause
[cause]: nested cause in errors
[errors]: second string error
[errors]: third nested aggregate error
[errors]: nested first
[errors]: nested second
WARNING in error with case
[cause]: error case
WARNING in error with nested error case
[cause]: test
[cause]: nested case
WARNING in error with string case
[cause]: string case
WARNING in webpack error with case
[cause]: cause
WARNING in webpack error
ERROR in aggregate error
[cause]: cause
cause
cause
[cause]: nested string cause
[errors]: first error
[cause]: cause
[cause]: nested cause in errors
[errors]: second string error
[errors]: third nested aggregate error
[errors]: nested first
[errors]: nested second
ERROR in error with case
[cause]: error case
ERROR in error with nested error case
[cause]: test
[cause]: nested case
ERROR in error with string case
[cause]: string case
ERROR in webpack error with case
[cause]: cause
ERROR in webpack error
error cause (webpack x.x.x) compiled with 6 errors and 6 warnings in X ms"
`;
exports[`StatsTestCases should print correct stats for child-compiler-apply-entry-option 1`] = `
"asset child.js X bytes [emitted]
asset parent.js X bytes [emitted] (name: parent)

View File

View File

@ -0,0 +1,59 @@
const WebpackError = require("../../../lib/WebpackError");
/** @type {import("../../../").Configuration} */
module.exports = {
name: `error cause`,
mode: "development",
entry: "./index.js",
plugins: [
compiler => {
compiler.hooks.compilation.tap("Test", compilation => {
const errCauseErr = new Error("error with case", {
cause: new Error("error case")
});
compilation.errors.push(errCauseErr);
compilation.warnings.push(errCauseErr);
const errCauseErrCauseErr = new Error("error with nested error case", {
cause: new Error("test", { cause: new Error("nested case") })
});
compilation.errors.push(errCauseErrCauseErr);
compilation.warnings.push(errCauseErrCauseErr);
const errCauseStr = new Error("error with string case", {
cause: "string case"
});
compilation.errors.push(errCauseStr);
compilation.warnings.push(errCauseStr);
const aggregateError = new AggregateError(
[
new Error("first error", {
cause: new Error("cause", {
cause: new Error("nested cause in errors")
})
}),
"second string error",
new AggregateError(
[new Error("nested first"), new Error("nested second")],
"third nested aggregate error"
)
],
"aggregate error",
{
cause: new Error("cause\ncause\ncause", {
cause: "nested string cause"
})
}
);
compilation.errors.push(aggregateError);
compilation.warnings.push(aggregateError);
const webpackError = new WebpackError("webpack error");
compilation.errors.push(webpackError);
compilation.warnings.push(webpackError);
const webpackErrorCause = new WebpackError("webpack error with case", {
cause: new Error("cause")
});
compilation.errors.push(webpackErrorCause);
compilation.warnings.push(webpackErrorCause);
});
}
]
};

View File

@ -2,7 +2,7 @@
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"lib": ["es2017", "dom"],
"lib": ["es2017", "dom", "es2022.error"],
"allowJs": true,
"checkJs": true,
"noEmit": true,

34
types.d.ts vendored
View File

@ -1962,8 +1962,8 @@ declare class Compilation {
needAdditionalPass: SyncBailHook<[], boolean | void>;
childCompiler: SyncHook<[Compiler, string, number]>;
log: SyncBailHook<[string, LogEntry], boolean | void>;
processWarnings: SyncWaterfallHook<[WebpackError[]]>;
processErrors: SyncWaterfallHook<[WebpackError[]]>;
processWarnings: SyncWaterfallHook<[Error[]]>;
processErrors: SyncWaterfallHook<[Error[]]>;
statsPreset: HookMap<
SyncHook<[Partial<NormalizedStatsOptions>, CreateStatsOptionsContext]>
>;
@ -2030,8 +2030,8 @@ declare class Compilation {
additionalChunkAssets: string[];
assets: CompilationAssets;
assetsInfo: Map<string, AssetInfo>;
errors: WebpackError[];
warnings: WebpackError[];
errors: Error[];
warnings: Error[];
children: Compilation[];
logging: Map<string, LogEntry[]>;
dependencyFactories: Map<DepConstructor, ModuleFactory>;
@ -2230,8 +2230,8 @@ declare class Compilation {
filename: TemplatePath,
data: PathData
): InterpolatedPathAndAssetInfo;
getWarnings(): WebpackError[];
getErrors(): WebpackError[];
getWarnings(): Error[];
getErrors(): Error[];
/**
* This function allows you to run another instance of webpack inside of webpack however as
@ -2705,7 +2705,7 @@ declare interface Configuration {
*/
module?: RegExp;
}
| ((warning: WebpackError, compilation: Compilation) => boolean)
| ((warning: Error, compilation: Compilation) => boolean)
)[];
/**
@ -7903,6 +7903,8 @@ declare interface KnownStatsError {
moduleTrace?: StatsModuleTraceItem[];
details?: string;
stack?: string;
cause?: KnownStatsError;
errors?: KnownStatsError[];
compilerPath?: string;
}
declare interface KnownStatsFactoryContext {
@ -15096,11 +15098,21 @@ declare interface StatsOptions {
*/
env?: boolean;
/**
* Add cause to errors.
*/
errorCause?: boolean | "auto";
/**
* Add details to errors (like resolving log).
*/
errorDetails?: boolean | "auto";
/**
* Add nested errors to errors (like in AggregateError).
*/
errorErrors?: boolean | "auto";
/**
* Add internal stack trace to errors.
*/
@ -15778,7 +15790,7 @@ declare class WebpackError extends Error {
/**
* Creates an instance of WebpackError.
*/
constructor(message?: string);
constructor(message?: string, options?: { cause?: unknown });
[index: number]: () => string;
details?: string;
module?: null | Module;
@ -15788,6 +15800,7 @@ declare class WebpackError extends Error {
file?: string;
serialize(__0: ObjectSerializerContext): void;
deserialize(__0: ObjectDeserializerContext): void;
cause: any;
/**
* Create .stack property on a target object
@ -15925,10 +15938,7 @@ declare interface WebpackOptionsNormalized {
/**
* Ignore specific warnings.
*/
ignoreWarnings?: ((
warning: WebpackError,
compilation: Compilation
) => boolean)[];
ignoreWarnings?: ((warning: Error, compilation: Compilation) => boolean)[];
/**
* Options for infrastructure level logging.