fix: types for multi compiler
Github Actions / lint (push) Waiting to run Details
Github Actions / validate-legacy-node (push) Waiting to run Details
Github Actions / benchmark (1/4) (push) Waiting to run Details
Github Actions / benchmark (2/4) (push) Waiting to run Details
Github Actions / benchmark (3/4) (push) Waiting to run Details
Github Actions / benchmark (4/4) (push) Waiting to run Details
Github Actions / basic (push) Waiting to run Details
Github Actions / unit (push) Waiting to run Details
Github Actions / integration (10.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (10.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (20.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Blocked by required conditions Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Blocked by required conditions Details

This commit is contained in:
Alexander Akait 2025-07-18 15:28:16 +03:00 committed by GitHub
parent c1f2249eea
commit f07eba4bc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 435 additions and 77 deletions

View File

@ -4,7 +4,8 @@ module.exports = {
nameMapping: { nameMapping: {
FsStats: /^Stats Import fs/, FsStats: /^Stats Import fs/,
validateFunction: /^validate Import/, validateFunction: /^validate Import/,
Configuration: /^WebpackOptions / Configuration: /^WebpackOptions /,
MultiConfiguration: /^MultiWebpackOptions /
}, },
exclude: [/^devServer in WebpackOptions /], exclude: [/^devServer in WebpackOptions /],
include: [/^(_module|_compilation|_compiler) in NormalModuleLoaderContext /] include: [/^(_module|_compilation|_compiler) in NormalModuleLoaderContext /]

View File

@ -16,6 +16,7 @@ const ArrayQueue = require("./util/ArrayQueue");
/** @template T @typedef {import("tapable").AsyncSeriesHook<T>} AsyncSeriesHook<T> */ /** @template T @typedef {import("tapable").AsyncSeriesHook<T>} AsyncSeriesHook<T> */
/** @template T @template R @typedef {import("tapable").SyncBailHook<T, R>} SyncBailHook<T, R> */ /** @template T @template R @typedef {import("tapable").SyncBailHook<T, R>} SyncBailHook<T, R> */
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
/** @typedef {import("../declarations/WebpackOptions").WatchOptions} WatchOptions */ /** @typedef {import("../declarations/WebpackOptions").WatchOptions} WatchOptions */
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Stats")} Stats */ /** @typedef {import("./Stats")} Stats */
@ -44,6 +45,8 @@ const ArrayQueue = require("./util/ArrayQueue");
* @property {number=} parallelism how many Compilers are allows to run at the same time in parallel * @property {number=} parallelism how many Compilers are allows to run at the same time in parallel
*/ */
/** @typedef {ReadonlyArray<WebpackOptions> & MultiCompilerOptions} MultiWebpackOptions */
const CLASS_NAME = "MultiCompiler"; const CLASS_NAME = "MultiCompiler";
module.exports = class MultiCompiler { module.exports = class MultiCompiler {

View File

@ -25,6 +25,8 @@ const indent = (str, prefix) => {
return prefix + rem; return prefix + rem;
}; };
/** @typedef {undefined | string | boolean | StatsOptions} ChildrenStatsOptions */
/** @typedef {Omit<StatsOptions, "children"> & { children?: ChildrenStatsOptions | ChildrenStatsOptions[] }} MultiStatsOptions */
/** @typedef {{ version: boolean, hash: boolean, errorsCount: boolean, warningsCount: boolean, errors: boolean, warnings: boolean, children: NormalizedStatsOptions[] }} ChildOptions */ /** @typedef {{ version: boolean, hash: boolean, errorsCount: boolean, warningsCount: boolean, errors: boolean, warnings: boolean, children: NormalizedStatsOptions[] }} ChildOptions */
class MultiStats { class MultiStats {
@ -54,7 +56,7 @@ class MultiStats {
} }
/** /**
* @param {string | boolean | StatsOptions | undefined} options stats options * @param {undefined | string | boolean | MultiStatsOptions} options stats options
* @param {CreateStatsOptionsContext} context context * @param {CreateStatsOptionsContext} context context
* @returns {ChildOptions} context context * @returns {ChildOptions} context context
*/ */
@ -80,6 +82,9 @@ class MultiStats {
const childOptions = Array.isArray(childrenOptions) const childOptions = Array.isArray(childrenOptions)
? childrenOptions[idx] ? childrenOptions[idx]
: childrenOptions; : childrenOptions;
if (typeof childOptions === "boolean") {
return stat.compilation.createStatsOptions(childOptions, context);
}
return stat.compilation.createStatsOptions( return stat.compilation.createStatsOptions(
{ {
...baseOptions, ...baseOptions,
@ -104,7 +109,7 @@ class MultiStats {
} }
/** /**
* @param {(string | boolean | StatsOptions)=} options stats options * @param {(string | boolean | MultiStatsOptions)=} options stats options
* @returns {StatsCompilation} json output * @returns {StatsCompilation} json output
*/ */
toJson(options) { toJson(options) {
@ -179,7 +184,7 @@ class MultiStats {
} }
/** /**
* @param {(string | boolean | StatsOptions)=} options stats options * @param {(string | boolean | MultiStatsOptions)=} options stats options
* @returns {string} string output * @returns {string} string output
*/ */
toString(options) { toString(options) {

View File

@ -840,7 +840,12 @@ const init = (open, close, replace) =>
}} Colors */ }} Colors */
/** /**
* @param {{ useColor?: boolean }=} options options * @typedef {object} ColorsOptions
* @property {boolean=} useColor force use colors
*/
/**
* @param {ColorsOptions=} options options
* @returns {Colors} colors * @returns {Colors} colors
*/ */
const createColors = ({ useColor = isColorSupported() } = {}) => ({ const createColors = ({ useColor = isColorSupported() } = {}) => ({

View File

@ -49,7 +49,9 @@ const memoize = require("./util/memoize");
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */ /** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
/** @typedef {import("./Entrypoint")} Entrypoint */ /** @typedef {import("./Entrypoint")} Entrypoint */
/** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */ /** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
/** @typedef {import("./MultiCompiler").MultiWebpackOptions} MultiConfiguration */
/** @typedef {import("./MultiStats")} MultiStats */ /** @typedef {import("./MultiStats")} MultiStats */
/** @typedef {import("./MultiStats").MultiStatsOptions} MultiStatsOptions */
/** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */ /** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
/** @typedef {import("./Parser").ParserState} ParserState */ /** @typedef {import("./Parser").ParserState} ParserState */
/** @typedef {import("./ResolverFactory").ResolvePluginInstance} ResolvePluginInstance */ /** @typedef {import("./ResolverFactory").ResolvePluginInstance} ResolvePluginInstance */
@ -57,6 +59,8 @@ const memoize = require("./util/memoize");
/** @typedef {import("./Watching")} Watching */ /** @typedef {import("./Watching")} Watching */
/** @typedef {import("./cli").Argument} Argument */ /** @typedef {import("./cli").Argument} Argument */
/** @typedef {import("./cli").Problem} Problem */ /** @typedef {import("./cli").Problem} Problem */
/** @typedef {import("./cli").Colors} Colors */
/** @typedef {import("./cli").ColorsOptions} ColorsOptions */
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */ /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunk} StatsChunk */ /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunk} StatsChunk */
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunkGroup} StatsChunkGroup */ /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunkGroup} StatsChunkGroup */
@ -132,16 +136,16 @@ module.exports = mergeExports(fn, {
return require("./webpack"); return require("./webpack");
}, },
/** /**
* @returns {(configuration: Configuration | Configuration[]) => void} validate fn * @returns {(configuration: Configuration | MultiConfiguration) => void} validate fn
*/ */
get validate() { get validate() {
const webpackOptionsSchemaCheck = const webpackOptionsSchemaCheck =
/** @type {(configuration: Configuration | Configuration[]) => boolean} */ /** @type {(configuration: Configuration | MultiConfiguration) => boolean} */
(require("../schemas/WebpackOptions.check")); (require("../schemas/WebpackOptions.check"));
const getRealValidate = memoize( const getRealValidate = memoize(
/** /**
* @returns {(configuration: Configuration | Configuration[]) => void} validate fn * @returns {(configuration: Configuration | MultiConfiguration) => void} validate fn
*/ */
() => { () => {
const validateSchema = require("./validateSchema"); const validateSchema = require("./validateSchema");

View File

@ -144,31 +144,31 @@ const NAMED_PRESETS = {
}; };
/** /**
* @param {Partial<NormalizedStatsOptions>} all stats option * @param {Partial<NormalizedStatsOptions>} all stats options
* @returns {boolean} true when enabled, otherwise false * @returns {boolean} true when enabled, otherwise false
*/ */
const NORMAL_ON = ({ all }) => all !== false; const NORMAL_ON = ({ all }) => all !== false;
/** /**
* @param {Partial<NormalizedStatsOptions>} all stats option * @param {Partial<NormalizedStatsOptions>} all stats options
* @returns {boolean} true when enabled, otherwise false * @returns {boolean} true when enabled, otherwise false
*/ */
const NORMAL_OFF = ({ all }) => all === true; const NORMAL_OFF = ({ all }) => all === true;
/** /**
* @param {Partial<NormalizedStatsOptions>} all stats option * @param {Partial<NormalizedStatsOptions>} all stats options
* @param {CreateStatsOptionsContext} forToString stats options context * @param {CreateStatsOptionsContext} forToString stats options context
* @returns {boolean} true when enabled, otherwise false * @returns {boolean} true when enabled, otherwise false
*/ */
const ON_FOR_TO_STRING = ({ all }, { forToString }) => const ON_FOR_TO_STRING = ({ all }, { forToString }) =>
forToString ? all !== false : all === true; forToString ? all !== false : all === true;
/** /**
* @param {Partial<NormalizedStatsOptions>} all stats option * @param {Partial<NormalizedStatsOptions>} all stats options
* @param {CreateStatsOptionsContext} forToString stats options context * @param {CreateStatsOptionsContext} forToString stats options context
* @returns {boolean} true when enabled, otherwise false * @returns {boolean} true when enabled, otherwise false
*/ */
const OFF_FOR_TO_STRING = ({ all }, { forToString }) => const OFF_FOR_TO_STRING = ({ all }, { forToString }) =>
forToString ? all === true : all !== false; forToString ? all === true : all !== false;
/** /**
* @param {Partial<NormalizedStatsOptions>} all stats option * @param {Partial<NormalizedStatsOptions>} all stats options
* @param {CreateStatsOptionsContext} forToString stats options context * @param {CreateStatsOptionsContext} forToString stats options context
* @returns {boolean | "auto"} true when enabled, otherwise false * @returns {boolean | "auto"} true when enabled, otherwise false
*/ */

View File

@ -23,6 +23,7 @@ const memoize = require("./util/memoize");
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */ /** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
/** @typedef {import("./Compiler").WatchOptions} WatchOptions */ /** @typedef {import("./Compiler").WatchOptions} WatchOptions */
/** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */ /** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
/** @typedef {import("./MultiCompiler").MultiWebpackOptions} MultiWebpackOptions */
/** @typedef {import("./MultiStats")} MultiStats */ /** @typedef {import("./MultiStats")} MultiStats */
/** @typedef {import("./Stats")} Stats */ /** @typedef {import("./Stats")} Stats */
@ -100,14 +101,14 @@ const createCompiler = (rawOptions, compilerIndex) => {
* @callback WebpackFunctionSingle * @callback WebpackFunctionSingle
* @param {WebpackOptions} options options object * @param {WebpackOptions} options options object
* @param {Callback<Stats>=} callback callback * @param {Callback<Stats>=} callback callback
* @returns {Compiler} the compiler object * @returns {Compiler | null} the compiler object
*/ */
/** /**
* @callback WebpackFunctionMulti * @callback WebpackFunctionMulti
* @param {ReadonlyArray<WebpackOptions> & MultiCompilerOptions} options options objects * @param {MultiWebpackOptions} options options objects
* @param {Callback<MultiStats>=} callback callback * @param {Callback<MultiStats>=} callback callback
* @returns {MultiCompiler} the multi compiler object * @returns {MultiCompiler | null} the multi compiler object
*/ */
/** /**
@ -118,12 +119,15 @@ const createCompiler = (rawOptions, compilerIndex) => {
const asArray = (options) => const asArray = (options) =>
Array.isArray(options) ? [...options] : [options]; Array.isArray(options) ? [...options] : [options];
const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
/** /**
* @param {WebpackOptions | (ReadonlyArray<WebpackOptions> & MultiCompilerOptions)} options options * @callback WebpackCallback
* @param {WebpackOptions | MultiWebpackOptions} options options
* @param {Callback<Stats> & Callback<MultiStats>=} callback callback * @param {Callback<Stats> & Callback<MultiStats>=} callback callback
* @returns {Compiler | MultiCompiler | null} Compiler or MultiCompiler * @returns {Compiler | MultiCompiler | null} Compiler or MultiCompiler
*/ */
const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
/** @type {WebpackCallback} */
(options, callback) => { (options, callback) => {
const create = () => { const create = () => {
if (!asArray(options).every(webpackOptionsSchemaCheck)) { if (!asArray(options).every(webpackOptionsSchemaCheck)) {

View File

@ -4,11 +4,24 @@ require("./helpers/warmup-webpack");
const { Volume, createFsFromVolume } = require("memfs"); const { Volume, createFsFromVolume } = require("memfs");
describe("MultiStats", () => { const compile = (options) =>
it("should create JSON of children stats", (done) => { new Promise((resolve, reject) => {
const webpack = require(".."); const webpack = require("..");
const compiler = webpack([ const compiler = webpack(options);
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
if (err) {
reject(err);
} else {
resolve(stats);
}
});
});
describe("MultiStats", () => {
it("should create JSON of children stats", async () => {
const stats = await compile([
{ {
context: __dirname, context: __dirname,
entry: "./fixtures/a" entry: "./fixtures/a"
@ -18,19 +31,278 @@ describe("MultiStats", () => {
entry: "./fixtures/b" entry: "./fixtures/b"
} }
]); ]);
compiler.outputFileSystem = createFsFromVolume(new Volume());
compiler.run((err, stats) => {
if (err) return done(err);
try {
const statsObject = stats.toJson(); const statsObject = stats.toJson();
expect(statsObject).toEqual( expect(statsObject).toEqual(
expect.objectContaining({ children: expect.any(Array) }) expect.objectContaining({ children: expect.any(Array) })
); );
expect(statsObject.children).toHaveLength(2); expect(statsObject.children).toHaveLength(2);
done(); });
} catch (err) {
done(err); it("should work with a boolean value", async () => {
const stats = await compile([
{
context: __dirname,
entry: "./fixtures/a"
},
{
context: __dirname,
entry: "./fixtures/b"
} }
}); ]);
expect(stats.toJson(false)).toMatchInlineSnapshot(`
Object {
"children": Array [
Object {
"name": undefined,
},
Object {
"name": undefined,
},
],
}
`);
expect(stats.toString(false)).toMatchInlineSnapshot('""');
});
it("should work with a string value", async () => {
const stats = await compile([
{
context: __dirname,
entry: "./fixtures/a"
},
{
context: __dirname,
entry: "./fixtures/b"
}
]);
expect(stats.toJson("none")).toMatchInlineSnapshot(`
Object {
"children": Array [
Object {
"name": undefined,
},
Object {
"name": undefined,
},
],
}
`);
expect(stats.toString("none")).toMatchInlineSnapshot('""');
});
it("should work with an object value", async () => {
const stats = await compile([
{
context: __dirname,
entry: "./fixtures/a"
},
{
context: __dirname,
entry: "./fixtures/b"
}
]);
expect(
stats.toJson({
all: false,
version: false,
errorsCount: true,
warningsCount: true
})
).toMatchInlineSnapshot(`
Object {
"children": Array [
Object {
"errorsCount": 0,
"name": undefined,
"warningsCount": 1,
},
Object {
"errorsCount": 0,
"name": undefined,
"warningsCount": 1,
},
],
"errorsCount": 0,
"warningsCount": 2,
}
`);
expect(
stats.toString({
all: false,
version: false,
errorsCount: true,
warningsCount: true
})
).toMatchInlineSnapshot(`
"webpack compiled with 1 warning
webpack compiled with 1 warning"
`);
});
it("should work with a boolean value for each children", async () => {
const stats = await compile([
{
context: __dirname,
entry: "./fixtures/a"
},
{
context: __dirname,
entry: "./fixtures/b"
}
]);
const statsOptions = {
children: [false, false]
};
expect(stats.toJson(statsOptions)).toMatchInlineSnapshot(`
Object {
"children": Array [
Object {
"name": undefined,
},
Object {
"name": undefined,
},
],
}
`);
expect(stats.toString(statsOptions)).toMatchInlineSnapshot('""');
});
it("should work with a string value for each children", async () => {
const stats = await compile([
{
context: __dirname,
entry: "./fixtures/a"
},
{
context: __dirname,
entry: "./fixtures/b"
}
]);
const statsOptions = {
children: ["none", "none"]
};
expect(stats.toJson(statsOptions)).toMatchInlineSnapshot(`
Object {
"children": Array [
Object {
"name": undefined,
},
Object {
"name": undefined,
},
],
}
`);
expect(stats.toString(statsOptions)).toMatchInlineSnapshot('""');
});
it("should work with an object value for each children", async () => {
const stats = await compile([
{
context: __dirname,
entry: "./fixtures/a"
},
{
context: __dirname,
entry: "./fixtures/b"
}
]);
const statsOptions = {
children: [
{
all: false,
publicPath: true,
version: false,
errorsCount: true,
warningsCount: true
},
{
all: false,
version: false,
errorsCount: true,
warningsCount: true
}
]
};
expect(stats.toJson(statsOptions)).toMatchInlineSnapshot(`
Object {
"children": Array [
Object {
"errorsCount": 0,
"name": undefined,
"publicPath": "auto",
"warningsCount": 1,
},
Object {
"errorsCount": 0,
"name": undefined,
"warningsCount": 1,
},
],
"errorsCount": 0,
"warningsCount": 2,
}
`);
expect(stats.toString(statsOptions)).toMatchInlineSnapshot(`
"PublicPath: auto
webpack compiled with 1 warning
webpack compiled with 1 warning"
`);
});
it("should work with an mixed values for each children", async () => {
const stats = await compile([
{
context: __dirname,
entry: "./fixtures/a"
},
{
context: __dirname,
entry: "./fixtures/b"
}
]);
const statsOptions = {
children: [
false,
{
all: false,
version: false,
errorsCount: true,
warningsCount: true
}
]
};
expect(stats.toJson(statsOptions)).toMatchInlineSnapshot(`
Object {
"children": Array [
Object {
"name": undefined,
},
Object {
"errorsCount": 0,
"name": undefined,
"warningsCount": 1,
},
],
}
`);
expect(stats.toString(statsOptions)).toMatchInlineSnapshot(
'"webpack compiled with 1 warning"'
);
}); });
}); });

View File

@ -20,6 +20,52 @@ const compile = (options) =>
}); });
describe("Stats", () => { describe("Stats", () => {
it("should work with a boolean value", async () => {
const stats = await compile({
context: __dirname,
entry: "./fixtures/a"
});
expect(stats.toJson(false)).toMatchInlineSnapshot("Object {}");
expect(stats.toString(false)).toMatchInlineSnapshot('""');
});
it("should work with a string value", async () => {
const stats = await compile({
context: __dirname,
entry: "./fixtures/a"
});
expect(stats.toJson("none")).toMatchInlineSnapshot("Object {}");
expect(stats.toString("none")).toMatchInlineSnapshot('""');
});
it("should work with an object value", async () => {
const stats = await compile({
context: __dirname,
entry: "./fixtures/a"
});
expect(
stats.toJson({
all: false,
version: false,
errorsCount: true,
warningsCount: true
})
).toMatchInlineSnapshot(`
Object {
"errorsCount": 0,
"warningsCount": 1,
}
`);
expect(
stats.toString({
all: false,
version: false,
errorsCount: true,
warningsCount: true
})
).toMatchInlineSnapshot('"webpack compiled with 1 warning"');
});
it("should print env string in stats", async () => { it("should print env string in stats", async () => {
const stats = await compile({ const stats = await compile({
context: __dirname, context: __dirname,

96
types.d.ts vendored
View File

@ -1180,6 +1180,7 @@ declare interface CallbackWebpack<T> {
(err: null | Error, stats?: T): void; (err: null | Error, stats?: T): void;
} }
type Cell<T> = undefined | T; type Cell<T> = undefined | T;
type ChildrenStatsOptions = undefined | string | boolean | StatsOptions;
declare class Chunk { declare class Chunk {
constructor(name?: null | string, backCompat?: boolean); constructor(name?: null | string, backCompat?: boolean);
id: null | string | number; id: null | string | number;
@ -1994,6 +1995,12 @@ declare interface Colors {
bgCyanBright: (value?: any) => string; bgCyanBright: (value?: any) => string;
bgWhiteBright: (value?: any) => string; bgWhiteBright: (value?: any) => string;
} }
declare interface ColorsOptions {
/**
* force use colors
*/
useColor?: boolean;
}
declare interface Comparator<T> { declare interface Comparator<T> {
(a: T, b: T): 0 | 1 | -1; (a: T, b: T): 0 | 1 | -1;
} }
@ -10460,14 +10467,18 @@ declare interface MultiCompilerOptions {
*/ */
parallelism?: number; parallelism?: number;
} }
type MultiConfiguration = ReadonlyArray<Configuration> & MultiCompilerOptions;
declare abstract class MultiStats { declare abstract class MultiStats {
stats: Stats[]; stats: Stats[];
get hash(): string; get hash(): string;
hasErrors(): boolean; hasErrors(): boolean;
hasWarnings(): boolean; hasWarnings(): boolean;
toJson(options?: string | boolean | StatsOptions): StatsCompilation; toJson(options?: string | boolean | MultiStatsOptions): StatsCompilation;
toString(options?: string | boolean | StatsOptions): string; toString(options?: string | boolean | MultiStatsOptions): string;
} }
type MultiStatsOptions = Omit<StatsOptions, "children"> & {
children?: string | boolean | StatsOptions | ChildrenStatsOptions[];
};
declare abstract class MultiWatching { declare abstract class MultiWatching {
watchings: Watching[]; watchings: Watching[];
compiler: MultiCompiler; compiler: MultiCompiler;
@ -10920,43 +10931,43 @@ declare class NormalModuleReplacementPlugin {
type NormalizedStatsOptions = KnownNormalizedStatsOptions & type NormalizedStatsOptions = KnownNormalizedStatsOptions &
Omit< Omit<
StatsOptions, StatsOptions,
| "context"
| "chunkGroups"
| "requestShortener"
| "chunksSort"
| "modulesSort"
| "chunkModulesSort"
| "nestedModulesSort"
| "assetsSort" | "assetsSort"
| "ids"
| "cachedAssets"
| "groupAssetsByEmitStatus"
| "groupAssetsByPath"
| "groupAssetsByExtension"
| "assetsSpace" | "assetsSpace"
| "excludeAssets" | "cachedAssets"
| "excludeModules"
| "warningsFilter"
| "cachedModules" | "cachedModules"
| "orphanModules"
| "dependentModules"
| "runtimeModules"
| "groupModulesByCacheStatus"
| "groupModulesByLayer"
| "groupModulesByAttributes"
| "groupModulesByPath"
| "groupModulesByExtension"
| "groupModulesByType"
| "entrypoints"
| "chunkGroupAuxiliary" | "chunkGroupAuxiliary"
| "chunkGroupChildren" | "chunkGroupChildren"
| "chunkGroupMaxAssets" | "chunkGroupMaxAssets"
| "modulesSpace" | "chunkGroups"
| "chunkModulesSpace" | "chunkModulesSpace"
| "nestedModulesSpace" | "chunksSort"
| "context"
| "dependentModules"
| "entrypoints"
| "excludeAssets"
| "excludeModules"
| "groupAssetsByEmitStatus"
| "groupAssetsByExtension"
| "groupAssetsByPath"
| "groupModulesByAttributes"
| "groupModulesByCacheStatus"
| "groupModulesByExtension"
| "groupModulesByLayer"
| "groupModulesByPath"
| "groupModulesByType"
| "ids"
| "logging" | "logging"
| "loggingDebug" | "loggingDebug"
| "loggingTrace" | "loggingTrace"
| "modulesSort"
| "modulesSpace"
| "nestedModulesSpace"
| "orphanModules"
| "runtimeModules"
| "warningsFilter"
| "requestShortener"
| "chunkModulesSort"
| "nestedModulesSort"
| "_env" | "_env"
> & > &
Record<string, any>; Record<string, any>;
@ -12617,7 +12628,7 @@ declare class ProgressPlugin {
showModules?: boolean; showModules?: boolean;
showDependencies?: boolean; showDependencies?: boolean;
showActiveModules?: boolean; showActiveModules?: boolean;
percentBy?: null | "entries" | "modules" | "dependencies"; percentBy?: null | "modules" | "entries" | "dependencies";
apply(compiler: Compiler | MultiCompiler): void; apply(compiler: Compiler | MultiCompiler): void;
static getReporter( static getReporter(
compiler: Compiler compiler: Compiler
@ -12682,7 +12693,7 @@ declare interface ProgressPluginOptions {
/** /**
* Collect percent algorithm. By default it calculates by a median from modules, entries and dependencies percent. * Collect percent algorithm. By default it calculates by a median from modules, entries and dependencies percent.
*/ */
percentBy?: null | "entries" | "modules" | "dependencies"; percentBy?: null | "modules" | "entries" | "dependencies";
/** /**
* Collect profile data for progress steps. Default: false. * Collect profile data for progress steps. Default: false.
@ -17432,21 +17443,24 @@ declare interface WriteStreamOptions {
declare function exports( declare function exports(
options: Configuration, options: Configuration,
callback?: CallbackWebpack<Stats> callback?: CallbackWebpack<Stats>
): Compiler; ): null | Compiler;
declare function exports( declare function exports(
options: ReadonlyArray<Configuration> & MultiCompilerOptions, options: MultiConfiguration,
callback?: CallbackWebpack<MultiStats> callback?: CallbackWebpack<MultiStats>
): MultiCompiler; ): null | MultiCompiler;
declare namespace exports { declare namespace exports {
export const webpack: { export const webpack: {
(options: Configuration, callback?: CallbackWebpack<Stats>): Compiler;
( (
options: ReadonlyArray<Configuration> & MultiCompilerOptions, options: Configuration,
callback?: CallbackWebpack<Stats>
): null | Compiler;
(
options: MultiConfiguration,
callback?: CallbackWebpack<MultiStats> callback?: CallbackWebpack<MultiStats>
): MultiCompiler; ): null | MultiCompiler;
}; };
export const validate: ( export const validate: (
configuration: Configuration | Configuration[] configuration: Configuration | MultiConfiguration
) => void; ) => void;
export const validateSchema: ( export const validateSchema: (
schema: Parameters<typeof validateFunction>[0], schema: Parameters<typeof validateFunction>[0],
@ -17455,7 +17469,7 @@ declare namespace exports {
) => void; ) => void;
export const version: string; export const version: string;
export namespace cli { export namespace cli {
export let createColors: (__0?: { useColor?: boolean }) => Colors; export let createColors: (__0?: ColorsOptions) => Colors;
export let getArguments: ( export let getArguments: (
schema?: schema?:
| (JSONSchema4 & { | (JSONSchema4 & {
@ -18145,7 +18159,9 @@ declare namespace exports {
AssetEmittedInfo, AssetEmittedInfo,
Entrypoint, Entrypoint,
MultiCompilerOptions, MultiCompilerOptions,
MultiConfiguration,
MultiStats, MultiStats,
MultiStatsOptions,
ResolveData, ResolveData,
ParserState, ParserState,
ResolvePluginInstance, ResolvePluginInstance,
@ -18153,6 +18169,8 @@ declare namespace exports {
Watching, Watching,
Argument, Argument,
Problem, Problem,
Colors,
ColorsOptions,
StatsAsset, StatsAsset,
StatsChunk, StatsChunk,
StatsChunkGroup, StatsChunkGroup,