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.
|
||||
*/
|
||||
children?: boolean;
|
||||
children?: StatsValue[] | StatsValue;
|
||||
/**
|
||||
* Display auxiliary assets in chunk groups.
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,7 @@ const {
|
|||
/** @typedef {import("./Module")} Module */
|
||||
/** @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
|
||||
|
|
|
@ -140,6 +140,7 @@ const { isSourceEqual } = require("./util/source");
|
|||
*/
|
||||
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
||||
|
||||
/**
|
||||
* @callback Callback
|
||||
* @param {(WebpackError | null)=} err
|
||||
|
@ -148,33 +149,33 @@ const { isSourceEqual } = require("./util/source");
|
|||
|
||||
/**
|
||||
* @callback ModuleCallback
|
||||
* @param {(WebpackError | null)=} err
|
||||
* @param {(Module | null)=} result
|
||||
* @param {WebpackError | null=} err
|
||||
* @param {Module | null=} result
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback ModuleFactoryResultCallback
|
||||
* @param {(WebpackError | null)=} err
|
||||
* @param {ModuleFactoryResult=} result
|
||||
* @param {WebpackError | null=} err
|
||||
* @param {ModuleFactoryResult | null=} result
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback ModuleOrFactoryResultCallback
|
||||
* @param {(WebpackError | null)=} err
|
||||
* @param {Module | ModuleFactoryResult=} result
|
||||
* @callback ModuleOrModuleFactoryResultCallback
|
||||
* @param {WebpackError | null=} err
|
||||
* @param {Module | ModuleFactoryResult | null=} result
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback ExecuteModuleCallback
|
||||
* @param {WebpackError | null} err
|
||||
* @param {ExecuteModuleResult=} result
|
||||
* @param {WebpackError | null=} err
|
||||
* @param {ExecuteModuleResult | null=} result
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
/** @typedef {new (...args: EXPECTED_ANY[]) => Dependency} DepConstructor */
|
||||
/** @typedef {new (...args: EXPECTED_ANY[]) => Dependency} DependencyConstructor */
|
||||
|
||||
/** @typedef {Record<string, Source>} CompilationAssets */
|
||||
|
||||
|
@ -494,7 +495,7 @@ class Compilation {
|
|||
this._backCompat = compiler._backCompat;
|
||||
|
||||
const getNormalModuleLoader = () => deprecatedNormalModuleLoaderHook(this);
|
||||
/** @typedef {{ additionalAssets?: true | TODO }} ProcessAssetsAdditionalOptions */
|
||||
/** @typedef {{ additionalAssets?: boolean | ((assets: CompilationAssets) => void) }} ProcessAssetsAdditionalOptions */
|
||||
/** @type {AsyncSeriesHook<[CompilationAssets], ProcessAssetsAdditionalOptions>} */
|
||||
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();
|
||||
/** @type {ChunkGraph} */
|
||||
this.chunkGraph = /** @type {TODO} */ (undefined);
|
||||
/** @type {CodeGenerationResults} */
|
||||
this.codeGenerationResults = /** @type {TODO} */ (undefined);
|
||||
/** @type {CodeGenerationResults | undefined} */
|
||||
this.codeGenerationResults = undefined;
|
||||
|
||||
/** @type {AsyncQueue<Module, Module, Module>} */
|
||||
this.processDependenciesQueue = new AsyncQueue({
|
||||
|
@ -1183,7 +1184,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
this.children = [];
|
||||
/** @type {Map<string, LogEntry[]>} */
|
||||
this.logging = new Map();
|
||||
/** @type {Map<DepConstructor, ModuleFactory>} */
|
||||
/** @type {Map<DependencyConstructor, ModuleFactory>} */
|
||||
this.dependencyFactories = new Map();
|
||||
/** @type {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[]>>} */
|
||||
let dependencies;
|
||||
/** @type {DepConstructor} */
|
||||
/** @type {DependencyConstructor} */
|
||||
let factoryCacheKey;
|
||||
/** @type {ModuleFactory} */
|
||||
let factoryCacheKey2;
|
||||
|
@ -1819,7 +1820,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
const resourceIdent = dep.getResourceIdentifier();
|
||||
if (resourceIdent !== undefined && resourceIdent !== null) {
|
||||
const category = dep.category;
|
||||
const constructor = /** @type {DepConstructor} */ (dep.constructor);
|
||||
const constructor =
|
||||
/** @type {DependencyConstructor} */
|
||||
(dep.constructor);
|
||||
if (factoryCacheKey === constructor) {
|
||||
// Fast path 1: same constructor as prev item
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @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 {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")
|
||||
);
|
||||
}
|
||||
const Dep = /** @type {DepConstructor} */ (dependency.constructor);
|
||||
const Dep =
|
||||
/** @type {DependencyConstructor} */
|
||||
(dependency.constructor);
|
||||
const moduleFactory = this.dependencyFactories.get(Dep);
|
||||
if (!moduleFactory) {
|
||||
return callback(
|
||||
|
@ -2413,8 +2442,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
);
|
||||
} else {
|
||||
entryData[target].push(entry);
|
||||
for (const _key of Object.keys(options)) {
|
||||
const key = /** @type {keyof EntryOptions} */ (_key);
|
||||
for (const key_ of Object.keys(options)) {
|
||||
const key = /** @type {keyof EntryOptions} */ (key_);
|
||||
if (options[key] === undefined) continue;
|
||||
if (entryData.options[key] === options[key]) continue;
|
||||
if (
|
||||
|
@ -2425,10 +2454,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
continue;
|
||||
}
|
||||
if (entryData.options[key] === undefined) {
|
||||
/** @type {TODO} */
|
||||
(entryData.options)[key] =
|
||||
/** @type {NonNullable<EntryOptions[keyof EntryOptions]>} */
|
||||
(options[key]);
|
||||
/** @type {EntryOptions[keyof EntryOptions]} */
|
||||
(entryData.options[key]) = options[key];
|
||||
} else {
|
||||
return callback(
|
||||
new WebpackError(
|
||||
|
@ -3553,7 +3580,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|||
let statModulesGenerated = 0;
|
||||
const { chunkGraph, moduleGraph, dependencyTemplates, runtimeTemplate } =
|
||||
this;
|
||||
const results = this.codeGenerationResults;
|
||||
const results =
|
||||
/** @type {CodeGenerationResults} */
|
||||
(this.codeGenerationResults);
|
||||
/** @type {WebpackError[]} */
|
||||
const errors = [];
|
||||
/** @type {NotCodeGeneratedModules | undefined} */
|
||||
|
@ -3748,7 +3777,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|||
chunkGraph = this.chunkGraph,
|
||||
modules = this.modules,
|
||||
chunks = this.chunks,
|
||||
codeGenerationResults = this.codeGenerationResults,
|
||||
codeGenerationResults = /** @type {CodeGenerationResults} */ (
|
||||
this.codeGenerationResults
|
||||
),
|
||||
chunkGraphEntries = this._getChunkGraphEntries()
|
||||
} = {}) {
|
||||
const context = { chunkGraph, codeGenerationResults };
|
||||
|
@ -4565,7 +4596,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|||
chunk.updateHash(chunkHash, chunkGraph);
|
||||
this.hooks.chunkHash.call(chunk, chunkHash, {
|
||||
chunkGraph,
|
||||
codeGenerationResults: this.codeGenerationResults,
|
||||
codeGenerationResults:
|
||||
/** @type {CodeGenerationResults} */
|
||||
(this.codeGenerationResults),
|
||||
moduleGraph: this.moduleGraph,
|
||||
runtimeTemplate: this.runtimeTemplate
|
||||
});
|
||||
|
@ -4979,7 +5012,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|||
hash: /** @type {string} */ (this.hash),
|
||||
fullHash: /** @type {string} */ (this.fullHash),
|
||||
outputOptions,
|
||||
codeGenerationResults: this.codeGenerationResults,
|
||||
codeGenerationResults:
|
||||
/** @type {CodeGenerationResults} */
|
||||
(this.codeGenerationResults),
|
||||
moduleTemplates: this.moduleTemplates,
|
||||
dependencyTemplates: this.dependencyTemplates,
|
||||
chunkGraph: this.chunkGraph,
|
||||
|
@ -5637,19 +5672,6 @@ This prevents using hashes of each other and should be avoided.`);
|
|||
* @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
|
||||
const compilationPrototype = Compilation.prototype;
|
||||
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
const { DEFAULTS } = require("./config/defaults");
|
||||
const createHash = require("./util/createHash");
|
||||
|
||||
/** @typedef {import("./Compilation").DependencyConstructor} DependencyConstructor */
|
||||
/** @typedef {import("./Dependency")} Dependency */
|
||||
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
|
||||
/** @typedef {typeof import("./util/Hash")} Hash */
|
||||
|
||||
/** @typedef {new (...args: EXPECTED_ANY[]) => Dependency} DependencyConstructor */
|
||||
|
||||
class DependencyTemplates {
|
||||
/**
|
||||
* @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").ExternalItemObjectUnknown} ExternalItemObjectUnknown */
|
||||
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
|
||||
/** @typedef {import("./Compilation").DepConstructor} DepConstructor */
|
||||
/** @typedef {import("./ExternalModule").DependencyMeta} DependencyMeta */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./ModuleFactory").IssuerLayer} IssuerLayer */
|
||||
|
|
|
@ -50,6 +50,7 @@ const {
|
|||
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
||||
/** @typedef {import("./Compilation").Records} Records */
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
||||
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
||||
|
@ -399,13 +400,11 @@ class HotModuleReplacementPlugin {
|
|||
* @returns {string} module hash
|
||||
*/
|
||||
const getModuleHash = (module) => {
|
||||
if (
|
||||
compilation.codeGenerationResults.has(module, chunk.runtime)
|
||||
) {
|
||||
return compilation.codeGenerationResults.getHash(
|
||||
module,
|
||||
chunk.runtime
|
||||
);
|
||||
const codeGenerationResults =
|
||||
/** @type {CodeGenerationResults} */
|
||||
(compilation.codeGenerationResults);
|
||||
if (codeGenerationResults.has(module, chunk.runtime)) {
|
||||
return codeGenerationResults.getHash(module, chunk.runtime);
|
||||
}
|
||||
nonCodeGeneratedModules.add(module, chunk.runtime);
|
||||
return chunkGraph.getModuleHash(module, chunk.runtime);
|
||||
|
@ -499,14 +498,14 @@ class HotModuleReplacementPlugin {
|
|||
) {
|
||||
return;
|
||||
}
|
||||
const codeGenerationResults =
|
||||
/** @type {CodeGenerationResults} */
|
||||
(compilation.codeGenerationResults);
|
||||
for (const [module, chunk] of fullHashModules) {
|
||||
const key = `${chunk.id}|${module.identifier()}`;
|
||||
const hash = nonCodeGeneratedModules.has(module, chunk.runtime)
|
||||
? chunkGraph.getModuleHash(module, chunk.runtime)
|
||||
: compilation.codeGenerationResults.getHash(
|
||||
module,
|
||||
chunk.runtime
|
||||
);
|
||||
: codeGenerationResults.getHash(module, chunk.runtime);
|
||||
if (records.chunkModuleHashes[key] !== hash) {
|
||||
updatedModules.add(module, chunk);
|
||||
}
|
||||
|
@ -644,10 +643,7 @@ class HotModuleReplacementPlugin {
|
|||
// Module is still in the same runtime combination
|
||||
const hash = nonCodeGeneratedModules.has(module, newRuntime)
|
||||
? chunkGraph.getModuleHash(module, newRuntime)
|
||||
: compilation.codeGenerationResults.getHash(
|
||||
module,
|
||||
newRuntime
|
||||
);
|
||||
: codeGenerationResults.getHash(module, newRuntime);
|
||||
if (hash !== oldHash) {
|
||||
if (module.type === WEBPACK_MODULE_TYPE_RUNTIME) {
|
||||
newRuntimeModules = newRuntimeModules || [];
|
||||
|
@ -731,7 +727,9 @@ class HotModuleReplacementPlugin {
|
|||
outputOptions: compilation.outputOptions,
|
||||
moduleTemplates: compilation.moduleTemplates,
|
||||
dependencyTemplates: compilation.dependencyTemplates,
|
||||
codeGenerationResults: compilation.codeGenerationResults,
|
||||
codeGenerationResults: /** @type {CodeGenerationResults} */ (
|
||||
compilation.codeGenerationResults
|
||||
),
|
||||
runtimeTemplate: compilation.runtimeTemplate,
|
||||
moduleGraph: compilation.moduleGraph,
|
||||
chunkGraph
|
||||
|
|
|
@ -24,6 +24,7 @@ const memoize = require("../util/memoize");
|
|||
/** @typedef {import("../../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssGlobalGeneratorOptions} CssGlobalGeneratorOptions */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
|
||||
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
||||
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").CssData} CssData */
|
||||
|
@ -124,7 +125,7 @@ class CssGenerator extends Generator {
|
|||
*/
|
||||
const handleDependency = (dependency) => {
|
||||
const constructor =
|
||||
/** @type {new (...args: EXPECTED_ANY[]) => Dependency} */
|
||||
/** @type {DependencyConstructor} */
|
||||
(dependency.constructor);
|
||||
const template = generateContext.dependencyTemplates.get(constructor);
|
||||
if (!template) {
|
||||
|
|
|
@ -445,7 +445,6 @@ class CssModulesPlugin {
|
|||
compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
|
||||
const {
|
||||
chunkGraph,
|
||||
codeGenerationResults,
|
||||
moduleGraph,
|
||||
runtimeTemplate,
|
||||
outputOptions: {
|
||||
|
@ -457,6 +456,9 @@ class CssModulesPlugin {
|
|||
} = compilation;
|
||||
const hash = createHash(hashFunction);
|
||||
if (hashSalt) hash.update(hashSalt);
|
||||
const codeGenerationResults =
|
||||
/** @type {CodeGenerationResults} */
|
||||
(compilation.codeGenerationResults);
|
||||
hooks.chunkHash.call(chunk, hash, {
|
||||
chunkGraph,
|
||||
codeGenerationResults,
|
||||
|
|
|
@ -296,7 +296,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
depBlock.addDependency(dep);
|
||||
|
||||
parser.state.current = /** @type {TODO} */ (depBlock);
|
||||
parser.state.current = /** @type {EXPECTED_ANY} */ (depBlock);
|
||||
}
|
||||
|
||||
if (expr.arguments.length === 1) {
|
||||
|
|
|
@ -11,7 +11,7 @@ const LoaderDependency = require("./LoaderDependency");
|
|||
const LoaderImportDependency = require("./LoaderImportDependency");
|
||||
|
||||
/** @typedef {import("../../declarations/LoaderContext").LoaderPluginLoaderContext} LoaderPluginLoaderContext */
|
||||
/** @typedef {import("../Compilation").DepConstructor} DepConstructor */
|
||||
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
||||
/** @typedef {import("../Compilation").ExecuteModuleExports} ExecuteModuleExports */
|
||||
/** @typedef {import("../Compilation").ExecuteModuleResult} ExecuteModuleResult */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
|
@ -66,7 +66,8 @@ class LoaderPlugin {
|
|||
name: request
|
||||
};
|
||||
const factory = compilation.dependencyFactories.get(
|
||||
/** @type {DepConstructor} */ (dep.constructor)
|
||||
/** @type {DependencyConstructor} */
|
||||
(dep.constructor)
|
||||
);
|
||||
if (factory === undefined) {
|
||||
return callback(
|
||||
|
@ -170,7 +171,8 @@ class LoaderPlugin {
|
|||
name: request
|
||||
};
|
||||
const factory = compilation.dependencyFactories.get(
|
||||
/** @type {DepConstructor} */ (dep.constructor)
|
||||
/** @type {DependencyConstructor} */
|
||||
(dep.constructor)
|
||||
);
|
||||
if (factory === undefined) {
|
||||
return callback(
|
||||
|
|
|
@ -86,7 +86,7 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
|||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
depBlock.addDependency(dep);
|
||||
const old = parser.state.current;
|
||||
parser.state.current = /** @type {TODO} */ (depBlock);
|
||||
parser.state.current = /** @type {EXPECTED_ANY} */ (depBlock);
|
||||
try {
|
||||
let failed = false;
|
||||
parser.inScope([], () => {
|
||||
|
|
|
@ -42,11 +42,12 @@ const memoize = require("./util/memoize");
|
|||
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
|
||||
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
|
||||
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
||||
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
|
||||
/** @typedef {import("./Compilation").Asset} Asset */
|
||||
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
||||
/** @typedef {import("./Compilation").EntryOptions} EntryOptions */
|
||||
/** @typedef {import("./Compilation").PathData} PathData */
|
||||
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
|
||||
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
||||
/** @typedef {import("./Entrypoint")} Entrypoint */
|
||||
/** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
|
||||
/** @typedef {import("./MultiCompiler").MultiWebpackOptions} MultiConfiguration */
|
||||
|
|
|
@ -17,6 +17,7 @@ const {
|
|||
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
|
||||
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||
|
||||
const PLUGIN_NAME = "ArrayPushCallbackChunkFormatPlugin";
|
||||
|
||||
|
@ -89,7 +90,9 @@ class ArrayPushCallbackChunkFormatPlugin {
|
|||
runtime.add(
|
||||
Template.renderRuntimeModules(runtimeModules, {
|
||||
...renderContext,
|
||||
codeGenerationResults: compilation.codeGenerationResults
|
||||
codeGenerationResults:
|
||||
/** @type {CodeGenerationResults} */
|
||||
(compilation.codeGenerationResults)
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ const { JS_TYPES } = require("../ModuleSourceTypesConstants");
|
|||
const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
||||
/** @typedef {import("../DependenciesBlock")} DependenciesBlock */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate")} DependencyTemplate */
|
||||
|
@ -213,7 +214,7 @@ class JavascriptGenerator extends Generator {
|
|||
*/
|
||||
sourceDependency(module, dependency, initFragments, source, generateContext) {
|
||||
const constructor =
|
||||
/** @type {new (...args: EXPECTED_ANY[]) => Dependency} */
|
||||
/** @type {DependencyConstructor} */
|
||||
(dependency.constructor);
|
||||
const template = generateContext.dependencyTemplates.get(constructor);
|
||||
if (!template) {
|
||||
|
|
|
@ -444,7 +444,6 @@ class JavascriptModulesPlugin {
|
|||
compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
|
||||
const {
|
||||
chunkGraph,
|
||||
codeGenerationResults,
|
||||
moduleGraph,
|
||||
runtimeTemplate,
|
||||
outputOptions: {
|
||||
|
@ -454,6 +453,9 @@ class JavascriptModulesPlugin {
|
|||
hashFunction
|
||||
}
|
||||
} = compilation;
|
||||
const codeGenerationResults =
|
||||
/** @type {CodeGenerationResults} */
|
||||
(compilation.codeGenerationResults);
|
||||
const hash = createHash(hashFunction);
|
||||
if (hashSalt) hash.update(hashSalt);
|
||||
if (chunk.hasRuntime()) {
|
||||
|
|
|
@ -95,6 +95,7 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|||
*/
|
||||
/** @typedef {import("../Parser").ParserState} ParserState */
|
||||
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
||||
|
||||
/** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => string[], getMembersOptionals: () => boolean[], getMemberRanges: () => Range[] }} GetInfoResult */
|
||||
/** @typedef {Statement | ModuleDeclaration | Expression | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration} StatementPathItem */
|
||||
/** @typedef {(ident: string) => void} OnIdentString */
|
||||
|
@ -4605,7 +4606,7 @@ class JavascriptParser extends Parser {
|
|||
terminated: undefined,
|
||||
definitions: new StackedMap()
|
||||
};
|
||||
this.state = /** @type {ParserState} */ (state);
|
||||
this.state = state;
|
||||
this.comments = comments;
|
||||
this.semicolons = semicolons;
|
||||
this.statementPath = [];
|
||||
|
|
|
@ -16,6 +16,7 @@ const {
|
|||
} = require("../util/semver");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("./ConsumeSharedModule")} ConsumeSharedModule */
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
|
@ -23,7 +24,7 @@ const {
|
|||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
/** @typedef {import("./ConsumeSharedModule")} ConsumeSharedModule */
|
||||
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||
|
||||
class ConsumeSharedRuntimeModule extends RuntimeModule {
|
||||
/**
|
||||
|
@ -40,7 +41,10 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|||
generate() {
|
||||
const compilation = /** @type {Compilation} */ (this.compilation);
|
||||
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
||||
const { runtimeTemplate, codeGenerationResults } = compilation;
|
||||
const codeGenerationResults =
|
||||
/** @type {CodeGenerationResults} */
|
||||
(compilation.codeGenerationResults);
|
||||
const { runtimeTemplate } = compilation;
|
||||
/** @type {Record<ChunkId, ModuleId[]>} */
|
||||
const chunkToModuleMapping = {};
|
||||
/** @type {Map<ModuleId, Source>} */
|
||||
|
|
|
@ -16,6 +16,7 @@ const {
|
|||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||
|
||||
class ShareRuntimeModule extends RuntimeModule {
|
||||
constructor() {
|
||||
|
@ -29,9 +30,11 @@ class ShareRuntimeModule extends RuntimeModule {
|
|||
const compilation = /** @type {Compilation} */ (this.compilation);
|
||||
const {
|
||||
runtimeTemplate,
|
||||
codeGenerationResults,
|
||||
outputOptions: { uniqueName, ignoreBrowserWarnings }
|
||||
} = compilation;
|
||||
const codeGenerationResults =
|
||||
/** @type {CodeGenerationResults} */
|
||||
(compilation.codeGenerationResults);
|
||||
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
||||
/** @type {Map<string, Map<number, Set<string>>>} */
|
||||
const initCodePerScope = new Map();
|
||||
|
|
|
@ -25,6 +25,8 @@ const {
|
|||
const { makePathsRelative, parseResource } = require("../util/identifier");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("./StatsFactory")} StatsFactory */
|
||||
/** @typedef {import("./StatsFactory").StatsFactoryContext} StatsFactoryContext */
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
||||
/** @typedef {import("../Chunk").ChunkName} ChunkName */
|
||||
|
@ -48,8 +50,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|||
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
|
||||
/** @typedef {import("../WebpackError")} WebpackError */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
/** @typedef {import("./StatsFactory")} StatsFactory */
|
||||
/** @typedef {import("./StatsFactory").StatsFactoryContext} StatsFactoryContext */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").StatsValue} StatsValue */
|
||||
|
||||
/**
|
||||
* @template T
|
||||
|
@ -57,8 +58,8 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|||
*/
|
||||
|
||||
/**
|
||||
* @template T, R
|
||||
* @typedef {import("../util/smartGrouping").GroupConfig<T, R>} GroupConfig
|
||||
* @template I, G
|
||||
* @typedef {import("../util/smartGrouping").GroupConfig<I, G>} GroupConfig
|
||||
*/
|
||||
|
||||
/** @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 = {
|
||||
"compilation.chunks": {
|
||||
_: (comparators) => {
|
||||
|
@ -2013,8 +2024,7 @@ const errorsSpaceLimit = (errors, max) => {
|
|||
|
||||
/**
|
||||
* @template {{ size: number }} T
|
||||
* @template {{ size: number }} R
|
||||
* @param {(R | T)[]} children children
|
||||
* @param {T[]} children children
|
||||
* @param {T[]} assets assets
|
||||
* @returns {{ size: number }} asset size
|
||||
*/
|
||||
|
@ -2026,11 +2036,13 @@ const assetGroup = (children, assets) => {
|
|||
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 {KnownStatsModule[]} modules modules
|
||||
* @returns {{ size: number, sizes: Record<string, number>}} size and sizes
|
||||
* @returns {ModuleGroupBySizeResult} size and sizes
|
||||
*/
|
||||
const moduleGroup = (children, modules) => {
|
||||
let size = 0;
|
||||
|
@ -2067,7 +2079,21 @@ const reasonGroup = (children, reasons) => {
|
|||
const GROUP_EXTENSION_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} */
|
||||
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) => ({
|
||||
_: (groupConfigs, context, options) => {
|
||||
/**
|
||||
|
@ -2233,7 +2266,11 @@ const MODULES_GROUPERS = (type) => ({
|
|||
type,
|
||||
[name]: Boolean(key),
|
||||
...(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`,
|
||||
moduleType: key,
|
||||
...(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",
|
||||
layer: key,
|
||||
children,
|
||||
...moduleGroup(children, modules)
|
||||
...moduleGroup(
|
||||
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
||||
(children),
|
||||
modules
|
||||
)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -2349,7 +2394,11 @@ const MODULES_GROUPERS = (type) => ({
|
|||
: "modules by extension",
|
||||
name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
|
||||
children,
|
||||
...moduleGroup(children, modules)
|
||||
...moduleGroup(
|
||||
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
||||
(children),
|
||||
modules
|
||||
)
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@ -2371,13 +2420,21 @@ const MODULES_GROUPERS = (type) => ({
|
|||
createGroup: (key, children, modules) => ({
|
||||
type: "hidden modules",
|
||||
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} */
|
||||
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 = {
|
||||
"compilation.assets": ASSETS_GROUPERS,
|
||||
"asset.related": ASSETS_GROUPERS,
|
||||
|
@ -2460,7 +2527,14 @@ const sortByField = (field) => {
|
|||
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 = {
|
||||
assetsSort: (comparators, context, { 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 = {
|
||||
"compilation.chunks": {
|
||||
chunksSort: (comparators, context, { chunksSort }) => {
|
||||
|
@ -2498,9 +2581,14 @@ const RESULT_SORTERS = {
|
|||
|
||||
/**
|
||||
* @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 {(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}
|
||||
*/
|
||||
const iterateConfig = (config, options, fn) => {
|
||||
|
@ -2594,18 +2682,13 @@ class DefaultStatsFactoryPlugin {
|
|||
* @param {NormalizedStatsOptions} options stats options
|
||||
*/
|
||||
(stats, options) => {
|
||||
iterateConfig(
|
||||
/** @type {TODO} */
|
||||
(SIMPLE_EXTRACTORS),
|
||||
options,
|
||||
(hookFor, fn) => {
|
||||
stats.hooks.extract
|
||||
.for(hookFor)
|
||||
.tap(PLUGIN_NAME, (obj, data, ctx) =>
|
||||
fn(obj, data, ctx, options, stats)
|
||||
);
|
||||
}
|
||||
);
|
||||
iterateConfig(SIMPLE_EXTRACTORS, options, (hookFor, fn) => {
|
||||
stats.hooks.extract
|
||||
.for(hookFor)
|
||||
.tap(PLUGIN_NAME, (obj, data, ctx) =>
|
||||
fn(obj, data, ctx, options, stats)
|
||||
);
|
||||
});
|
||||
iterateConfig(FILTER, options, (hookFor, fn) => {
|
||||
stats.hooks.filter
|
||||
.for(hookFor)
|
||||
|
@ -2634,18 +2717,13 @@ class DefaultStatsFactoryPlugin {
|
|||
fn(comparators, ctx, options)
|
||||
);
|
||||
});
|
||||
iterateConfig(
|
||||
/** @type {TODO} */
|
||||
(RESULT_GROUPERS),
|
||||
options,
|
||||
(hookFor, fn) => {
|
||||
stats.hooks.groupResults
|
||||
.for(hookFor)
|
||||
.tap(PLUGIN_NAME, (groupConfigs, ctx) =>
|
||||
fn(groupConfigs, ctx, options)
|
||||
);
|
||||
}
|
||||
);
|
||||
iterateConfig(RESULT_GROUPERS, options, (hookFor, fn) => {
|
||||
stats.hooks.groupResults
|
||||
.for(hookFor)
|
||||
.tap(PLUGIN_NAME, (groupConfigs, ctx) =>
|
||||
fn(groupConfigs, ctx, options)
|
||||
);
|
||||
});
|
||||
for (const key of Object.keys(ITEM_NAMES)) {
|
||||
const itemName = ITEM_NAMES[key];
|
||||
stats.hooks.getItemName.for(key).tap(PLUGIN_NAME, () => itemName);
|
||||
|
@ -2667,7 +2745,7 @@ class DefaultStatsFactoryPlugin {
|
|||
*/
|
||||
(comp, { _index: idx }) => {
|
||||
const children =
|
||||
/** @type {TODO} */
|
||||
/** @type {StatsValue[]} */
|
||||
(options.children);
|
||||
if (idx < children.length) {
|
||||
return compilation.createStatsFactory(
|
||||
|
|
|
@ -44,8 +44,8 @@ const smartGrouping = require("../util/smartGrouping");
|
|||
/**
|
||||
* @typedef {object} KnownStatsFactoryContext
|
||||
* @property {string} type
|
||||
* @property {(path: string) => string} makePathsRelative
|
||||
* @property {Compilation} compilation
|
||||
* @property {(path: string) => string} makePathsRelative
|
||||
* @property {Set<Module>} rootModules
|
||||
* @property {Map<string, Chunk[]>} compilationFileToChunks
|
||||
* @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 {TODO} ObjectForExtract */
|
||||
/** @typedef {TODO} FactoryData */
|
||||
/** @typedef {TODO} FactoryDataItem */
|
||||
/** @typedef {TODO} Result */
|
||||
/** @typedef {Record<string, TODO>} ObjectForExtract */
|
||||
|
||||
/**
|
||||
* @typedef {object} StatsFactoryHooks
|
||||
|
|
|
@ -13,52 +13,53 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @template R
|
||||
* @template I
|
||||
* @template G
|
||||
* @typedef {object} GroupConfig
|
||||
* @property {(item: T) => string[] | undefined} getKeys
|
||||
* @property {(key: string, children: (R | T)[], items: T[]) => R} createGroup
|
||||
* @property {(name: string, items: T[]) => GroupOptions=} getOptions
|
||||
* @property {(item: I) => string[] | undefined} getKeys
|
||||
* @property {(name: string, items: I[]) => GroupOptions=} getOptions
|
||||
* @property {(key: string, children: I[], items: I[]) => G} createGroup
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T, R
|
||||
* @typedef {Set<Group<T, R>>} Groups
|
||||
* @template I
|
||||
* @template G
|
||||
* @typedef {{ config: GroupConfig<I, G>, name: string, alreadyGrouped: boolean, items: Items<I, G> | undefined }} Group
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T, R
|
||||
* @typedef {Set<ItemWithGroups<T, R>>} Items
|
||||
* @template I, G
|
||||
* @typedef {Set<Group<I, G>>} Groups
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @template R
|
||||
* @template I
|
||||
* @template G
|
||||
* @typedef {object} ItemWithGroups
|
||||
* @property {T} item
|
||||
* @property {Groups<T, R>} groups
|
||||
* @property {I} item
|
||||
* @property {Groups<I, G>} groups
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @template R
|
||||
* @typedef {{ config: GroupConfig<T, R>, name: string, alreadyGrouped: boolean, items: Items<T, R> | undefined }} Group
|
||||
* @template T, G
|
||||
* @typedef {Set<ItemWithGroups<T, G>>} Items
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @template I
|
||||
* @template G
|
||||
* @template R
|
||||
* @param {T[]} items the list of items
|
||||
* @param {GroupConfig<T, R>[]} groupConfigs configuration
|
||||
* @returns {(R | T)[]} grouped items
|
||||
* @param {I[]} items the list of items
|
||||
* @param {GroupConfig<I, G>[]} groupConfigs configuration
|
||||
* @returns {(I | G)[]} grouped items
|
||||
*/
|
||||
const smartGrouping = (items, groupConfigs) => {
|
||||
/** @type {Items<T, R>} */
|
||||
/** @type {Items<I, G>} */
|
||||
const itemsWithGroups = new Set();
|
||||
/** @type {Map<string, Group<T, R>>} */
|
||||
/** @type {Map<string, Group<I, G>>} */
|
||||
const allGroups = new Map();
|
||||
for (const item of items) {
|
||||
/** @type {Groups<T, R>} */
|
||||
/** @type {Groups<I, G>} */
|
||||
const groups = new Set();
|
||||
for (let i = 0; i < groupConfigs.length; i++) {
|
||||
const groupConfig = groupConfigs[i];
|
||||
|
@ -87,9 +88,10 @@ const smartGrouping = (items, groupConfigs) => {
|
|||
groups
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Items<T, R>} itemsWithGroups input items with groups
|
||||
* @returns {(T | R)[]} groups items
|
||||
* @param {Items<I, G>} itemsWithGroups input items with groups
|
||||
* @returns {(I | G)[]} groups items
|
||||
*/
|
||||
const runGrouping = (itemsWithGroups) => {
|
||||
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();
|
||||
for (const group of allGroups.values()) {
|
||||
if (group.items) {
|
||||
|
@ -117,13 +119,15 @@ const smartGrouping = (items, groupConfigs) => {
|
|||
});
|
||||
}
|
||||
}
|
||||
/** @type {(T | R)[]} */
|
||||
/** @type {(I | G)[]} */
|
||||
const results = [];
|
||||
for (;;) {
|
||||
/** @type {Group<T, R> | undefined} */
|
||||
/** @type {Group<I, G> | undefined} */
|
||||
let bestGroup;
|
||||
let bestGroupSize = -1;
|
||||
/** @type {Items<I, G> | undefined} */
|
||||
let bestGroupItems;
|
||||
/** @type {GroupOptions | false | undefined} */
|
||||
let bestGroupOptions;
|
||||
for (const [group, state] of groupMap) {
|
||||
const { items, used } = state;
|
||||
|
@ -202,8 +206,9 @@ const smartGrouping = (items, groupConfigs) => {
|
|||
bestGroup.alreadyGrouped = true;
|
||||
const children = groupChildren ? runGrouping(items) : allItems;
|
||||
bestGroup.alreadyGrouped = false;
|
||||
|
||||
results.push(groupConfig.createGroup(key, children, allItems));
|
||||
results.push(
|
||||
groupConfig.createGroup(key, /** @type {I[]} */ (children), allItems)
|
||||
);
|
||||
}
|
||||
for (const { item } of itemsWithGroups) {
|
||||
results.push(item);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5179,7 +5179,17 @@
|
|||
},
|
||||
"children": {
|
||||
"description": "Add children information.",
|
||||
"type": "boolean"
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/StatsValue"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/StatsValue"
|
||||
}
|
||||
]
|
||||
},
|
||||
"chunkGroupAuxiliary": {
|
||||
"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"
|
||||
`;
|
||||
|
||||
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`] = `
|
||||
"asset child.js X bytes [emitted]
|
||||
asset parent.js X bytes [emitted] (name: parent)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"use strict";
|
||||
|
||||
/** @typedef {import("webpack").CodeGenerationResults} CodeGenerationResults */
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
|
||||
/** @type {import("../../../../").Configuration} */
|
||||
|
@ -28,10 +29,9 @@ module.exports = {
|
|||
() => {
|
||||
for (const module of compilation.modules) {
|
||||
if (module.type === "json") {
|
||||
const { sources } = compilation.codeGenerationResults.get(
|
||||
module,
|
||||
"main"
|
||||
);
|
||||
const { sources } =
|
||||
/** @type {CodeGenerationResults} */
|
||||
(compilation.codeGenerationResults).get(module, "main");
|
||||
const source =
|
||||
/** @type {Source} */
|
||||
(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>>;
|
||||
moduleGraph: ModuleGraph;
|
||||
chunkGraph: ChunkGraph;
|
||||
codeGenerationResults: CodeGenerationResults;
|
||||
codeGenerationResults?: CodeGenerationResults;
|
||||
processDependenciesQueue: AsyncQueue<Module, Module, Module>;
|
||||
addModuleQueue: AsyncQueue<Module, string, Module>;
|
||||
factorizeQueue: AsyncQueue<
|
||||
|
@ -2262,7 +2262,7 @@ declare class Compilation {
|
|||
warnings: Error[];
|
||||
children: Compilation[];
|
||||
logging: Map<string, LogEntry[]>;
|
||||
dependencyFactories: Map<DepConstructor, ModuleFactory>;
|
||||
dependencyFactories: Map<DependencyConstructor, ModuleFactory>;
|
||||
dependencyTemplates: DependencyTemplates;
|
||||
childrenCounters: Record<string, number>;
|
||||
usedChunkIds: null | Set<string | number>;
|
||||
|
@ -2314,6 +2314,17 @@ declare class Compilation {
|
|||
callback: (err?: null | WebpackError, result?: null | Module) => void
|
||||
): 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(
|
||||
__0: HandleModuleCreationOptions,
|
||||
callback: (err?: null | WebpackError, result?: null | Module) => void
|
||||
|
@ -2482,22 +2493,12 @@ declare class Compilation {
|
|||
executeModule(
|
||||
module: Module,
|
||||
options: ExecuteModuleOptions,
|
||||
callback: (err: null | WebpackError, result?: ExecuteModuleResult) => void
|
||||
callback: (
|
||||
err?: null | WebpackError,
|
||||
result?: null | ExecuteModuleResult
|
||||
) => void
|
||||
): void;
|
||||
checkConstraints(): void;
|
||||
factorizeModule: {
|
||||
(
|
||||
options: FactorizeModuleOptions & { factoryResult?: false },
|
||||
callback: (err?: null | WebpackError, result?: null | Module) => void
|
||||
): void;
|
||||
(
|
||||
options: FactorizeModuleOptions & { factoryResult: true },
|
||||
callback: (
|
||||
err?: null | WebpackError,
|
||||
result?: ModuleFactoryResult
|
||||
) => void
|
||||
): void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add additional assets to the compilation.
|
||||
|
@ -3123,13 +3124,13 @@ declare interface Configuration {
|
|||
| boolean
|
||||
| StatsOptions
|
||||
| "none"
|
||||
| "verbose"
|
||||
| "summary"
|
||||
| "errors-only"
|
||||
| "errors-warnings"
|
||||
| "minimal"
|
||||
| "normal"
|
||||
| "detailed";
|
||||
| "detailed"
|
||||
| "verbose";
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
declare interface DepConstructor {
|
||||
new (...args: any[]): Dependency;
|
||||
}
|
||||
declare abstract class DependenciesBlock {
|
||||
dependencies: Dependency[];
|
||||
blocks: AsyncDependenciesBlock[];
|
||||
|
@ -6012,8 +6010,8 @@ declare interface GotHandler<T> {
|
|||
}
|
||||
declare interface GroupConfig<T, R> {
|
||||
getKeys: (item: T) => undefined | string[];
|
||||
createGroup: (key: string, children: (T | R)[], items: T[]) => R;
|
||||
getOptions?: (name: string, items: T[]) => GroupOptions;
|
||||
createGroup: (key: string, children: T[], items: T[]) => R;
|
||||
}
|
||||
declare interface GroupOptions {
|
||||
groupChildren?: boolean;
|
||||
|
@ -6443,7 +6441,7 @@ declare interface InfrastructureLogging {
|
|||
/**
|
||||
* 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.
|
||||
|
@ -6461,7 +6459,7 @@ type InfrastructureLoggingNormalizedWithDefaults = InfrastructureLogging & {
|
|||
rows?: number;
|
||||
};
|
||||
level: NonNullable<
|
||||
undefined | "none" | "error" | "warn" | "info" | "log" | "verbose"
|
||||
undefined | "none" | "verbose" | "error" | "warn" | "info" | "log"
|
||||
>;
|
||||
debug: NonNullable<
|
||||
| undefined
|
||||
|
@ -8667,7 +8665,7 @@ declare interface KnownNormalizedStatsOptions {
|
|||
modulesSpace: number;
|
||||
chunkModulesSpace: number;
|
||||
nestedModulesSpace: number;
|
||||
logging: false | "none" | "error" | "warn" | "info" | "log" | "verbose";
|
||||
logging: false | "none" | "verbose" | "error" | "warn" | "info" | "log";
|
||||
loggingDebug: ((value: string) => boolean)[];
|
||||
loggingTrace: boolean;
|
||||
}
|
||||
|
@ -8792,8 +8790,8 @@ declare interface KnownStatsError {
|
|||
}
|
||||
declare interface KnownStatsFactoryContext {
|
||||
type: string;
|
||||
makePathsRelative: (path: string) => string;
|
||||
compilation: Compilation;
|
||||
makePathsRelative: (path: string) => string;
|
||||
rootModules: Set<Module>;
|
||||
compilationFileToChunks: Map<string, Chunk[]>;
|
||||
compilationAuxiliaryFileToChunks: Map<string, Chunk[]>;
|
||||
|
@ -11437,9 +11435,6 @@ declare interface ObjectEncodingOptions {
|
|||
| "binary"
|
||||
| "hex";
|
||||
}
|
||||
declare interface ObjectForExtract {
|
||||
[index: string]: any;
|
||||
}
|
||||
declare interface ObjectSerializer {
|
||||
serialize: (value: any, context: ObjectSerializerContext) => void;
|
||||
deserialize: (context: ObjectDeserializerContext) => any;
|
||||
|
@ -13091,7 +13086,7 @@ declare class PrefetchPlugin {
|
|||
apply(compiler: Compiler): void;
|
||||
}
|
||||
declare class PrefixSource extends Source {
|
||||
constructor(prefix: string, source: string | Source | Buffer);
|
||||
constructor(prefix: string, source: string | Buffer | Source);
|
||||
getPrefix(): string;
|
||||
original(): Source;
|
||||
streamChunks(
|
||||
|
@ -13135,7 +13130,7 @@ type ProblemType =
|
|||
| "multiple-values-unexpected"
|
||||
| "invalid-value";
|
||||
declare interface ProcessAssetsAdditionalOptions {
|
||||
additionalAssets?: any;
|
||||
additionalAssets?: boolean | ((assets: CompilationAssets) => void);
|
||||
}
|
||||
declare class Profiler {
|
||||
constructor(inspector: Inspector);
|
||||
|
@ -16787,9 +16782,7 @@ declare abstract class StatsFactory {
|
|||
}
|
||||
type StatsFactoryContext = KnownStatsFactoryContext & Record<string, any>;
|
||||
declare interface StatsFactoryHooks {
|
||||
extract: HookMap<
|
||||
SyncBailHook<[ObjectForExtract, any, StatsFactoryContext], void>
|
||||
>;
|
||||
extract: HookMap<SyncBailHook<[any, any, StatsFactoryContext], void>>;
|
||||
filter: HookMap<
|
||||
SyncBailHook<[any, StatsFactoryContext, number, number], boolean | void>
|
||||
>;
|
||||
|
@ -16877,7 +16870,18 @@ declare interface StatsOptions {
|
|||
/**
|
||||
* 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.
|
||||
|
@ -17131,7 +17135,7 @@ declare interface StatsOptions {
|
|||
/**
|
||||
* 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.
|
||||
|
@ -17324,13 +17328,13 @@ type StatsValue =
|
|||
| boolean
|
||||
| StatsOptions
|
||||
| "none"
|
||||
| "verbose"
|
||||
| "summary"
|
||||
| "errors-only"
|
||||
| "errors-warnings"
|
||||
| "minimal"
|
||||
| "normal"
|
||||
| "detailed";
|
||||
| "detailed"
|
||||
| "verbose";
|
||||
declare interface StreamChunksOptions {
|
||||
source?: boolean;
|
||||
finalSource?: boolean;
|
||||
|
@ -18870,11 +18874,12 @@ declare namespace exports {
|
|||
WebpackOptionsNormalized,
|
||||
WebpackPluginInstance,
|
||||
ChunkGroup,
|
||||
AssetEmittedInfo,
|
||||
Asset,
|
||||
AssetInfo,
|
||||
EntryOptions,
|
||||
PathData,
|
||||
AssetEmittedInfo,
|
||||
CodeGenerationResults,
|
||||
Entrypoint,
|
||||
MultiCompilerOptions,
|
||||
MultiConfiguration,
|
||||
|
|
Loading…
Reference in New Issue