mirror of https://github.com/webpack/webpack.git
fix: types
This commit is contained in:
parent
1ffd83f416
commit
2d25a95d8c
|
@ -2583,7 +2583,7 @@ export interface StatsOptions {
|
||||||
/**
|
/**
|
||||||
* Add children information.
|
* Add children information.
|
||||||
*/
|
*/
|
||||||
children?: boolean;
|
children?: StatsValue[] | StatsValue;
|
||||||
/**
|
/**
|
||||||
* Display auxiliary assets in chunk groups.
|
* Display auxiliary assets in chunk groups.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,7 +21,7 @@ const {
|
||||||
/** @typedef {import("./Module")} Module */
|
/** @typedef {import("./Module")} Module */
|
||||||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||||
|
|
||||||
/** @typedef {{module: Module | null, loc: DependencyLocation, request: string}} OriginRecord */
|
/** @typedef {{ module: Module | null, loc: DependencyLocation, request: string }} OriginRecord */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} RawChunkGroupOptions
|
* @typedef {object} RawChunkGroupOptions
|
||||||
|
|
|
@ -140,6 +140,7 @@ const { isSourceEqual } = require("./util/source");
|
||||||
*/
|
*/
|
||||||
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
||||||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @callback Callback
|
* @callback Callback
|
||||||
* @param {(WebpackError | null)=} err
|
* @param {(WebpackError | null)=} err
|
||||||
|
@ -148,33 +149,33 @@ const { isSourceEqual } = require("./util/source");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @callback ModuleCallback
|
* @callback ModuleCallback
|
||||||
* @param {(WebpackError | null)=} err
|
* @param {WebpackError | null=} err
|
||||||
* @param {(Module | null)=} result
|
* @param {Module | null=} result
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @callback ModuleFactoryResultCallback
|
* @callback ModuleFactoryResultCallback
|
||||||
* @param {(WebpackError | null)=} err
|
* @param {WebpackError | null=} err
|
||||||
* @param {ModuleFactoryResult=} result
|
* @param {ModuleFactoryResult | null=} result
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @callback ModuleOrFactoryResultCallback
|
* @callback ModuleOrModuleFactoryResultCallback
|
||||||
* @param {(WebpackError | null)=} err
|
* @param {WebpackError | null=} err
|
||||||
* @param {Module | ModuleFactoryResult=} result
|
* @param {Module | ModuleFactoryResult | null=} result
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @callback ExecuteModuleCallback
|
* @callback ExecuteModuleCallback
|
||||||
* @param {WebpackError | null} err
|
* @param {WebpackError | null=} err
|
||||||
* @param {ExecuteModuleResult=} result
|
* @param {ExecuteModuleResult | null=} result
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @typedef {new (...args: EXPECTED_ANY[]) => Dependency} DepConstructor */
|
/** @typedef {new (...args: EXPECTED_ANY[]) => Dependency} DependencyConstructor */
|
||||||
|
|
||||||
/** @typedef {Record<string, Source>} CompilationAssets */
|
/** @typedef {Record<string, Source>} CompilationAssets */
|
||||||
|
|
||||||
|
@ -494,7 +495,7 @@ class Compilation {
|
||||||
this._backCompat = compiler._backCompat;
|
this._backCompat = compiler._backCompat;
|
||||||
|
|
||||||
const getNormalModuleLoader = () => deprecatedNormalModuleLoaderHook(this);
|
const getNormalModuleLoader = () => deprecatedNormalModuleLoaderHook(this);
|
||||||
/** @typedef {{ additionalAssets?: true | TODO }} ProcessAssetsAdditionalOptions */
|
/** @typedef {{ additionalAssets?: boolean | ((assets: CompilationAssets) => void) }} ProcessAssetsAdditionalOptions */
|
||||||
/** @type {AsyncSeriesHook<[CompilationAssets], ProcessAssetsAdditionalOptions>} */
|
/** @type {AsyncSeriesHook<[CompilationAssets], ProcessAssetsAdditionalOptions>} */
|
||||||
const processAssetsHook = new AsyncSeriesHook(["assets"]);
|
const processAssetsHook = new AsyncSeriesHook(["assets"]);
|
||||||
|
|
||||||
|
@ -1089,8 +1090,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
this.moduleGraph = new ModuleGraph();
|
this.moduleGraph = new ModuleGraph();
|
||||||
/** @type {ChunkGraph} */
|
/** @type {ChunkGraph} */
|
||||||
this.chunkGraph = /** @type {TODO} */ (undefined);
|
this.chunkGraph = /** @type {TODO} */ (undefined);
|
||||||
/** @type {CodeGenerationResults} */
|
/** @type {CodeGenerationResults | undefined} */
|
||||||
this.codeGenerationResults = /** @type {TODO} */ (undefined);
|
this.codeGenerationResults = undefined;
|
||||||
|
|
||||||
/** @type {AsyncQueue<Module, Module, Module>} */
|
/** @type {AsyncQueue<Module, Module, Module>} */
|
||||||
this.processDependenciesQueue = new AsyncQueue({
|
this.processDependenciesQueue = new AsyncQueue({
|
||||||
|
@ -1183,7 +1184,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
this.children = [];
|
this.children = [];
|
||||||
/** @type {Map<string, LogEntry[]>} */
|
/** @type {Map<string, LogEntry[]>} */
|
||||||
this.logging = new Map();
|
this.logging = new Map();
|
||||||
/** @type {Map<DepConstructor, ModuleFactory>} */
|
/** @type {Map<DependencyConstructor, ModuleFactory>} */
|
||||||
this.dependencyFactories = new Map();
|
this.dependencyFactories = new Map();
|
||||||
/** @type {DependencyTemplates} */
|
/** @type {DependencyTemplates} */
|
||||||
this.dependencyTemplates = new DependencyTemplates(
|
this.dependencyTemplates = new DependencyTemplates(
|
||||||
|
@ -1636,7 +1637,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
|
|
||||||
/** @type {Map<ModuleFactory, Map<string, Dependency[]>>} */
|
/** @type {Map<ModuleFactory, Map<string, Dependency[]>>} */
|
||||||
let dependencies;
|
let dependencies;
|
||||||
/** @type {DepConstructor} */
|
/** @type {DependencyConstructor} */
|
||||||
let factoryCacheKey;
|
let factoryCacheKey;
|
||||||
/** @type {ModuleFactory} */
|
/** @type {ModuleFactory} */
|
||||||
let factoryCacheKey2;
|
let factoryCacheKey2;
|
||||||
|
@ -1819,7 +1820,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
const resourceIdent = dep.getResourceIdentifier();
|
const resourceIdent = dep.getResourceIdentifier();
|
||||||
if (resourceIdent !== undefined && resourceIdent !== null) {
|
if (resourceIdent !== undefined && resourceIdent !== null) {
|
||||||
const category = dep.category;
|
const category = dep.category;
|
||||||
const constructor = /** @type {DepConstructor} */ (dep.constructor);
|
const constructor =
|
||||||
|
/** @type {DependencyConstructor} */
|
||||||
|
(dep.constructor);
|
||||||
if (factoryCacheKey === constructor) {
|
if (factoryCacheKey === constructor) {
|
||||||
// Fast path 1: same constructor as prev item
|
// Fast path 1: same constructor as prev item
|
||||||
if (listCacheKey1 === category && listCacheKey2 === resourceIdent) {
|
if (listCacheKey1 === category && listCacheKey2 === resourceIdent) {
|
||||||
|
@ -1954,6 +1957,116 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
moduleGraph.setResolvedModule(originModule, dependency, module);
|
moduleGraph.setResolvedModule(originModule, dependency, module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {FactorizeModuleOptions} options options
|
||||||
|
* @param {ModuleOrModuleFactoryResultCallback} callback callback
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
_factorizeModule(
|
||||||
|
{
|
||||||
|
currentProfile,
|
||||||
|
factory,
|
||||||
|
dependencies,
|
||||||
|
originModule,
|
||||||
|
factoryResult,
|
||||||
|
contextInfo,
|
||||||
|
context
|
||||||
|
},
|
||||||
|
callback
|
||||||
|
) {
|
||||||
|
if (currentProfile !== undefined) {
|
||||||
|
currentProfile.markFactoryStart();
|
||||||
|
}
|
||||||
|
factory.create(
|
||||||
|
{
|
||||||
|
contextInfo: {
|
||||||
|
issuer: originModule
|
||||||
|
? /** @type {string} */ (originModule.nameForCondition())
|
||||||
|
: "",
|
||||||
|
issuerLayer: originModule ? originModule.layer : null,
|
||||||
|
compiler: this.compiler.name,
|
||||||
|
...contextInfo
|
||||||
|
},
|
||||||
|
resolveOptions: originModule ? originModule.resolveOptions : undefined,
|
||||||
|
context:
|
||||||
|
context ||
|
||||||
|
(originModule
|
||||||
|
? /** @type {string} */ (originModule.context)
|
||||||
|
: this.compiler.context),
|
||||||
|
dependencies
|
||||||
|
},
|
||||||
|
(err, result) => {
|
||||||
|
if (result) {
|
||||||
|
// TODO webpack 6: remove
|
||||||
|
// For backward-compat
|
||||||
|
if (result.module === undefined && result instanceof Module) {
|
||||||
|
result = {
|
||||||
|
module: result
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (!factoryResult) {
|
||||||
|
const {
|
||||||
|
fileDependencies,
|
||||||
|
contextDependencies,
|
||||||
|
missingDependencies
|
||||||
|
} = result;
|
||||||
|
if (fileDependencies) {
|
||||||
|
this.fileDependencies.addAll(fileDependencies);
|
||||||
|
}
|
||||||
|
if (contextDependencies) {
|
||||||
|
this.contextDependencies.addAll(contextDependencies);
|
||||||
|
}
|
||||||
|
if (missingDependencies) {
|
||||||
|
this.missingDependencies.addAll(missingDependencies);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (err) {
|
||||||
|
const notFoundError = new ModuleNotFoundError(
|
||||||
|
originModule,
|
||||||
|
err,
|
||||||
|
/** @type {DependencyLocation} */
|
||||||
|
(dependencies.map((d) => d.loc).find(Boolean))
|
||||||
|
);
|
||||||
|
return callback(notFoundError, factoryResult ? result : undefined);
|
||||||
|
}
|
||||||
|
if (!result) {
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentProfile !== undefined) {
|
||||||
|
currentProfile.markFactoryEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, factoryResult ? result : result.module);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overload
|
||||||
|
* @param {FactorizeModuleOptions & { factoryResult?: false }} options options
|
||||||
|
* @param {ModuleCallback} callback callback
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @overload
|
||||||
|
* @param {FactorizeModuleOptions & { factoryResult: true }} options options
|
||||||
|
* @param {ModuleFactoryResultCallback} callback callback
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @param {FactorizeModuleOptions & { factoryResult?: false } | FactorizeModuleOptions & { factoryResult: true }} options options
|
||||||
|
* @param {ModuleCallback | ModuleFactoryResultCallback} callback callback
|
||||||
|
*/
|
||||||
|
factorizeModule(options, callback) {
|
||||||
|
this.factorizeQueue.add(
|
||||||
|
options,
|
||||||
|
/** @type {ModuleOrModuleFactoryResultCallback} */
|
||||||
|
(callback)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} HandleModuleCreationOptions
|
* @typedef {object} HandleModuleCreationOptions
|
||||||
* @property {ModuleFactory} factory
|
* @property {ModuleFactory} factory
|
||||||
|
@ -2201,92 +2314,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {FactorizeModuleOptions} options options object
|
|
||||||
* @param {ModuleOrFactoryResultCallback} callback callback
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
_factorizeModule(
|
|
||||||
{
|
|
||||||
currentProfile,
|
|
||||||
factory,
|
|
||||||
dependencies,
|
|
||||||
originModule,
|
|
||||||
factoryResult,
|
|
||||||
contextInfo,
|
|
||||||
context
|
|
||||||
},
|
|
||||||
callback
|
|
||||||
) {
|
|
||||||
if (currentProfile !== undefined) {
|
|
||||||
currentProfile.markFactoryStart();
|
|
||||||
}
|
|
||||||
factory.create(
|
|
||||||
{
|
|
||||||
contextInfo: {
|
|
||||||
issuer: originModule
|
|
||||||
? /** @type {string} */ (originModule.nameForCondition())
|
|
||||||
: "",
|
|
||||||
issuerLayer: originModule ? originModule.layer : null,
|
|
||||||
compiler: this.compiler.name,
|
|
||||||
...contextInfo
|
|
||||||
},
|
|
||||||
resolveOptions: originModule ? originModule.resolveOptions : undefined,
|
|
||||||
context:
|
|
||||||
context ||
|
|
||||||
(originModule
|
|
||||||
? /** @type {string} */ (originModule.context)
|
|
||||||
: this.compiler.context),
|
|
||||||
dependencies
|
|
||||||
},
|
|
||||||
(err, result) => {
|
|
||||||
if (result) {
|
|
||||||
// TODO webpack 6: remove
|
|
||||||
// For backward-compat
|
|
||||||
if (result.module === undefined && result instanceof Module) {
|
|
||||||
result = {
|
|
||||||
module: result
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (!factoryResult) {
|
|
||||||
const {
|
|
||||||
fileDependencies,
|
|
||||||
contextDependencies,
|
|
||||||
missingDependencies
|
|
||||||
} = result;
|
|
||||||
if (fileDependencies) {
|
|
||||||
this.fileDependencies.addAll(fileDependencies);
|
|
||||||
}
|
|
||||||
if (contextDependencies) {
|
|
||||||
this.contextDependencies.addAll(contextDependencies);
|
|
||||||
}
|
|
||||||
if (missingDependencies) {
|
|
||||||
this.missingDependencies.addAll(missingDependencies);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (err) {
|
|
||||||
const notFoundError = new ModuleNotFoundError(
|
|
||||||
originModule,
|
|
||||||
err,
|
|
||||||
/** @type {DependencyLocation} */
|
|
||||||
(dependencies.map((d) => d.loc).find(Boolean))
|
|
||||||
);
|
|
||||||
return callback(notFoundError, factoryResult ? result : undefined);
|
|
||||||
}
|
|
||||||
if (!result) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentProfile !== undefined) {
|
|
||||||
currentProfile.markFactoryEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(null, factoryResult ? result : result.module);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} context context string path
|
* @param {string} context context string path
|
||||||
* @param {Dependency} dependency dependency used to create Module chain
|
* @param {Dependency} dependency dependency used to create Module chain
|
||||||
|
@ -2315,7 +2342,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
new WebpackError("Parameter 'dependency' must be a Dependency")
|
new WebpackError("Parameter 'dependency' must be a Dependency")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const Dep = /** @type {DepConstructor} */ (dependency.constructor);
|
const Dep =
|
||||||
|
/** @type {DependencyConstructor} */
|
||||||
|
(dependency.constructor);
|
||||||
const moduleFactory = this.dependencyFactories.get(Dep);
|
const moduleFactory = this.dependencyFactories.get(Dep);
|
||||||
if (!moduleFactory) {
|
if (!moduleFactory) {
|
||||||
return callback(
|
return callback(
|
||||||
|
@ -2413,8 +2442,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
entryData[target].push(entry);
|
entryData[target].push(entry);
|
||||||
for (const _key of Object.keys(options)) {
|
for (const key_ of Object.keys(options)) {
|
||||||
const key = /** @type {keyof EntryOptions} */ (_key);
|
const key = /** @type {keyof EntryOptions} */ (key_);
|
||||||
if (options[key] === undefined) continue;
|
if (options[key] === undefined) continue;
|
||||||
if (entryData.options[key] === options[key]) continue;
|
if (entryData.options[key] === options[key]) continue;
|
||||||
if (
|
if (
|
||||||
|
@ -2425,10 +2454,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (entryData.options[key] === undefined) {
|
if (entryData.options[key] === undefined) {
|
||||||
/** @type {TODO} */
|
/** @type {EntryOptions[keyof EntryOptions]} */
|
||||||
(entryData.options)[key] =
|
(entryData.options[key]) = options[key];
|
||||||
/** @type {NonNullable<EntryOptions[keyof EntryOptions]>} */
|
|
||||||
(options[key]);
|
|
||||||
} else {
|
} else {
|
||||||
return callback(
|
return callback(
|
||||||
new WebpackError(
|
new WebpackError(
|
||||||
|
@ -3553,7 +3580,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||||
let statModulesGenerated = 0;
|
let statModulesGenerated = 0;
|
||||||
const { chunkGraph, moduleGraph, dependencyTemplates, runtimeTemplate } =
|
const { chunkGraph, moduleGraph, dependencyTemplates, runtimeTemplate } =
|
||||||
this;
|
this;
|
||||||
const results = this.codeGenerationResults;
|
const results =
|
||||||
|
/** @type {CodeGenerationResults} */
|
||||||
|
(this.codeGenerationResults);
|
||||||
/** @type {WebpackError[]} */
|
/** @type {WebpackError[]} */
|
||||||
const errors = [];
|
const errors = [];
|
||||||
/** @type {NotCodeGeneratedModules | undefined} */
|
/** @type {NotCodeGeneratedModules | undefined} */
|
||||||
|
@ -3748,7 +3777,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||||
chunkGraph = this.chunkGraph,
|
chunkGraph = this.chunkGraph,
|
||||||
modules = this.modules,
|
modules = this.modules,
|
||||||
chunks = this.chunks,
|
chunks = this.chunks,
|
||||||
codeGenerationResults = this.codeGenerationResults,
|
codeGenerationResults = /** @type {CodeGenerationResults} */ (
|
||||||
|
this.codeGenerationResults
|
||||||
|
),
|
||||||
chunkGraphEntries = this._getChunkGraphEntries()
|
chunkGraphEntries = this._getChunkGraphEntries()
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const context = { chunkGraph, codeGenerationResults };
|
const context = { chunkGraph, codeGenerationResults };
|
||||||
|
@ -4565,7 +4596,9 @@ This prevents using hashes of each other and should be avoided.`);
|
||||||
chunk.updateHash(chunkHash, chunkGraph);
|
chunk.updateHash(chunkHash, chunkGraph);
|
||||||
this.hooks.chunkHash.call(chunk, chunkHash, {
|
this.hooks.chunkHash.call(chunk, chunkHash, {
|
||||||
chunkGraph,
|
chunkGraph,
|
||||||
codeGenerationResults: this.codeGenerationResults,
|
codeGenerationResults:
|
||||||
|
/** @type {CodeGenerationResults} */
|
||||||
|
(this.codeGenerationResults),
|
||||||
moduleGraph: this.moduleGraph,
|
moduleGraph: this.moduleGraph,
|
||||||
runtimeTemplate: this.runtimeTemplate
|
runtimeTemplate: this.runtimeTemplate
|
||||||
});
|
});
|
||||||
|
@ -4979,7 +5012,9 @@ This prevents using hashes of each other and should be avoided.`);
|
||||||
hash: /** @type {string} */ (this.hash),
|
hash: /** @type {string} */ (this.hash),
|
||||||
fullHash: /** @type {string} */ (this.fullHash),
|
fullHash: /** @type {string} */ (this.fullHash),
|
||||||
outputOptions,
|
outputOptions,
|
||||||
codeGenerationResults: this.codeGenerationResults,
|
codeGenerationResults:
|
||||||
|
/** @type {CodeGenerationResults} */
|
||||||
|
(this.codeGenerationResults),
|
||||||
moduleTemplates: this.moduleTemplates,
|
moduleTemplates: this.moduleTemplates,
|
||||||
dependencyTemplates: this.dependencyTemplates,
|
dependencyTemplates: this.dependencyTemplates,
|
||||||
chunkGraph: this.chunkGraph,
|
chunkGraph: this.chunkGraph,
|
||||||
|
@ -5637,19 +5672,6 @@ This prevents using hashes of each other and should be avoided.`);
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Workaround for typescript as it doesn't support function overloading in jsdoc within a class
|
|
||||||
/* eslint-disable jsdoc/require-asterisk-prefix */
|
|
||||||
Compilation.prototype.factorizeModule = /**
|
|
||||||
@type {{
|
|
||||||
(options: FactorizeModuleOptions & { factoryResult?: false }, callback: ModuleCallback): void;
|
|
||||||
(options: FactorizeModuleOptions & { factoryResult: true }, callback: ModuleFactoryResultCallback): void;
|
|
||||||
}} */ (
|
|
||||||
function factorizeModule(options, callback) {
|
|
||||||
this.factorizeQueue.add(options, /** @type {TODO} */ (callback));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
/* eslint-enable jsdoc/require-asterisk-prefix */
|
|
||||||
|
|
||||||
// Hide from typescript
|
// Hide from typescript
|
||||||
const compilationPrototype = Compilation.prototype;
|
const compilationPrototype = Compilation.prototype;
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,11 @@
|
||||||
const { DEFAULTS } = require("./config/defaults");
|
const { DEFAULTS } = require("./config/defaults");
|
||||||
const createHash = require("./util/createHash");
|
const createHash = require("./util/createHash");
|
||||||
|
|
||||||
|
/** @typedef {import("./Compilation").DependencyConstructor} DependencyConstructor */
|
||||||
/** @typedef {import("./Dependency")} Dependency */
|
/** @typedef {import("./Dependency")} Dependency */
|
||||||
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
|
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
|
||||||
/** @typedef {typeof import("./util/Hash")} Hash */
|
/** @typedef {typeof import("./util/Hash")} Hash */
|
||||||
|
|
||||||
/** @typedef {new (...args: EXPECTED_ANY[]) => Dependency} DependencyConstructor */
|
|
||||||
|
|
||||||
class DependencyTemplates {
|
class DependencyTemplates {
|
||||||
/**
|
/**
|
||||||
* @param {string | Hash} hashFunction the hash function to use
|
* @param {string | Hash} hashFunction the hash function to use
|
||||||
|
|
|
@ -18,7 +18,6 @@ const { cachedSetProperty, resolveByProperty } = require("./util/cleverMerge");
|
||||||
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectKnown} ExternalItemObjectKnown */
|
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectKnown} ExternalItemObjectKnown */
|
||||||
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectUnknown} ExternalItemObjectUnknown */
|
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectUnknown} ExternalItemObjectUnknown */
|
||||||
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
|
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
|
||||||
/** @typedef {import("./Compilation").DepConstructor} DepConstructor */
|
|
||||||
/** @typedef {import("./ExternalModule").DependencyMeta} DependencyMeta */
|
/** @typedef {import("./ExternalModule").DependencyMeta} DependencyMeta */
|
||||||
/** @typedef {import("./Module")} Module */
|
/** @typedef {import("./Module")} Module */
|
||||||
/** @typedef {import("./ModuleFactory").IssuerLayer} IssuerLayer */
|
/** @typedef {import("./ModuleFactory").IssuerLayer} IssuerLayer */
|
||||||
|
|
|
@ -50,6 +50,7 @@ const {
|
||||||
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
||||||
/** @typedef {import("./Compilation").Records} Records */
|
/** @typedef {import("./Compilation").Records} Records */
|
||||||
/** @typedef {import("./Compiler")} Compiler */
|
/** @typedef {import("./Compiler")} Compiler */
|
||||||
|
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
||||||
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
||||||
/** @typedef {import("./Module")} Module */
|
/** @typedef {import("./Module")} Module */
|
||||||
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
||||||
|
@ -399,13 +400,11 @@ class HotModuleReplacementPlugin {
|
||||||
* @returns {string} module hash
|
* @returns {string} module hash
|
||||||
*/
|
*/
|
||||||
const getModuleHash = (module) => {
|
const getModuleHash = (module) => {
|
||||||
if (
|
const codeGenerationResults =
|
||||||
compilation.codeGenerationResults.has(module, chunk.runtime)
|
/** @type {CodeGenerationResults} */
|
||||||
) {
|
(compilation.codeGenerationResults);
|
||||||
return compilation.codeGenerationResults.getHash(
|
if (codeGenerationResults.has(module, chunk.runtime)) {
|
||||||
module,
|
return codeGenerationResults.getHash(module, chunk.runtime);
|
||||||
chunk.runtime
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
nonCodeGeneratedModules.add(module, chunk.runtime);
|
nonCodeGeneratedModules.add(module, chunk.runtime);
|
||||||
return chunkGraph.getModuleHash(module, chunk.runtime);
|
return chunkGraph.getModuleHash(module, chunk.runtime);
|
||||||
|
@ -499,14 +498,14 @@ class HotModuleReplacementPlugin {
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const codeGenerationResults =
|
||||||
|
/** @type {CodeGenerationResults} */
|
||||||
|
(compilation.codeGenerationResults);
|
||||||
for (const [module, chunk] of fullHashModules) {
|
for (const [module, chunk] of fullHashModules) {
|
||||||
const key = `${chunk.id}|${module.identifier()}`;
|
const key = `${chunk.id}|${module.identifier()}`;
|
||||||
const hash = nonCodeGeneratedModules.has(module, chunk.runtime)
|
const hash = nonCodeGeneratedModules.has(module, chunk.runtime)
|
||||||
? chunkGraph.getModuleHash(module, chunk.runtime)
|
? chunkGraph.getModuleHash(module, chunk.runtime)
|
||||||
: compilation.codeGenerationResults.getHash(
|
: codeGenerationResults.getHash(module, chunk.runtime);
|
||||||
module,
|
|
||||||
chunk.runtime
|
|
||||||
);
|
|
||||||
if (records.chunkModuleHashes[key] !== hash) {
|
if (records.chunkModuleHashes[key] !== hash) {
|
||||||
updatedModules.add(module, chunk);
|
updatedModules.add(module, chunk);
|
||||||
}
|
}
|
||||||
|
@ -644,10 +643,7 @@ class HotModuleReplacementPlugin {
|
||||||
// Module is still in the same runtime combination
|
// Module is still in the same runtime combination
|
||||||
const hash = nonCodeGeneratedModules.has(module, newRuntime)
|
const hash = nonCodeGeneratedModules.has(module, newRuntime)
|
||||||
? chunkGraph.getModuleHash(module, newRuntime)
|
? chunkGraph.getModuleHash(module, newRuntime)
|
||||||
: compilation.codeGenerationResults.getHash(
|
: codeGenerationResults.getHash(module, newRuntime);
|
||||||
module,
|
|
||||||
newRuntime
|
|
||||||
);
|
|
||||||
if (hash !== oldHash) {
|
if (hash !== oldHash) {
|
||||||
if (module.type === WEBPACK_MODULE_TYPE_RUNTIME) {
|
if (module.type === WEBPACK_MODULE_TYPE_RUNTIME) {
|
||||||
newRuntimeModules = newRuntimeModules || [];
|
newRuntimeModules = newRuntimeModules || [];
|
||||||
|
@ -731,7 +727,9 @@ class HotModuleReplacementPlugin {
|
||||||
outputOptions: compilation.outputOptions,
|
outputOptions: compilation.outputOptions,
|
||||||
moduleTemplates: compilation.moduleTemplates,
|
moduleTemplates: compilation.moduleTemplates,
|
||||||
dependencyTemplates: compilation.dependencyTemplates,
|
dependencyTemplates: compilation.dependencyTemplates,
|
||||||
codeGenerationResults: compilation.codeGenerationResults,
|
codeGenerationResults: /** @type {CodeGenerationResults} */ (
|
||||||
|
compilation.codeGenerationResults
|
||||||
|
),
|
||||||
runtimeTemplate: compilation.runtimeTemplate,
|
runtimeTemplate: compilation.runtimeTemplate,
|
||||||
moduleGraph: compilation.moduleGraph,
|
moduleGraph: compilation.moduleGraph,
|
||||||
chunkGraph
|
chunkGraph
|
||||||
|
|
|
@ -24,6 +24,7 @@ const memoize = require("../util/memoize");
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */
|
/** @typedef {import("../../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").CssGlobalGeneratorOptions} CssGlobalGeneratorOptions */
|
/** @typedef {import("../../declarations/WebpackOptions").CssGlobalGeneratorOptions} CssGlobalGeneratorOptions */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
|
/** @typedef {import("../../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
|
||||||
|
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
||||||
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||||
/** @typedef {import("../Dependency")} Dependency */
|
/** @typedef {import("../Dependency")} Dependency */
|
||||||
/** @typedef {import("../DependencyTemplate").CssData} CssData */
|
/** @typedef {import("../DependencyTemplate").CssData} CssData */
|
||||||
|
@ -124,7 +125,7 @@ class CssGenerator extends Generator {
|
||||||
*/
|
*/
|
||||||
const handleDependency = (dependency) => {
|
const handleDependency = (dependency) => {
|
||||||
const constructor =
|
const constructor =
|
||||||
/** @type {new (...args: EXPECTED_ANY[]) => Dependency} */
|
/** @type {DependencyConstructor} */
|
||||||
(dependency.constructor);
|
(dependency.constructor);
|
||||||
const template = generateContext.dependencyTemplates.get(constructor);
|
const template = generateContext.dependencyTemplates.get(constructor);
|
||||||
if (!template) {
|
if (!template) {
|
||||||
|
|
|
@ -445,7 +445,6 @@ class CssModulesPlugin {
|
||||||
compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
|
compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
|
||||||
const {
|
const {
|
||||||
chunkGraph,
|
chunkGraph,
|
||||||
codeGenerationResults,
|
|
||||||
moduleGraph,
|
moduleGraph,
|
||||||
runtimeTemplate,
|
runtimeTemplate,
|
||||||
outputOptions: {
|
outputOptions: {
|
||||||
|
@ -457,6 +456,9 @@ class CssModulesPlugin {
|
||||||
} = compilation;
|
} = compilation;
|
||||||
const hash = createHash(hashFunction);
|
const hash = createHash(hashFunction);
|
||||||
if (hashSalt) hash.update(hashSalt);
|
if (hashSalt) hash.update(hashSalt);
|
||||||
|
const codeGenerationResults =
|
||||||
|
/** @type {CodeGenerationResults} */
|
||||||
|
(compilation.codeGenerationResults);
|
||||||
hooks.chunkHash.call(chunk, hash, {
|
hooks.chunkHash.call(chunk, hash, {
|
||||||
chunkGraph,
|
chunkGraph,
|
||||||
codeGenerationResults,
|
codeGenerationResults,
|
||||||
|
|
|
@ -296,7 +296,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
||||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||||
depBlock.addDependency(dep);
|
depBlock.addDependency(dep);
|
||||||
|
|
||||||
parser.state.current = /** @type {TODO} */ (depBlock);
|
parser.state.current = /** @type {EXPECTED_ANY} */ (depBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expr.arguments.length === 1) {
|
if (expr.arguments.length === 1) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ const LoaderDependency = require("./LoaderDependency");
|
||||||
const LoaderImportDependency = require("./LoaderImportDependency");
|
const LoaderImportDependency = require("./LoaderImportDependency");
|
||||||
|
|
||||||
/** @typedef {import("../../declarations/LoaderContext").LoaderPluginLoaderContext} LoaderPluginLoaderContext */
|
/** @typedef {import("../../declarations/LoaderContext").LoaderPluginLoaderContext} LoaderPluginLoaderContext */
|
||||||
/** @typedef {import("../Compilation").DepConstructor} DepConstructor */
|
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
||||||
/** @typedef {import("../Compilation").ExecuteModuleExports} ExecuteModuleExports */
|
/** @typedef {import("../Compilation").ExecuteModuleExports} ExecuteModuleExports */
|
||||||
/** @typedef {import("../Compilation").ExecuteModuleResult} ExecuteModuleResult */
|
/** @typedef {import("../Compilation").ExecuteModuleResult} ExecuteModuleResult */
|
||||||
/** @typedef {import("../Compiler")} Compiler */
|
/** @typedef {import("../Compiler")} Compiler */
|
||||||
|
@ -66,7 +66,8 @@ class LoaderPlugin {
|
||||||
name: request
|
name: request
|
||||||
};
|
};
|
||||||
const factory = compilation.dependencyFactories.get(
|
const factory = compilation.dependencyFactories.get(
|
||||||
/** @type {DepConstructor} */ (dep.constructor)
|
/** @type {DependencyConstructor} */
|
||||||
|
(dep.constructor)
|
||||||
);
|
);
|
||||||
if (factory === undefined) {
|
if (factory === undefined) {
|
||||||
return callback(
|
return callback(
|
||||||
|
@ -170,7 +171,8 @@ class LoaderPlugin {
|
||||||
name: request
|
name: request
|
||||||
};
|
};
|
||||||
const factory = compilation.dependencyFactories.get(
|
const factory = compilation.dependencyFactories.get(
|
||||||
/** @type {DepConstructor} */ (dep.constructor)
|
/** @type {DependencyConstructor} */
|
||||||
|
(dep.constructor)
|
||||||
);
|
);
|
||||||
if (factory === undefined) {
|
if (factory === undefined) {
|
||||||
return callback(
|
return callback(
|
||||||
|
|
|
@ -86,7 +86,7 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
||||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||||
depBlock.addDependency(dep);
|
depBlock.addDependency(dep);
|
||||||
const old = parser.state.current;
|
const old = parser.state.current;
|
||||||
parser.state.current = /** @type {TODO} */ (depBlock);
|
parser.state.current = /** @type {EXPECTED_ANY} */ (depBlock);
|
||||||
try {
|
try {
|
||||||
let failed = false;
|
let failed = false;
|
||||||
parser.inScope([], () => {
|
parser.inScope([], () => {
|
||||||
|
|
|
@ -42,11 +42,12 @@ const memoize = require("./util/memoize");
|
||||||
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
|
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
|
||||||
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
|
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
|
||||||
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
||||||
|
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
|
||||||
/** @typedef {import("./Compilation").Asset} Asset */
|
/** @typedef {import("./Compilation").Asset} Asset */
|
||||||
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
||||||
/** @typedef {import("./Compilation").EntryOptions} EntryOptions */
|
/** @typedef {import("./Compilation").EntryOptions} EntryOptions */
|
||||||
/** @typedef {import("./Compilation").PathData} PathData */
|
/** @typedef {import("./Compilation").PathData} PathData */
|
||||||
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
|
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
||||||
/** @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("./MultiCompiler").MultiWebpackOptions} MultiConfiguration */
|
||||||
|
|
|
@ -17,6 +17,7 @@ const {
|
||||||
|
|
||||||
/** @typedef {import("../Compiler")} Compiler */
|
/** @typedef {import("../Compiler")} Compiler */
|
||||||
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
|
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
|
||||||
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||||
|
|
||||||
const PLUGIN_NAME = "ArrayPushCallbackChunkFormatPlugin";
|
const PLUGIN_NAME = "ArrayPushCallbackChunkFormatPlugin";
|
||||||
|
|
||||||
|
@ -89,7 +90,9 @@ class ArrayPushCallbackChunkFormatPlugin {
|
||||||
runtime.add(
|
runtime.add(
|
||||||
Template.renderRuntimeModules(runtimeModules, {
|
Template.renderRuntimeModules(runtimeModules, {
|
||||||
...renderContext,
|
...renderContext,
|
||||||
codeGenerationResults: compilation.codeGenerationResults
|
codeGenerationResults:
|
||||||
|
/** @type {CodeGenerationResults} */
|
||||||
|
(compilation.codeGenerationResults)
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ const { JS_TYPES } = require("../ModuleSourceTypesConstants");
|
||||||
const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
|
const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
|
||||||
|
|
||||||
/** @typedef {import("webpack-sources").Source} Source */
|
/** @typedef {import("webpack-sources").Source} Source */
|
||||||
|
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
||||||
/** @typedef {import("../DependenciesBlock")} DependenciesBlock */
|
/** @typedef {import("../DependenciesBlock")} DependenciesBlock */
|
||||||
/** @typedef {import("../Dependency")} Dependency */
|
/** @typedef {import("../Dependency")} Dependency */
|
||||||
/** @typedef {import("../DependencyTemplate")} DependencyTemplate */
|
/** @typedef {import("../DependencyTemplate")} DependencyTemplate */
|
||||||
|
@ -213,7 +214,7 @@ class JavascriptGenerator extends Generator {
|
||||||
*/
|
*/
|
||||||
sourceDependency(module, dependency, initFragments, source, generateContext) {
|
sourceDependency(module, dependency, initFragments, source, generateContext) {
|
||||||
const constructor =
|
const constructor =
|
||||||
/** @type {new (...args: EXPECTED_ANY[]) => Dependency} */
|
/** @type {DependencyConstructor} */
|
||||||
(dependency.constructor);
|
(dependency.constructor);
|
||||||
const template = generateContext.dependencyTemplates.get(constructor);
|
const template = generateContext.dependencyTemplates.get(constructor);
|
||||||
if (!template) {
|
if (!template) {
|
||||||
|
|
|
@ -444,7 +444,6 @@ class JavascriptModulesPlugin {
|
||||||
compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
|
compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
|
||||||
const {
|
const {
|
||||||
chunkGraph,
|
chunkGraph,
|
||||||
codeGenerationResults,
|
|
||||||
moduleGraph,
|
moduleGraph,
|
||||||
runtimeTemplate,
|
runtimeTemplate,
|
||||||
outputOptions: {
|
outputOptions: {
|
||||||
|
@ -454,6 +453,9 @@ class JavascriptModulesPlugin {
|
||||||
hashFunction
|
hashFunction
|
||||||
}
|
}
|
||||||
} = compilation;
|
} = compilation;
|
||||||
|
const codeGenerationResults =
|
||||||
|
/** @type {CodeGenerationResults} */
|
||||||
|
(compilation.codeGenerationResults);
|
||||||
const hash = createHash(hashFunction);
|
const hash = createHash(hashFunction);
|
||||||
if (hashSalt) hash.update(hashSalt);
|
if (hashSalt) hash.update(hashSalt);
|
||||||
if (chunk.hasRuntime()) {
|
if (chunk.hasRuntime()) {
|
||||||
|
|
|
@ -95,6 +95,7 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
||||||
*/
|
*/
|
||||||
/** @typedef {import("../Parser").ParserState} ParserState */
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
||||||
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
||||||
|
|
||||||
/** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => string[], getMembersOptionals: () => boolean[], getMemberRanges: () => Range[] }} GetInfoResult */
|
/** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => string[], getMembersOptionals: () => boolean[], getMemberRanges: () => Range[] }} GetInfoResult */
|
||||||
/** @typedef {Statement | ModuleDeclaration | Expression | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration} StatementPathItem */
|
/** @typedef {Statement | ModuleDeclaration | Expression | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration} StatementPathItem */
|
||||||
/** @typedef {(ident: string) => void} OnIdentString */
|
/** @typedef {(ident: string) => void} OnIdentString */
|
||||||
|
@ -4605,7 +4606,7 @@ class JavascriptParser extends Parser {
|
||||||
terminated: undefined,
|
terminated: undefined,
|
||||||
definitions: new StackedMap()
|
definitions: new StackedMap()
|
||||||
};
|
};
|
||||||
this.state = /** @type {ParserState} */ (state);
|
this.state = state;
|
||||||
this.comments = comments;
|
this.comments = comments;
|
||||||
this.semicolons = semicolons;
|
this.semicolons = semicolons;
|
||||||
this.statementPath = [];
|
this.statementPath = [];
|
||||||
|
|
|
@ -16,6 +16,7 @@ const {
|
||||||
} = require("../util/semver");
|
} = require("../util/semver");
|
||||||
|
|
||||||
/** @typedef {import("webpack-sources").Source} Source */
|
/** @typedef {import("webpack-sources").Source} Source */
|
||||||
|
/** @typedef {import("./ConsumeSharedModule")} ConsumeSharedModule */
|
||||||
/** @typedef {import("../Chunk")} Chunk */
|
/** @typedef {import("../Chunk")} Chunk */
|
||||||
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
||||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||||
|
@ -23,7 +24,7 @@ const {
|
||||||
/** @typedef {import("../Compilation")} Compilation */
|
/** @typedef {import("../Compilation")} Compilation */
|
||||||
/** @typedef {import("../Module")} Module */
|
/** @typedef {import("../Module")} Module */
|
||||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||||
/** @typedef {import("./ConsumeSharedModule")} ConsumeSharedModule */
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||||
|
|
||||||
class ConsumeSharedRuntimeModule extends RuntimeModule {
|
class ConsumeSharedRuntimeModule extends RuntimeModule {
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +41,10 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
||||||
generate() {
|
generate() {
|
||||||
const compilation = /** @type {Compilation} */ (this.compilation);
|
const compilation = /** @type {Compilation} */ (this.compilation);
|
||||||
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
||||||
const { runtimeTemplate, codeGenerationResults } = compilation;
|
const codeGenerationResults =
|
||||||
|
/** @type {CodeGenerationResults} */
|
||||||
|
(compilation.codeGenerationResults);
|
||||||
|
const { runtimeTemplate } = compilation;
|
||||||
/** @type {Record<ChunkId, ModuleId[]>} */
|
/** @type {Record<ChunkId, ModuleId[]>} */
|
||||||
const chunkToModuleMapping = {};
|
const chunkToModuleMapping = {};
|
||||||
/** @type {Map<ModuleId, Source>} */
|
/** @type {Map<ModuleId, Source>} */
|
||||||
|
|
|
@ -16,6 +16,7 @@ const {
|
||||||
/** @typedef {import("../Chunk")} Chunk */
|
/** @typedef {import("../Chunk")} Chunk */
|
||||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||||
/** @typedef {import("../Compilation")} Compilation */
|
/** @typedef {import("../Compilation")} Compilation */
|
||||||
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||||
|
|
||||||
class ShareRuntimeModule extends RuntimeModule {
|
class ShareRuntimeModule extends RuntimeModule {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -29,9 +30,11 @@ class ShareRuntimeModule extends RuntimeModule {
|
||||||
const compilation = /** @type {Compilation} */ (this.compilation);
|
const compilation = /** @type {Compilation} */ (this.compilation);
|
||||||
const {
|
const {
|
||||||
runtimeTemplate,
|
runtimeTemplate,
|
||||||
codeGenerationResults,
|
|
||||||
outputOptions: { uniqueName, ignoreBrowserWarnings }
|
outputOptions: { uniqueName, ignoreBrowserWarnings }
|
||||||
} = compilation;
|
} = compilation;
|
||||||
|
const codeGenerationResults =
|
||||||
|
/** @type {CodeGenerationResults} */
|
||||||
|
(compilation.codeGenerationResults);
|
||||||
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
||||||
/** @type {Map<string, Map<number, Set<string>>>} */
|
/** @type {Map<string, Map<number, Set<string>>>} */
|
||||||
const initCodePerScope = new Map();
|
const initCodePerScope = new Map();
|
||||||
|
|
|
@ -25,6 +25,8 @@ const {
|
||||||
const { makePathsRelative, parseResource } = require("../util/identifier");
|
const { makePathsRelative, parseResource } = require("../util/identifier");
|
||||||
|
|
||||||
/** @typedef {import("webpack-sources").Source} Source */
|
/** @typedef {import("webpack-sources").Source} Source */
|
||||||
|
/** @typedef {import("./StatsFactory")} StatsFactory */
|
||||||
|
/** @typedef {import("./StatsFactory").StatsFactoryContext} StatsFactoryContext */
|
||||||
/** @typedef {import("../Chunk")} Chunk */
|
/** @typedef {import("../Chunk")} Chunk */
|
||||||
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
||||||
/** @typedef {import("../Chunk").ChunkName} ChunkName */
|
/** @typedef {import("../Chunk").ChunkName} ChunkName */
|
||||||
|
@ -48,8 +50,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
||||||
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
|
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
|
||||||
/** @typedef {import("../WebpackError")} WebpackError */
|
/** @typedef {import("../WebpackError")} WebpackError */
|
||||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||||
/** @typedef {import("./StatsFactory")} StatsFactory */
|
/** @typedef {import("../../declarations/WebpackOptions").StatsValue} StatsValue */
|
||||||
/** @typedef {import("./StatsFactory").StatsFactoryContext} StatsFactoryContext */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T
|
* @template T
|
||||||
|
@ -57,8 +58,8 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T, R
|
* @template I, G
|
||||||
* @typedef {import("../util/smartGrouping").GroupConfig<T, R>} GroupConfig
|
* @typedef {import("../util/smartGrouping").GroupConfig<I, G>} GroupConfig
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @typedef {KnownStatsCompilation & Record<string, EXPECTED_ANY>} StatsCompilation */
|
/** @typedef {KnownStatsCompilation & Record<string, EXPECTED_ANY>} StatsCompilation */
|
||||||
|
@ -1694,7 +1695,17 @@ const MODULES_SORTER = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {Record<string, Record<string, (comparators: Comparator<TODO>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>>} */
|
/**
|
||||||
|
* @type {{
|
||||||
|
* "compilation.chunks": Record<string, (comparators: Comparator<Chunk>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
||||||
|
* "compilation.modules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
||||||
|
* "chunk.rootModules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
||||||
|
* "chunk.modules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
||||||
|
* "module.modules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
||||||
|
* "module.reasons": Record<string, (comparators: Comparator<ModuleGraphConnection>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
||||||
|
* "chunk.origins": Record<string, (comparators: Comparator<OriginRecord>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
||||||
|
* }}
|
||||||
|
*/
|
||||||
const SORTERS = {
|
const SORTERS = {
|
||||||
"compilation.chunks": {
|
"compilation.chunks": {
|
||||||
_: (comparators) => {
|
_: (comparators) => {
|
||||||
|
@ -2013,8 +2024,7 @@ const errorsSpaceLimit = (errors, max) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template {{ size: number }} T
|
* @template {{ size: number }} T
|
||||||
* @template {{ size: number }} R
|
* @param {T[]} children children
|
||||||
* @param {(R | T)[]} children children
|
|
||||||
* @param {T[]} assets assets
|
* @param {T[]} assets assets
|
||||||
* @returns {{ size: number }} asset size
|
* @returns {{ size: number }} asset size
|
||||||
*/
|
*/
|
||||||
|
@ -2026,11 +2036,13 @@ const assetGroup = (children, assets) => {
|
||||||
return { size };
|
return { size };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @typedef {{ size: number, sizes: Record<string, number> }} ModuleGroupBySizeResult */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template {{ size: number, sizes: Record<string, number> }} T
|
* @template {ModuleGroupBySizeResult} T
|
||||||
* @param {Children<T>[]} children children
|
* @param {Children<T>[]} children children
|
||||||
* @param {KnownStatsModule[]} modules modules
|
* @param {KnownStatsModule[]} modules modules
|
||||||
* @returns {{ size: number, sizes: Record<string, number>}} size and sizes
|
* @returns {ModuleGroupBySizeResult} size and sizes
|
||||||
*/
|
*/
|
||||||
const moduleGroup = (children, modules) => {
|
const moduleGroup = (children, modules) => {
|
||||||
let size = 0;
|
let size = 0;
|
||||||
|
@ -2067,7 +2079,21 @@ const reasonGroup = (children, reasons) => {
|
||||||
const GROUP_EXTENSION_REGEXP = /(\.[^.]+?)(?:\?|(?: \+ \d+ modules?)?$)/;
|
const GROUP_EXTENSION_REGEXP = /(\.[^.]+?)(?:\?|(?: \+ \d+ modules?)?$)/;
|
||||||
const GROUP_PATH_REGEXP = /(.+)[/\\][^/\\]+?(?:\?|(?: \+ \d+ modules?)?$)/;
|
const GROUP_PATH_REGEXP = /(.+)[/\\][^/\\]+?(?:\?|(?: \+ \d+ modules?)?$)/;
|
||||||
|
|
||||||
/** @typedef {Record<string, (groupConfigs: GroupConfig<KnownStatsAsset, TODO>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>} AssetsGroupers */
|
/** @typedef {{ type: string }} BaseGroup */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @typedef {BaseGroup & { children: T[], size: number }} BaseGroupWithChildren
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {{
|
||||||
|
* _: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroup & { filteredChildren: number, size: number } | BaseGroupWithChildren<KnownStatsAsset>>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
||||||
|
* groupAssetsByInfo: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroupWithChildren<KnownStatsAsset>>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
||||||
|
* groupAssetsByChunk: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroupWithChildren<KnownStatsAsset>>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
||||||
|
* excludeAssets: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroup & { filteredChildren: number, size: number }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
||||||
|
* }} AssetsGroupers
|
||||||
|
*/
|
||||||
|
|
||||||
/** @type {AssetsGroupers} */
|
/** @type {AssetsGroupers} */
|
||||||
const ASSETS_GROUPERS = {
|
const ASSETS_GROUPERS = {
|
||||||
|
@ -2212,9 +2238,16 @@ const ASSETS_GROUPERS = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @typedef {Record<string, (groupConfigs: GroupConfig<KnownStatsModule, TODO>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>} ModulesGroupers */
|
/**
|
||||||
|
* @typedef {{
|
||||||
|
* _: (groupConfigs: GroupConfig<KnownStatsModule, BaseGroup & { filteredChildren?: number, children?: KnownStatsModule[], size: number, sizes: Record<string, number> }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
||||||
|
* excludeModules: (groupConfigs: GroupConfig<KnownStatsModule, BaseGroup & { filteredChildren: number, size: number, sizes: Record<string, number> }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
||||||
|
* }} ModulesGroupers
|
||||||
|
*/
|
||||||
|
|
||||||
/** @type {(type: ExcludeModulesType) => ModulesGroupers} */
|
/**
|
||||||
|
* @type {(type: ExcludeModulesType) => ModulesGroupers}
|
||||||
|
*/
|
||||||
const MODULES_GROUPERS = (type) => ({
|
const MODULES_GROUPERS = (type) => ({
|
||||||
_: (groupConfigs, context, options) => {
|
_: (groupConfigs, context, options) => {
|
||||||
/**
|
/**
|
||||||
|
@ -2233,7 +2266,11 @@ const MODULES_GROUPERS = (type) => ({
|
||||||
type,
|
type,
|
||||||
[name]: Boolean(key),
|
[name]: Boolean(key),
|
||||||
...(exclude ? { filteredChildren: modules.length } : { children }),
|
...(exclude ? { filteredChildren: modules.length } : { children }),
|
||||||
...moduleGroup(children, modules)
|
...moduleGroup(
|
||||||
|
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
||||||
|
(children),
|
||||||
|
modules
|
||||||
|
)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -2290,7 +2327,11 @@ const MODULES_GROUPERS = (type) => ({
|
||||||
type: `${key} modules`,
|
type: `${key} modules`,
|
||||||
moduleType: key,
|
moduleType: key,
|
||||||
...(exclude ? { filteredChildren: modules.length } : { children }),
|
...(exclude ? { filteredChildren: modules.length } : { children }),
|
||||||
...moduleGroup(children, modules)
|
...moduleGroup(
|
||||||
|
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
||||||
|
(children),
|
||||||
|
modules
|
||||||
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2302,7 +2343,11 @@ const MODULES_GROUPERS = (type) => ({
|
||||||
type: "modules by layer",
|
type: "modules by layer",
|
||||||
layer: key,
|
layer: key,
|
||||||
children,
|
children,
|
||||||
...moduleGroup(children, modules)
|
...moduleGroup(
|
||||||
|
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
||||||
|
(children),
|
||||||
|
modules
|
||||||
|
)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2349,7 +2394,11 @@ const MODULES_GROUPERS = (type) => ({
|
||||||
: "modules by extension",
|
: "modules by extension",
|
||||||
name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
|
name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
|
||||||
children,
|
children,
|
||||||
...moduleGroup(children, modules)
|
...moduleGroup(
|
||||||
|
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
||||||
|
(children),
|
||||||
|
modules
|
||||||
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2371,13 +2420,21 @@ const MODULES_GROUPERS = (type) => ({
|
||||||
createGroup: (key, children, modules) => ({
|
createGroup: (key, children, modules) => ({
|
||||||
type: "hidden modules",
|
type: "hidden modules",
|
||||||
filteredChildren: children.length,
|
filteredChildren: children.length,
|
||||||
...moduleGroup(children, modules)
|
...moduleGroup(
|
||||||
|
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
||||||
|
(children),
|
||||||
|
modules
|
||||||
|
)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/** @typedef {Record<string, (groupConfigs: GroupConfig<KnownStatsModuleReason, TODO>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>} ModuleReasonsGroupers */
|
/**
|
||||||
|
* @typedef {{
|
||||||
|
* groupReasonsByOrigin: (groupConfigs: GroupConfig<KnownStatsModuleReason, BaseGroup & { module: string, children: KnownStatsModuleReason[], active: boolean }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void
|
||||||
|
* }} ModuleReasonsGroupers
|
||||||
|
*/
|
||||||
|
|
||||||
/** @type {ModuleReasonsGroupers} */
|
/** @type {ModuleReasonsGroupers} */
|
||||||
const MODULE_REASONS_GROUPERS = {
|
const MODULE_REASONS_GROUPERS = {
|
||||||
|
@ -2394,7 +2451,17 @@ const MODULE_REASONS_GROUPERS = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {Record<string, AssetsGroupers | ModulesGroupers | ModuleReasonsGroupers>} */
|
/**
|
||||||
|
* @type {{
|
||||||
|
* "compilation.assets": AssetsGroupers,
|
||||||
|
* "asset.related": AssetsGroupers,
|
||||||
|
* "compilation.modules": ModulesGroupers,
|
||||||
|
* "chunk.modules": ModulesGroupers,
|
||||||
|
* "chunk.rootModules": ModulesGroupers,
|
||||||
|
* "module.modules": ModulesGroupers,
|
||||||
|
* "module.reasons": ModuleReasonsGroupers,
|
||||||
|
* }}
|
||||||
|
*/
|
||||||
const RESULT_GROUPERS = {
|
const RESULT_GROUPERS = {
|
||||||
"compilation.assets": ASSETS_GROUPERS,
|
"compilation.assets": ASSETS_GROUPERS,
|
||||||
"asset.related": ASSETS_GROUPERS,
|
"asset.related": ASSETS_GROUPERS,
|
||||||
|
@ -2460,7 +2527,14 @@ const sortByField = (field) => {
|
||||||
return sortFn;
|
return sortFn;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {Record<string, (comparators: Comparator<Asset>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>} */
|
/**
|
||||||
|
* @typedef {{
|
||||||
|
* assetsSort: (comparators: Comparator<Asset>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
||||||
|
* _: (comparators: Comparator<Asset>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void
|
||||||
|
* }} AssetSorters
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {AssetSorters} */
|
||||||
const ASSET_SORTERS = {
|
const ASSET_SORTERS = {
|
||||||
assetsSort: (comparators, context, { assetsSort }) => {
|
assetsSort: (comparators, context, { assetsSort }) => {
|
||||||
comparators.push(sortByField(assetsSort));
|
comparators.push(sortByField(assetsSort));
|
||||||
|
@ -2470,7 +2544,16 @@ const ASSET_SORTERS = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {Record<string, Record<string, (comparators: Comparator<TODO>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>>} */
|
/**
|
||||||
|
* @type {{
|
||||||
|
* "compilation.chunks": { chunksSort: (comparators: Comparator<Chunk>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
|
||||||
|
* "compilation.modules": { modulesSort: (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
|
||||||
|
* "chunk.modules": { chunkModulesSort: (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
|
||||||
|
* "module.modules": { nestedModulesSort: (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
|
||||||
|
* "compilation.assets": AssetSorters,
|
||||||
|
* "asset.related": AssetSorters,
|
||||||
|
* }}
|
||||||
|
*/
|
||||||
const RESULT_SORTERS = {
|
const RESULT_SORTERS = {
|
||||||
"compilation.chunks": {
|
"compilation.chunks": {
|
||||||
chunksSort: (comparators, context, { chunksSort }) => {
|
chunksSort: (comparators, context, { chunksSort }) => {
|
||||||
|
@ -2498,9 +2581,14 @@ const RESULT_SORTERS = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T
|
* @template T
|
||||||
* @param {Record<string, Record<string, T>>} config the config see above
|
* @typedef {T extends Record<string, Record<string, infer F>> ? F : never} ExtractFunction
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template {Record<string, Record<string, EXPECTED_ANY>>} T
|
||||||
|
* @param {T} config the config see above
|
||||||
* @param {NormalizedStatsOptions} options stats options
|
* @param {NormalizedStatsOptions} options stats options
|
||||||
* @param {(hookFor: string, fn: T) => void} fn handler function called for every active line in config
|
* @param {(hookFor: keyof T, fn: ExtractFunction<T>) => void} fn handler function called for every active line in config
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const iterateConfig = (config, options, fn) => {
|
const iterateConfig = (config, options, fn) => {
|
||||||
|
@ -2594,18 +2682,13 @@ class DefaultStatsFactoryPlugin {
|
||||||
* @param {NormalizedStatsOptions} options stats options
|
* @param {NormalizedStatsOptions} options stats options
|
||||||
*/
|
*/
|
||||||
(stats, options) => {
|
(stats, options) => {
|
||||||
iterateConfig(
|
iterateConfig(SIMPLE_EXTRACTORS, options, (hookFor, fn) => {
|
||||||
/** @type {TODO} */
|
|
||||||
(SIMPLE_EXTRACTORS),
|
|
||||||
options,
|
|
||||||
(hookFor, fn) => {
|
|
||||||
stats.hooks.extract
|
stats.hooks.extract
|
||||||
.for(hookFor)
|
.for(hookFor)
|
||||||
.tap(PLUGIN_NAME, (obj, data, ctx) =>
|
.tap(PLUGIN_NAME, (obj, data, ctx) =>
|
||||||
fn(obj, data, ctx, options, stats)
|
fn(obj, data, ctx, options, stats)
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
iterateConfig(FILTER, options, (hookFor, fn) => {
|
iterateConfig(FILTER, options, (hookFor, fn) => {
|
||||||
stats.hooks.filter
|
stats.hooks.filter
|
||||||
.for(hookFor)
|
.for(hookFor)
|
||||||
|
@ -2634,18 +2717,13 @@ class DefaultStatsFactoryPlugin {
|
||||||
fn(comparators, ctx, options)
|
fn(comparators, ctx, options)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
iterateConfig(
|
iterateConfig(RESULT_GROUPERS, options, (hookFor, fn) => {
|
||||||
/** @type {TODO} */
|
|
||||||
(RESULT_GROUPERS),
|
|
||||||
options,
|
|
||||||
(hookFor, fn) => {
|
|
||||||
stats.hooks.groupResults
|
stats.hooks.groupResults
|
||||||
.for(hookFor)
|
.for(hookFor)
|
||||||
.tap(PLUGIN_NAME, (groupConfigs, ctx) =>
|
.tap(PLUGIN_NAME, (groupConfigs, ctx) =>
|
||||||
fn(groupConfigs, ctx, options)
|
fn(groupConfigs, ctx, options)
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
for (const key of Object.keys(ITEM_NAMES)) {
|
for (const key of Object.keys(ITEM_NAMES)) {
|
||||||
const itemName = ITEM_NAMES[key];
|
const itemName = ITEM_NAMES[key];
|
||||||
stats.hooks.getItemName.for(key).tap(PLUGIN_NAME, () => itemName);
|
stats.hooks.getItemName.for(key).tap(PLUGIN_NAME, () => itemName);
|
||||||
|
@ -2667,7 +2745,7 @@ class DefaultStatsFactoryPlugin {
|
||||||
*/
|
*/
|
||||||
(comp, { _index: idx }) => {
|
(comp, { _index: idx }) => {
|
||||||
const children =
|
const children =
|
||||||
/** @type {TODO} */
|
/** @type {StatsValue[]} */
|
||||||
(options.children);
|
(options.children);
|
||||||
if (idx < children.length) {
|
if (idx < children.length) {
|
||||||
return compilation.createStatsFactory(
|
return compilation.createStatsFactory(
|
||||||
|
|
|
@ -44,8 +44,8 @@ const smartGrouping = require("../util/smartGrouping");
|
||||||
/**
|
/**
|
||||||
* @typedef {object} KnownStatsFactoryContext
|
* @typedef {object} KnownStatsFactoryContext
|
||||||
* @property {string} type
|
* @property {string} type
|
||||||
* @property {(path: string) => string} makePathsRelative
|
|
||||||
* @property {Compilation} compilation
|
* @property {Compilation} compilation
|
||||||
|
* @property {(path: string) => string} makePathsRelative
|
||||||
* @property {Set<Module>} rootModules
|
* @property {Set<Module>} rootModules
|
||||||
* @property {Map<string, Chunk[]>} compilationFileToChunks
|
* @property {Map<string, Chunk[]>} compilationFileToChunks
|
||||||
* @property {Map<string, Chunk[]>} compilationAuxiliaryFileToChunks
|
* @property {Map<string, Chunk[]>} compilationAuxiliaryFileToChunks
|
||||||
|
@ -70,10 +70,10 @@ const smartGrouping = require("../util/smartGrouping");
|
||||||
* @typedef {T extends ChunkGroupInfoWithName[] ? Record<string, StatsObject<ChunkGroupInfoWithName, F>> : T extends (infer V)[] ? StatsObject<V, F>[] : StatsObject<T, F>} CreatedObject
|
* @typedef {T extends ChunkGroupInfoWithName[] ? Record<string, StatsObject<ChunkGroupInfoWithName, F>> : T extends (infer V)[] ? StatsObject<V, F>[] : StatsObject<T, F>} CreatedObject
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {TODO} ObjectForExtract */
|
||||||
/** @typedef {TODO} FactoryData */
|
/** @typedef {TODO} FactoryData */
|
||||||
/** @typedef {TODO} FactoryDataItem */
|
/** @typedef {TODO} FactoryDataItem */
|
||||||
/** @typedef {TODO} Result */
|
/** @typedef {TODO} Result */
|
||||||
/** @typedef {Record<string, TODO>} ObjectForExtract */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} StatsFactoryHooks
|
* @typedef {object} StatsFactoryHooks
|
||||||
|
|
|
@ -13,52 +13,53 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T
|
* @template I
|
||||||
* @template R
|
* @template G
|
||||||
* @typedef {object} GroupConfig
|
* @typedef {object} GroupConfig
|
||||||
* @property {(item: T) => string[] | undefined} getKeys
|
* @property {(item: I) => string[] | undefined} getKeys
|
||||||
* @property {(key: string, children: (R | T)[], items: T[]) => R} createGroup
|
* @property {(name: string, items: I[]) => GroupOptions=} getOptions
|
||||||
* @property {(name: string, items: T[]) => GroupOptions=} getOptions
|
* @property {(key: string, children: I[], items: I[]) => G} createGroup
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T, R
|
* @template I
|
||||||
* @typedef {Set<Group<T, R>>} Groups
|
* @template G
|
||||||
|
* @typedef {{ config: GroupConfig<I, G>, name: string, alreadyGrouped: boolean, items: Items<I, G> | undefined }} Group
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T, R
|
* @template I, G
|
||||||
* @typedef {Set<ItemWithGroups<T, R>>} Items
|
* @typedef {Set<Group<I, G>>} Groups
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T
|
* @template I
|
||||||
* @template R
|
* @template G
|
||||||
* @typedef {object} ItemWithGroups
|
* @typedef {object} ItemWithGroups
|
||||||
* @property {T} item
|
* @property {I} item
|
||||||
* @property {Groups<T, R>} groups
|
* @property {Groups<I, G>} groups
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T
|
* @template T, G
|
||||||
* @template R
|
* @typedef {Set<ItemWithGroups<T, G>>} Items
|
||||||
* @typedef {{ config: GroupConfig<T, R>, name: string, alreadyGrouped: boolean, items: Items<T, R> | undefined }} Group
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T
|
* @template I
|
||||||
|
* @template G
|
||||||
* @template R
|
* @template R
|
||||||
* @param {T[]} items the list of items
|
* @param {I[]} items the list of items
|
||||||
* @param {GroupConfig<T, R>[]} groupConfigs configuration
|
* @param {GroupConfig<I, G>[]} groupConfigs configuration
|
||||||
* @returns {(R | T)[]} grouped items
|
* @returns {(I | G)[]} grouped items
|
||||||
*/
|
*/
|
||||||
const smartGrouping = (items, groupConfigs) => {
|
const smartGrouping = (items, groupConfigs) => {
|
||||||
/** @type {Items<T, R>} */
|
/** @type {Items<I, G>} */
|
||||||
const itemsWithGroups = new Set();
|
const itemsWithGroups = new Set();
|
||||||
/** @type {Map<string, Group<T, R>>} */
|
/** @type {Map<string, Group<I, G>>} */
|
||||||
const allGroups = new Map();
|
const allGroups = new Map();
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
/** @type {Groups<T, R>} */
|
/** @type {Groups<I, G>} */
|
||||||
const groups = new Set();
|
const groups = new Set();
|
||||||
for (let i = 0; i < groupConfigs.length; i++) {
|
for (let i = 0; i < groupConfigs.length; i++) {
|
||||||
const groupConfig = groupConfigs[i];
|
const groupConfig = groupConfigs[i];
|
||||||
|
@ -87,9 +88,10 @@ const smartGrouping = (items, groupConfigs) => {
|
||||||
groups
|
groups
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Items<T, R>} itemsWithGroups input items with groups
|
* @param {Items<I, G>} itemsWithGroups input items with groups
|
||||||
* @returns {(T | R)[]} groups items
|
* @returns {(I | G)[]} groups items
|
||||||
*/
|
*/
|
||||||
const runGrouping = (itemsWithGroups) => {
|
const runGrouping = (itemsWithGroups) => {
|
||||||
const totalSize = itemsWithGroups.size;
|
const totalSize = itemsWithGroups.size;
|
||||||
|
@ -104,7 +106,7 @@ const smartGrouping = (items, groupConfigs) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** @type {Map<Group<T, R>, { items: Items<T, R>, options: GroupOptions | false | undefined, used: boolean }>} */
|
/** @type {Map<Group<I, G>, { items: Items<I, G>, options: GroupOptions | false | undefined, used: boolean }>} */
|
||||||
const groupMap = new Map();
|
const groupMap = new Map();
|
||||||
for (const group of allGroups.values()) {
|
for (const group of allGroups.values()) {
|
||||||
if (group.items) {
|
if (group.items) {
|
||||||
|
@ -117,13 +119,15 @@ const smartGrouping = (items, groupConfigs) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** @type {(T | R)[]} */
|
/** @type {(I | G)[]} */
|
||||||
const results = [];
|
const results = [];
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/** @type {Group<T, R> | undefined} */
|
/** @type {Group<I, G> | undefined} */
|
||||||
let bestGroup;
|
let bestGroup;
|
||||||
let bestGroupSize = -1;
|
let bestGroupSize = -1;
|
||||||
|
/** @type {Items<I, G> | undefined} */
|
||||||
let bestGroupItems;
|
let bestGroupItems;
|
||||||
|
/** @type {GroupOptions | false | undefined} */
|
||||||
let bestGroupOptions;
|
let bestGroupOptions;
|
||||||
for (const [group, state] of groupMap) {
|
for (const [group, state] of groupMap) {
|
||||||
const { items, used } = state;
|
const { items, used } = state;
|
||||||
|
@ -202,8 +206,9 @@ const smartGrouping = (items, groupConfigs) => {
|
||||||
bestGroup.alreadyGrouped = true;
|
bestGroup.alreadyGrouped = true;
|
||||||
const children = groupChildren ? runGrouping(items) : allItems;
|
const children = groupChildren ? runGrouping(items) : allItems;
|
||||||
bestGroup.alreadyGrouped = false;
|
bestGroup.alreadyGrouped = false;
|
||||||
|
results.push(
|
||||||
results.push(groupConfig.createGroup(key, children, allItems));
|
groupConfig.createGroup(key, /** @type {I[]} */ (children), allItems)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
for (const { item } of itemsWithGroups) {
|
for (const { item } of itemsWithGroups) {
|
||||||
results.push(item);
|
results.push(item);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5179,7 +5179,17 @@
|
||||||
},
|
},
|
||||||
"children": {
|
"children": {
|
||||||
"description": "Add children information.",
|
"description": "Add children information.",
|
||||||
"type": "boolean"
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/StatsValue"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/StatsValue"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"chunkGroupAuxiliary": {
|
"chunkGroupAuxiliary": {
|
||||||
"description": "Display auxiliary assets in chunk groups.",
|
"description": "Display auxiliary assets in chunk groups.",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -561,6 +561,35 @@ ERROR in webpack error
|
||||||
error cause (webpack x.x.x) compiled with 6 errors and 6 warnings in X ms"
|
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 1`] = `
|
||||||
|
"asset child1.js X bytes [emitted]
|
||||||
|
asset child2.js X bytes [emitted]
|
||||||
|
asset parent.js X bytes [emitted] (name: parent)
|
||||||
|
./parent.js X bytes [built] [code generated]
|
||||||
|
PublicPath: auto
|
||||||
|
asset child1.js X bytes {12} [cached] (name: child1)
|
||||||
|
Entrypoint child1 = child1.js
|
||||||
|
chunk {12} (runtime: child1) child1.js (child1) X bytes [entry] [rendered]
|
||||||
|
> ./child1 child1
|
||||||
|
./child1.js [84] X bytes {12} [depth 0] [built] [code generated]
|
||||||
|
[no exports used]
|
||||||
|
ModuleConcatenation bailout: Module is not an ECMAScript module
|
||||||
|
entry ./child1 child1
|
||||||
|
|
||||||
|
Child first compiled successfully
|
||||||
|
|
||||||
|
1 asset
|
||||||
|
1 module
|
||||||
|
Child second compiled successfully
|
||||||
|
|
||||||
|
WARNING in configuration
|
||||||
|
The 'mode' option has not been set, webpack will fallback to 'production' for this value.
|
||||||
|
Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
|
||||||
|
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
|
||||||
|
|
||||||
|
webpack x.x.x compiled with 1 warning in X ms"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`StatsTestCases should print correct stats for child-compiler-apply-entry-option 1`] = `
|
exports[`StatsTestCases should print correct stats for child-compiler-apply-entry-option 1`] = `
|
||||||
"asset child.js X bytes [emitted]
|
"asset child.js X bytes [emitted]
|
||||||
asset parent.js X bytes [emitted] (name: parent)
|
asset parent.js X bytes [emitted] (name: parent)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
/** @typedef {import("webpack").CodeGenerationResults} CodeGenerationResults */
|
||||||
/** @typedef {import("webpack-sources").Source} Source */
|
/** @typedef {import("webpack-sources").Source} Source */
|
||||||
|
|
||||||
/** @type {import("../../../../").Configuration} */
|
/** @type {import("../../../../").Configuration} */
|
||||||
|
@ -28,10 +29,9 @@ module.exports = {
|
||||||
() => {
|
() => {
|
||||||
for (const module of compilation.modules) {
|
for (const module of compilation.modules) {
|
||||||
if (module.type === "json") {
|
if (module.type === "json") {
|
||||||
const { sources } = compilation.codeGenerationResults.get(
|
const { sources } =
|
||||||
module,
|
/** @type {CodeGenerationResults} */
|
||||||
"main"
|
(compilation.codeGenerationResults).get(module, "main");
|
||||||
);
|
|
||||||
const source =
|
const source =
|
||||||
/** @type {Source} */
|
/** @type {Source} */
|
||||||
(sources.get("javascript"));
|
(sources.get("javascript"));
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
it("should `additionalAssets` work", () => {
|
||||||
|
const { info } = __STATS__.assets.find(item => item.name === "file.txt");
|
||||||
|
expect(info.new).toBe(true);
|
||||||
|
expect(info.additional).toBe(true);
|
||||||
|
expect(info.additionalAgain).toBe(true);
|
||||||
|
|
||||||
|
const { info: info1 } = __STATS__.assets.find(item => item.name === "file1.txt");
|
||||||
|
expect(info1.new).toBe(true);
|
||||||
|
expect(info1.additional).toBeUndefined();
|
||||||
|
});
|
|
@ -0,0 +1,86 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const newName = "file.txt";
|
||||||
|
|
||||||
|
/** @type {import("../../../../").Configuration} */
|
||||||
|
module.exports = {
|
||||||
|
output: {
|
||||||
|
assetModuleFilename: "images/[name][ext]"
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
{
|
||||||
|
apply: (compiler) => {
|
||||||
|
const PLUGIN_NAME = "TestPlugin";
|
||||||
|
|
||||||
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
||||||
|
compilation.hooks.processAssets.tap(
|
||||||
|
{
|
||||||
|
name: PLUGIN_NAME,
|
||||||
|
additionalAssets: (assets) => {
|
||||||
|
for (const name of Object.keys(assets)) {
|
||||||
|
if (newName !== name) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
compilation.updateAsset(name, assets[name], {
|
||||||
|
additional: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
compilation.emitAsset(
|
||||||
|
newName,
|
||||||
|
new compiler.webpack.sources.RawSource("text"),
|
||||||
|
{
|
||||||
|
new: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apply: (compiler) => {
|
||||||
|
const PLUGIN_NAME = "TestPlugin1";
|
||||||
|
|
||||||
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
||||||
|
compilation.hooks.processAssets.tap(
|
||||||
|
{
|
||||||
|
name: PLUGIN_NAME,
|
||||||
|
additionalAssets: false
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
compilation.emitAsset(
|
||||||
|
"file1.txt",
|
||||||
|
new compiler.webpack.sources.RawSource("text"),
|
||||||
|
{
|
||||||
|
new: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
apply: (compiler) => {
|
||||||
|
const PLUGIN_NAME = "TestPlugin2";
|
||||||
|
|
||||||
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
||||||
|
compilation.hooks.processAssets.tap(
|
||||||
|
{
|
||||||
|
name: PLUGIN_NAME,
|
||||||
|
additionalAssets: true
|
||||||
|
},
|
||||||
|
(assets) => {
|
||||||
|
compilation.updateAsset(newName, assets[newName], {
|
||||||
|
additionalAgain: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
|
@ -0,0 +1,36 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/** @typedef {import("../../../").Configuration} Configuration */
|
||||||
|
/** @typedef {import("../../../").Compiler} Compiler */
|
||||||
|
|
||||||
|
var EntryOptionPlugin = require("../../../").EntryOptionPlugin;
|
||||||
|
var getNormalizedWebpackOptions = require("../../../").config.getNormalizedWebpackOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use the static method in EntryOptionPlugin to
|
||||||
|
* apply entry option for the child compiler.
|
||||||
|
*/
|
||||||
|
module.exports = class TestApplyEntryOptionPlugin {
|
||||||
|
/**
|
||||||
|
* @param {Configuration} options options
|
||||||
|
* @param {string} name name of a child compiler
|
||||||
|
*/
|
||||||
|
constructor(options, name = "TestApplyEntryOptionPlugin") {
|
||||||
|
this.options = getNormalizedWebpackOptions(options);
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Compiler} compiler compiler
|
||||||
|
*/
|
||||||
|
apply(compiler) {
|
||||||
|
compiler.hooks.make.tapAsync(
|
||||||
|
"TestApplyEntryOptionPlugin",
|
||||||
|
(compilation, cb) => {
|
||||||
|
const child = compilation.createChildCompiler(this.name);
|
||||||
|
EntryOptionPlugin.applyEntryOption(child, compilation.compiler.context, this.options.entry);
|
||||||
|
child.runAsChild(/** @type {EXPECTED_ANY} */ (cb))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const TestApplyEntryOptionPlugin = require("./TestApplyEntryOptionPlugin");
|
||||||
|
|
||||||
|
/** @type {import("../../../").Configuration} */
|
||||||
|
module.exports = {
|
||||||
|
entry: {
|
||||||
|
parent: "./parent"
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
filename: "[name].js"
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new TestApplyEntryOptionPlugin(
|
||||||
|
{
|
||||||
|
entry: {
|
||||||
|
child1: "./child1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"first"
|
||||||
|
),
|
||||||
|
new TestApplyEntryOptionPlugin(
|
||||||
|
{
|
||||||
|
entry: {
|
||||||
|
child2: "./child2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"second"
|
||||||
|
)
|
||||||
|
],
|
||||||
|
stats: {
|
||||||
|
children: [{ hash: false, modules: true, entrypoints: true }, "minimal"]
|
||||||
|
}
|
||||||
|
};
|
|
@ -2228,7 +2228,7 @@ declare class Compilation {
|
||||||
moduleMemCaches2?: Map<Module, WeakTupleMap<any[], any>>;
|
moduleMemCaches2?: Map<Module, WeakTupleMap<any[], any>>;
|
||||||
moduleGraph: ModuleGraph;
|
moduleGraph: ModuleGraph;
|
||||||
chunkGraph: ChunkGraph;
|
chunkGraph: ChunkGraph;
|
||||||
codeGenerationResults: CodeGenerationResults;
|
codeGenerationResults?: CodeGenerationResults;
|
||||||
processDependenciesQueue: AsyncQueue<Module, Module, Module>;
|
processDependenciesQueue: AsyncQueue<Module, Module, Module>;
|
||||||
addModuleQueue: AsyncQueue<Module, string, Module>;
|
addModuleQueue: AsyncQueue<Module, string, Module>;
|
||||||
factorizeQueue: AsyncQueue<
|
factorizeQueue: AsyncQueue<
|
||||||
|
@ -2262,7 +2262,7 @@ declare class Compilation {
|
||||||
warnings: Error[];
|
warnings: Error[];
|
||||||
children: Compilation[];
|
children: Compilation[];
|
||||||
logging: Map<string, LogEntry[]>;
|
logging: Map<string, LogEntry[]>;
|
||||||
dependencyFactories: Map<DepConstructor, ModuleFactory>;
|
dependencyFactories: Map<DependencyConstructor, ModuleFactory>;
|
||||||
dependencyTemplates: DependencyTemplates;
|
dependencyTemplates: DependencyTemplates;
|
||||||
childrenCounters: Record<string, number>;
|
childrenCounters: Record<string, number>;
|
||||||
usedChunkIds: null | Set<string | number>;
|
usedChunkIds: null | Set<string | number>;
|
||||||
|
@ -2314,6 +2314,17 @@ declare class Compilation {
|
||||||
callback: (err?: null | WebpackError, result?: null | Module) => void
|
callback: (err?: null | WebpackError, result?: null | Module) => void
|
||||||
): void;
|
): void;
|
||||||
processModuleDependenciesNonRecursive(module: Module): void;
|
processModuleDependenciesNonRecursive(module: Module): void;
|
||||||
|
factorizeModule(
|
||||||
|
options: FactorizeModuleOptions & { factoryResult?: false },
|
||||||
|
callback: (err?: null | WebpackError, result?: null | Module) => void
|
||||||
|
): void;
|
||||||
|
factorizeModule(
|
||||||
|
options: FactorizeModuleOptions & { factoryResult: true },
|
||||||
|
callback: (
|
||||||
|
err?: null | WebpackError,
|
||||||
|
result?: null | ModuleFactoryResult
|
||||||
|
) => void
|
||||||
|
): void;
|
||||||
handleModuleCreation(
|
handleModuleCreation(
|
||||||
__0: HandleModuleCreationOptions,
|
__0: HandleModuleCreationOptions,
|
||||||
callback: (err?: null | WebpackError, result?: null | Module) => void
|
callback: (err?: null | WebpackError, result?: null | Module) => void
|
||||||
|
@ -2482,22 +2493,12 @@ declare class Compilation {
|
||||||
executeModule(
|
executeModule(
|
||||||
module: Module,
|
module: Module,
|
||||||
options: ExecuteModuleOptions,
|
options: ExecuteModuleOptions,
|
||||||
callback: (err: null | WebpackError, result?: ExecuteModuleResult) => void
|
|
||||||
): void;
|
|
||||||
checkConstraints(): void;
|
|
||||||
factorizeModule: {
|
|
||||||
(
|
|
||||||
options: FactorizeModuleOptions & { factoryResult?: false },
|
|
||||||
callback: (err?: null | WebpackError, result?: null | Module) => void
|
|
||||||
): void;
|
|
||||||
(
|
|
||||||
options: FactorizeModuleOptions & { factoryResult: true },
|
|
||||||
callback: (
|
callback: (
|
||||||
err?: null | WebpackError,
|
err?: null | WebpackError,
|
||||||
result?: ModuleFactoryResult
|
result?: null | ExecuteModuleResult
|
||||||
) => void
|
) => void
|
||||||
): void;
|
): void;
|
||||||
};
|
checkConstraints(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add additional assets to the compilation.
|
* Add additional assets to the compilation.
|
||||||
|
@ -3123,13 +3124,13 @@ declare interface Configuration {
|
||||||
| boolean
|
| boolean
|
||||||
| StatsOptions
|
| StatsOptions
|
||||||
| "none"
|
| "none"
|
||||||
| "verbose"
|
|
||||||
| "summary"
|
| "summary"
|
||||||
| "errors-only"
|
| "errors-only"
|
||||||
| "errors-warnings"
|
| "errors-warnings"
|
||||||
| "minimal"
|
| "minimal"
|
||||||
| "normal"
|
| "normal"
|
||||||
| "detailed";
|
| "detailed"
|
||||||
|
| "verbose";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Environment to build for. An array of environments to build for all of them when possible.
|
* Environment to build for. An array of environments to build for all of them when possible.
|
||||||
|
@ -3781,9 +3782,6 @@ declare class DelegatedPlugin {
|
||||||
*/
|
*/
|
||||||
apply(compiler: Compiler): void;
|
apply(compiler: Compiler): void;
|
||||||
}
|
}
|
||||||
declare interface DepConstructor {
|
|
||||||
new (...args: any[]): Dependency;
|
|
||||||
}
|
|
||||||
declare abstract class DependenciesBlock {
|
declare abstract class DependenciesBlock {
|
||||||
dependencies: Dependency[];
|
dependencies: Dependency[];
|
||||||
blocks: AsyncDependenciesBlock[];
|
blocks: AsyncDependenciesBlock[];
|
||||||
|
@ -6012,8 +6010,8 @@ declare interface GotHandler<T> {
|
||||||
}
|
}
|
||||||
declare interface GroupConfig<T, R> {
|
declare interface GroupConfig<T, R> {
|
||||||
getKeys: (item: T) => undefined | string[];
|
getKeys: (item: T) => undefined | string[];
|
||||||
createGroup: (key: string, children: (T | R)[], items: T[]) => R;
|
|
||||||
getOptions?: (name: string, items: T[]) => GroupOptions;
|
getOptions?: (name: string, items: T[]) => GroupOptions;
|
||||||
|
createGroup: (key: string, children: T[], items: T[]) => R;
|
||||||
}
|
}
|
||||||
declare interface GroupOptions {
|
declare interface GroupOptions {
|
||||||
groupChildren?: boolean;
|
groupChildren?: boolean;
|
||||||
|
@ -6443,7 +6441,7 @@ declare interface InfrastructureLogging {
|
||||||
/**
|
/**
|
||||||
* Log level.
|
* Log level.
|
||||||
*/
|
*/
|
||||||
level?: "none" | "error" | "warn" | "info" | "log" | "verbose";
|
level?: "none" | "verbose" | "error" | "warn" | "info" | "log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stream used for logging output. Defaults to process.stderr. This option is only used when no custom console is provided.
|
* Stream used for logging output. Defaults to process.stderr. This option is only used when no custom console is provided.
|
||||||
|
@ -6461,7 +6459,7 @@ type InfrastructureLoggingNormalizedWithDefaults = InfrastructureLogging & {
|
||||||
rows?: number;
|
rows?: number;
|
||||||
};
|
};
|
||||||
level: NonNullable<
|
level: NonNullable<
|
||||||
undefined | "none" | "error" | "warn" | "info" | "log" | "verbose"
|
undefined | "none" | "verbose" | "error" | "warn" | "info" | "log"
|
||||||
>;
|
>;
|
||||||
debug: NonNullable<
|
debug: NonNullable<
|
||||||
| undefined
|
| undefined
|
||||||
|
@ -8667,7 +8665,7 @@ declare interface KnownNormalizedStatsOptions {
|
||||||
modulesSpace: number;
|
modulesSpace: number;
|
||||||
chunkModulesSpace: number;
|
chunkModulesSpace: number;
|
||||||
nestedModulesSpace: number;
|
nestedModulesSpace: number;
|
||||||
logging: false | "none" | "error" | "warn" | "info" | "log" | "verbose";
|
logging: false | "none" | "verbose" | "error" | "warn" | "info" | "log";
|
||||||
loggingDebug: ((value: string) => boolean)[];
|
loggingDebug: ((value: string) => boolean)[];
|
||||||
loggingTrace: boolean;
|
loggingTrace: boolean;
|
||||||
}
|
}
|
||||||
|
@ -8792,8 +8790,8 @@ declare interface KnownStatsError {
|
||||||
}
|
}
|
||||||
declare interface KnownStatsFactoryContext {
|
declare interface KnownStatsFactoryContext {
|
||||||
type: string;
|
type: string;
|
||||||
makePathsRelative: (path: string) => string;
|
|
||||||
compilation: Compilation;
|
compilation: Compilation;
|
||||||
|
makePathsRelative: (path: string) => string;
|
||||||
rootModules: Set<Module>;
|
rootModules: Set<Module>;
|
||||||
compilationFileToChunks: Map<string, Chunk[]>;
|
compilationFileToChunks: Map<string, Chunk[]>;
|
||||||
compilationAuxiliaryFileToChunks: Map<string, Chunk[]>;
|
compilationAuxiliaryFileToChunks: Map<string, Chunk[]>;
|
||||||
|
@ -11437,9 +11435,6 @@ declare interface ObjectEncodingOptions {
|
||||||
| "binary"
|
| "binary"
|
||||||
| "hex";
|
| "hex";
|
||||||
}
|
}
|
||||||
declare interface ObjectForExtract {
|
|
||||||
[index: string]: any;
|
|
||||||
}
|
|
||||||
declare interface ObjectSerializer {
|
declare interface ObjectSerializer {
|
||||||
serialize: (value: any, context: ObjectSerializerContext) => void;
|
serialize: (value: any, context: ObjectSerializerContext) => void;
|
||||||
deserialize: (context: ObjectDeserializerContext) => any;
|
deserialize: (context: ObjectDeserializerContext) => any;
|
||||||
|
@ -13091,7 +13086,7 @@ declare class PrefetchPlugin {
|
||||||
apply(compiler: Compiler): void;
|
apply(compiler: Compiler): void;
|
||||||
}
|
}
|
||||||
declare class PrefixSource extends Source {
|
declare class PrefixSource extends Source {
|
||||||
constructor(prefix: string, source: string | Source | Buffer);
|
constructor(prefix: string, source: string | Buffer | Source);
|
||||||
getPrefix(): string;
|
getPrefix(): string;
|
||||||
original(): Source;
|
original(): Source;
|
||||||
streamChunks(
|
streamChunks(
|
||||||
|
@ -13135,7 +13130,7 @@ type ProblemType =
|
||||||
| "multiple-values-unexpected"
|
| "multiple-values-unexpected"
|
||||||
| "invalid-value";
|
| "invalid-value";
|
||||||
declare interface ProcessAssetsAdditionalOptions {
|
declare interface ProcessAssetsAdditionalOptions {
|
||||||
additionalAssets?: any;
|
additionalAssets?: boolean | ((assets: CompilationAssets) => void);
|
||||||
}
|
}
|
||||||
declare class Profiler {
|
declare class Profiler {
|
||||||
constructor(inspector: Inspector);
|
constructor(inspector: Inspector);
|
||||||
|
@ -16787,9 +16782,7 @@ declare abstract class StatsFactory {
|
||||||
}
|
}
|
||||||
type StatsFactoryContext = KnownStatsFactoryContext & Record<string, any>;
|
type StatsFactoryContext = KnownStatsFactoryContext & Record<string, any>;
|
||||||
declare interface StatsFactoryHooks {
|
declare interface StatsFactoryHooks {
|
||||||
extract: HookMap<
|
extract: HookMap<SyncBailHook<[any, any, StatsFactoryContext], void>>;
|
||||||
SyncBailHook<[ObjectForExtract, any, StatsFactoryContext], void>
|
|
||||||
>;
|
|
||||||
filter: HookMap<
|
filter: HookMap<
|
||||||
SyncBailHook<[any, StatsFactoryContext, number, number], boolean | void>
|
SyncBailHook<[any, StatsFactoryContext, number, number], boolean | void>
|
||||||
>;
|
>;
|
||||||
|
@ -16877,7 +16870,18 @@ declare interface StatsOptions {
|
||||||
/**
|
/**
|
||||||
* Add children information.
|
* Add children information.
|
||||||
*/
|
*/
|
||||||
children?: boolean;
|
children?:
|
||||||
|
| boolean
|
||||||
|
| StatsOptions
|
||||||
|
| "none"
|
||||||
|
| "summary"
|
||||||
|
| "errors-only"
|
||||||
|
| "errors-warnings"
|
||||||
|
| "minimal"
|
||||||
|
| "normal"
|
||||||
|
| "detailed"
|
||||||
|
| "verbose"
|
||||||
|
| StatsValue[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display auxiliary assets in chunk groups.
|
* Display auxiliary assets in chunk groups.
|
||||||
|
@ -17131,7 +17135,7 @@ declare interface StatsOptions {
|
||||||
/**
|
/**
|
||||||
* Add logging output.
|
* Add logging output.
|
||||||
*/
|
*/
|
||||||
logging?: boolean | "none" | "error" | "warn" | "info" | "log" | "verbose";
|
logging?: boolean | "none" | "verbose" | "error" | "warn" | "info" | "log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include debug logging of specified loggers (i. e. for plugins or loaders). Filters can be Strings, RegExps or Functions.
|
* Include debug logging of specified loggers (i. e. for plugins or loaders). Filters can be Strings, RegExps or Functions.
|
||||||
|
@ -17324,13 +17328,13 @@ type StatsValue =
|
||||||
| boolean
|
| boolean
|
||||||
| StatsOptions
|
| StatsOptions
|
||||||
| "none"
|
| "none"
|
||||||
| "verbose"
|
|
||||||
| "summary"
|
| "summary"
|
||||||
| "errors-only"
|
| "errors-only"
|
||||||
| "errors-warnings"
|
| "errors-warnings"
|
||||||
| "minimal"
|
| "minimal"
|
||||||
| "normal"
|
| "normal"
|
||||||
| "detailed";
|
| "detailed"
|
||||||
|
| "verbose";
|
||||||
declare interface StreamChunksOptions {
|
declare interface StreamChunksOptions {
|
||||||
source?: boolean;
|
source?: boolean;
|
||||||
finalSource?: boolean;
|
finalSource?: boolean;
|
||||||
|
@ -18870,11 +18874,12 @@ declare namespace exports {
|
||||||
WebpackOptionsNormalized,
|
WebpackOptionsNormalized,
|
||||||
WebpackPluginInstance,
|
WebpackPluginInstance,
|
||||||
ChunkGroup,
|
ChunkGroup,
|
||||||
|
AssetEmittedInfo,
|
||||||
Asset,
|
Asset,
|
||||||
AssetInfo,
|
AssetInfo,
|
||||||
EntryOptions,
|
EntryOptions,
|
||||||
PathData,
|
PathData,
|
||||||
AssetEmittedInfo,
|
CodeGenerationResults,
|
||||||
Entrypoint,
|
Entrypoint,
|
||||||
MultiCompilerOptions,
|
MultiCompilerOptions,
|
||||||
MultiConfiguration,
|
MultiConfiguration,
|
||||||
|
|
Loading…
Reference in New Issue