refactor(types): more

This commit is contained in:
alexander.akait 2023-06-16 20:13:03 +03:00
parent 1ab7cad9a3
commit 4809421990
89 changed files with 520 additions and 195 deletions

View File

@ -13,8 +13,11 @@ const {
const RuntimeGlobals = require("./RuntimeGlobals"); const RuntimeGlobals = require("./RuntimeGlobals");
const ConstDependency = require("./dependencies/ConstDependency"); const ConstDependency = require("./dependencies/ConstDependency");
/** @typedef {import("estree").CallExpression} CallExpression */
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */ /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
const nestedWebpackIdentifierTag = Symbol("nested webpack identifier"); const nestedWebpackIdentifierTag = Symbol("nested webpack identifier");
const PLUGIN_NAME = "CompatibilityPlugin"; const PLUGIN_NAME = "CompatibilityPlugin";
@ -43,14 +46,23 @@ class CompatibilityPlugin {
) )
return; return;
parser.hooks.call.for("require").tap(PLUGIN_NAME, expr => { parser.hooks.call.for("require").tap(
PLUGIN_NAME,
/**
* @param {CallExpression} expr call expression
* @returns {boolean | void} true when need to handle
*/
expr => {
// support for browserify style require delegator: "require(o, !0)" // support for browserify style require delegator: "require(o, !0)"
if (expr.arguments.length !== 2) return; if (expr.arguments.length !== 2) return;
const second = parser.evaluateExpression(expr.arguments[1]); const second = parser.evaluateExpression(expr.arguments[1]);
if (!second.isBoolean()) return; if (!second.isBoolean()) return;
if (second.asBool() !== true) return; if (second.asBool() !== true) return;
const dep = new ConstDependency("require", expr.callee.range); const dep = new ConstDependency(
dep.loc = expr.loc; "require",
/** @type {Range} */ (expr.callee.range)
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
if (parser.state.current.dependencies.length > 0) { if (parser.state.current.dependencies.length > 0) {
const last = const last =
parser.state.current.dependencies[ parser.state.current.dependencies[
@ -67,7 +79,8 @@ class CompatibilityPlugin {
} }
parser.state.module.addPresentationalDependency(dep); parser.state.module.addPresentationalDependency(dep);
return true; return true;
}); }
);
}); });
/** /**
@ -82,7 +95,9 @@ class CompatibilityPlugin {
statement.id && statement.id &&
statement.id.name === RuntimeGlobals.require statement.id.name === RuntimeGlobals.require
) { ) {
const newName = `__nested_webpack_require_${statement.range[0]}__`; const newName = `__nested_webpack_require_${
/** @type {Range} */ (statement.range)[0]
}__`;
parser.tagVariable( parser.tagVariable(
statement.id.name, statement.id.name,
nestedWebpackIdentifierTag, nestedWebpackIdentifierTag,
@ -101,7 +116,9 @@ class CompatibilityPlugin {
parser.hooks.pattern parser.hooks.pattern
.for(RuntimeGlobals.require) .for(RuntimeGlobals.require)
.tap(PLUGIN_NAME, pattern => { .tap(PLUGIN_NAME, pattern => {
const newName = `__nested_webpack_require_${pattern.range[0]}__`; const newName = `__nested_webpack_require_${
/** @type {Range} */ (pattern.range)[0]
}__`;
parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, { parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, {
name: newName, name: newName,
declaration: { declaration: {
@ -135,8 +152,11 @@ class CompatibilityPlugin {
parser.state.module.addPresentationalDependency(dep); parser.state.module.addPresentationalDependency(dep);
declaration.updated = true; declaration.updated = true;
} }
const dep = new ConstDependency(name, expr.range); const dep = new ConstDependency(
dep.loc = expr.loc; name,
/** @type {Range} */ (expr.range)
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep); parser.state.module.addPresentationalDependency(dep);
return true; return true;
}); });
@ -145,11 +165,11 @@ class CompatibilityPlugin {
parser.hooks.program.tap(PLUGIN_NAME, (program, comments) => { parser.hooks.program.tap(PLUGIN_NAME, (program, comments) => {
if (comments.length === 0) return; if (comments.length === 0) return;
const c = comments[0]; const c = comments[0];
if (c.type === "Line" && c.range[0] === 0) { if (c.type === "Line" && /** @type {Range} */ (c.range)[0] === 0) {
if (parser.state.source.slice(0, 2).toString() !== "#!") return; if (parser.state.source.slice(0, 2).toString() !== "#!") return;
// this is a hashbang comment // this is a hashbang comment
const dep = new ConstDependency("//", 0); const dep = new ConstDependency("//", 0);
dep.loc = c.loc; dep.loc = /** @type {DependencyLocation} */ (c.loc);
parser.state.module.addPresentationalDependency(dep); parser.state.module.addPresentationalDependency(dep);
} }
}); });

View File

@ -3208,6 +3208,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
const { chunkGraph, moduleGraph, dependencyTemplates, runtimeTemplate } = const { chunkGraph, moduleGraph, dependencyTemplates, runtimeTemplate } =
this; this;
const results = this.codeGenerationResults; const results = this.codeGenerationResults;
/** @type {WebpackError[]} */
const errors = []; const errors = [];
/** @type {Set<Module> | undefined} */ /** @type {Set<Module> | undefined} */
let notCodeGeneratedModules = undefined; let notCodeGeneratedModules = undefined;
@ -3303,7 +3304,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
* @param {RuntimeTemplate} runtimeTemplate runtimeTemplate * @param {RuntimeTemplate} runtimeTemplate runtimeTemplate
* @param {WebpackError[]} errors errors * @param {WebpackError[]} errors errors
* @param {CodeGenerationResults} results results * @param {CodeGenerationResults} results results
* @param {function(WebpackError=, boolean=): void} callback callback * @param {function((WebpackError | null)=, boolean=): void} callback callback
*/ */
_codeGenerationModule( _codeGenerationModule(
module, module,

View File

@ -42,6 +42,13 @@ const RUNTIME_REQUIREMENTS = new Set([
]); ]);
class DelegatedModule extends Module { class DelegatedModule extends Module {
/**
* @param {string} sourceRequest source request
* @param {TODO} data data
* @param {"require" | "object"} type type
* @param {string} userRequest user request
* @param {string | Module} originalRequest original request
*/
constructor(sourceRequest, data, type, userRequest, originalRequest) { constructor(sourceRequest, data, type, userRequest, originalRequest) {
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null); super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
@ -51,7 +58,7 @@ class DelegatedModule extends Module {
this.delegationType = type; this.delegationType = type;
this.userRequest = userRequest; this.userRequest = userRequest;
this.originalRequest = originalRequest; this.originalRequest = originalRequest;
/** @type {ManifestModuleData} */ /** @type {ManifestModuleData | undefined} */
this.delegateData = data; this.delegateData = data;
// Build info // Build info
@ -110,7 +117,8 @@ class DelegatedModule extends Module {
* @returns {void} * @returns {void}
*/ */
build(options, compilation, resolver, fs, callback) { build(options, compilation, resolver, fs, callback) {
this.buildMeta = { ...this.delegateData.buildMeta }; const delegateData = /** @type {ManifestModuleData} */ (this.delegateData);
this.buildMeta = { ...delegateData.buildMeta };
this.buildInfo = {}; this.buildInfo = {};
this.dependencies.length = 0; this.dependencies.length = 0;
this.delegatedSourceDependency = new DelegatedSourceDependency( this.delegatedSourceDependency = new DelegatedSourceDependency(
@ -118,7 +126,7 @@ class DelegatedModule extends Module {
); );
this.addDependency(this.delegatedSourceDependency); this.addDependency(this.delegatedSourceDependency);
this.addDependency( this.addDependency(
new StaticExportsDependency(this.delegateData.exports || true, false) new StaticExportsDependency(delegateData.exports || true, false)
); );
callback(); callback();
} }
@ -202,6 +210,10 @@ class DelegatedModule extends Module {
super.serialize(context); super.serialize(context);
} }
/**
* @param {ObjectDeserializerContext} context context\
* @returns {DelegatedModule} DelegatedModule
*/
static deserialize(context) { static deserialize(context) {
const { read } = context; const { read } = context;
const obj = new DelegatedModule( const obj = new DelegatedModule(

View File

@ -7,6 +7,8 @@
const DelegatedModule = require("./DelegatedModule"); const DelegatedModule = require("./DelegatedModule");
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
// options.source // options.source
// options.type // options.type
// options.context // options.context
@ -20,6 +22,10 @@ class DelegatedModuleFactoryPlugin {
options.extensions = options.extensions || ["", ".js", ".json", ".wasm"]; options.extensions = options.extensions || ["", ".js", ".json", ".wasm"];
} }
/**
* @param {NormalModuleFactory} normalModuleFactory the normal module factory
* @returns {void}
*/
apply(normalModuleFactory) { apply(normalModuleFactory) {
const scope = this.options.scope; const scope = this.options.scope;
if (scope) { if (scope) {

View File

@ -82,6 +82,10 @@ class EvalSourceMapDevToolPlugin {
return cachedSource; return cachedSource;
} }
/**
* @param {Source} r result
* @returns {Source} result
*/
const result = r => { const result = r => {
cache.set(source, r); cache.set(source, r);
return r; return r;

View File

@ -14,6 +14,8 @@ const { forEachRuntime } = require("./util/runtime");
/** @typedef {import("./Module")} Module */ /** @typedef {import("./Module")} Module */
/** @typedef {import("./ModuleGraph")} ModuleGraph */ /** @typedef {import("./ModuleGraph")} ModuleGraph */
/** @typedef {import("./ModuleGraphConnection")} ModuleGraphConnection */ /** @typedef {import("./ModuleGraphConnection")} ModuleGraphConnection */
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
/** @typedef {import("./util/Hash")} Hash */ /** @typedef {import("./util/Hash")} Hash */
/** @typedef {typeof UsageState.OnlyPropertiesUsed | typeof UsageState.NoInfo | typeof UsageState.Unknown | typeof UsageState.Used} RuntimeUsageStateType */ /** @typedef {typeof UsageState.OnlyPropertiesUsed | typeof UsageState.NoInfo | typeof UsageState.Unknown | typeof UsageState.Used} RuntimeUsageStateType */
@ -44,6 +46,9 @@ class RestoreProvidedData {
this.otherTerminalBinding = otherTerminalBinding; this.otherTerminalBinding = otherTerminalBinding;
} }
/**
* @param {ObjectSerializerContext} context context
*/
serialize({ write }) { serialize({ write }) {
write(this.exports); write(this.exports);
write(this.otherProvided); write(this.otherProvided);
@ -51,6 +56,10 @@ class RestoreProvidedData {
write(this.otherTerminalBinding); write(this.otherTerminalBinding);
} }
/**
* @param {ObjectDeserializerContext} context context
* @returns {RestoreProvidedData} RestoreProvidedData
*/
static deserialize({ read }) { static deserialize({ read }) {
return new RestoreProvidedData(read(), read(), read(), read()); return new RestoreProvidedData(read(), read(), read(), read());
} }
@ -301,7 +310,12 @@ class ExportsInfo {
changed = true; changed = true;
} }
if (targetKey) { if (targetKey) {
exportInfo.setTarget(targetKey, targetModule, [exportInfo.name], -1); exportInfo.setTarget(
targetKey,
/** @type {ModuleGraphConnection} */ (targetModule),
[exportInfo.name],
-1
);
} }
} }
if (this._redirectTo !== undefined) { if (this._redirectTo !== undefined) {
@ -331,7 +345,7 @@ class ExportsInfo {
if (targetKey) { if (targetKey) {
this._otherExportsInfo.setTarget( this._otherExportsInfo.setTarget(
targetKey, targetKey,
targetModule, /** @type {ModuleGraphConnection} */ (targetModule),
undefined, undefined,
priority priority
); );
@ -1226,7 +1240,7 @@ class ExportInfo {
/** /**
* @param {ModuleGraph} moduleGraph the module graph * @param {ModuleGraph} moduleGraph the module graph
* @param {function(Module): boolean} validTargetModuleFilter a valid target module * @param {function(Module): boolean} validTargetModuleFilter a valid target module
* @param {Set<ExportInfo> | undefined} alreadyVisited set of already visited export info to avoid circular references * @param {Set<ExportInfo>} alreadyVisited set of already visited export info to avoid circular references
* @returns {{ module: Module, export: string[] | undefined } | undefined | false} the target, undefined when there is no target, false when no target is valid * @returns {{ module: Module, export: string[] | undefined } | undefined | false} the target, undefined when there is no target, false when no target is valid
*/ */
_findTarget(moduleGraph, validTargetModuleFilter, alreadyVisited) { _findTarget(moduleGraph, validTargetModuleFilter, alreadyVisited) {

View File

@ -14,7 +14,9 @@ const ConstDependency = require("./dependencies/ConstDependency");
const ExportsInfoDependency = require("./dependencies/ExportsInfoDependency"); const ExportsInfoDependency = require("./dependencies/ExportsInfoDependency");
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */ /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
const PLUGIN_NAME = "ExportsInfoApiPlugin"; const PLUGIN_NAME = "ExportsInfoApiPlugin";
@ -43,20 +45,27 @@ class ExportsInfoApiPlugin {
const dep = const dep =
members.length >= 2 members.length >= 2
? new ExportsInfoDependency( ? new ExportsInfoDependency(
expr.range, /** @type {Range} */ (expr.range),
members.slice(0, -1), members.slice(0, -1),
members[members.length - 1] members[members.length - 1]
) )
: new ExportsInfoDependency(expr.range, null, members[0]); : new ExportsInfoDependency(
dep.loc = expr.loc; /** @type {Range} */ (expr.range),
null,
members[0]
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addDependency(dep); parser.state.module.addDependency(dep);
return true; return true;
}); });
parser.hooks.expression parser.hooks.expression
.for("__webpack_exports_info__") .for("__webpack_exports_info__")
.tap(PLUGIN_NAME, expr => { .tap(PLUGIN_NAME, expr => {
const dep = new ConstDependency("true", expr.range); const dep = new ConstDependency(
dep.loc = expr.loc; "true",
/** @type {Range} */ (expr.range)
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep); parser.state.module.addPresentationalDependency(dep);
return true; return true;
}); });

View File

@ -384,6 +384,11 @@ const getSourceForDefaultCase = (optional, request, runtimeTemplate) => {
}; };
class ExternalModule extends Module { class ExternalModule extends Module {
/**
* @param {string | string[] | Record<string, string | string[]>} request request
* @param {TODO} type type
* @param {string} userRequest user request
*/
constructor(request, type, userRequest) { constructor(request, type, userRequest) {
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null); super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);

View File

@ -8,10 +8,14 @@
const { getEntryRuntime, mergeRuntimeOwned } = require("./util/runtime"); const { getEntryRuntime, mergeRuntimeOwned } = require("./util/runtime");
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Module").FactoryMeta} FactoryMeta */
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */ /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
const PLUGIN_NAME = "FlagAllModulesAsUsedPlugin"; const PLUGIN_NAME = "FlagAllModulesAsUsedPlugin";
class FlagAllModulesAsUsedPlugin { class FlagAllModulesAsUsedPlugin {
/**
* @param {string} explanation explanation
*/
constructor(explanation) { constructor(explanation) {
this.explanation = explanation; this.explanation = explanation;
} }
@ -40,7 +44,8 @@ class FlagAllModulesAsUsedPlugin {
if (module.factoryMeta === undefined) { if (module.factoryMeta === undefined) {
module.factoryMeta = {}; module.factoryMeta = {};
} }
module.factoryMeta.sideEffectFree = false; /** @type {FactoryMeta} */
(module.factoryMeta).sideEffectFree = false;
} }
}); });
}); });

View File

@ -189,6 +189,10 @@ class HotModuleReplacementPlugin {
return true; return true;
}; };
/**
* @param {JavascriptParser} parser the parser
* @returns {void}
*/
const applyModuleHot = parser => { const applyModuleHot = parser => {
parser.hooks.evaluateIdentifier.for("module.hot").tap( parser.hooks.evaluateIdentifier.for("module.hot").tap(
{ {
@ -221,6 +225,10 @@ class HotModuleReplacementPlugin {
.tap(PLUGIN_NAME, createHMRExpressionHandler(parser)); .tap(PLUGIN_NAME, createHMRExpressionHandler(parser));
}; };
/**
* @param {JavascriptParser} parser the parser
* @returns {void}
*/
const applyImportMetaHot = parser => { const applyImportMetaHot = parser => {
parser.hooks.evaluateIdentifier parser.hooks.evaluateIdentifier
.for("import.meta.webpackHot") .for("import.meta.webpackHot")

View File

@ -10,17 +10,21 @@ const makeSerializable = require("./util/makeSerializable");
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("./Generator").GenerateContext} GenerateContext */ /** @typedef {import("./Generator").GenerateContext} GenerateContext */
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
/** /**
* @param {InitFragment} fragment the init fragment * @template T
* @param {InitFragment<T>} fragment the init fragment
* @param {number} index index * @param {number} index index
* @returns {[InitFragment, number]} tuple with both * @returns {[InitFragment<T>, number]} tuple with both
*/ */
const extractFragmentIndex = (fragment, index) => [fragment, index]; const extractFragmentIndex = (fragment, index) => [fragment, index];
/** /**
* @param {[InitFragment, number]} a first pair * @template T
* @param {[InitFragment, number]} b second pair * @param {[InitFragment<T>, number]} a first pair
* @param {[InitFragment<T>, number]} b second pair
* @returns {number} sort value * @returns {number} sort value
*/ */
const sortFragmentWithIndex = ([a, i], [b, j]) => { const sortFragmentWithIndex = ([a, i], [b, j]) => {
@ -66,6 +70,14 @@ class InitFragment {
return this.endContent; return this.endContent;
} }
/**
* @template Context
* @template T
* @param {Source} source sources
* @param {InitFragment<T>[]} initFragments init fragments
* @param {Context} context context
* @returns {Source} source
*/
static addToSource(source, initFragments, context) { static addToSource(source, initFragments, context) {
if (initFragments.length > 0) { if (initFragments.length > 0) {
// Sort fragments by position. If 2 fragments have the same position, // Sort fragments by position. If 2 fragments have the same position,
@ -77,7 +89,12 @@ class InitFragment {
// Deduplicate fragments. If a fragment has no key, it is always included. // Deduplicate fragments. If a fragment has no key, it is always included.
const keyedFragments = new Map(); const keyedFragments = new Map();
for (const [fragment] of sortedFragments) { for (const [fragment] of sortedFragments) {
if (typeof fragment.mergeAll === "function") { if (
typeof (
/** @type {InitFragment<T> & { mergeAll?: (fragments: InitFragment[]) => InitFragment[] }} */
(fragment).mergeAll
) === "function"
) {
if (!fragment.key) { if (!fragment.key) {
throw new Error( throw new Error(
`InitFragment with mergeAll function must have a valid key: ${fragment.constructor.name}` `InitFragment with mergeAll function must have a valid key: ${fragment.constructor.name}`
@ -125,6 +142,9 @@ class InitFragment {
} }
} }
/**
* @param {ObjectSerializerContext} context context
*/
serialize(context) { serialize(context) {
const { write } = context; const { write } = context;
@ -135,6 +155,9 @@ class InitFragment {
write(this.endContent); write(this.endContent);
} }
/**
* @param {ObjectDeserializerContext} context context
*/
deserialize(context) { deserialize(context) {
const { read } = context; const { read } = context;

View File

@ -13,6 +13,7 @@ const {
const InnerGraph = require("./optimize/InnerGraph"); const InnerGraph = require("./optimize/InnerGraph");
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Module").BuildInfo} BuildInfo */
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */ /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
const PLUGIN_NAME = "JavascriptMetaInfoPlugin"; const PLUGIN_NAME = "JavascriptMetaInfoPlugin";
@ -33,8 +34,11 @@ class JavascriptMetaInfoPlugin {
*/ */
const handler = parser => { const handler = parser => {
parser.hooks.call.for("eval").tap(PLUGIN_NAME, () => { parser.hooks.call.for("eval").tap(PLUGIN_NAME, () => {
parser.state.module.buildInfo.moduleConcatenationBailout = "eval()"; const buildInfo =
parser.state.module.buildInfo.usingEval = true; /** @type {BuildInfo} */
(parser.state.module.buildInfo);
buildInfo.moduleConcatenationBailout = "eval()";
buildInfo.usingEval = true;
const currentSymbol = InnerGraph.getTopLevelSymbol(parser.state); const currentSymbol = InnerGraph.getTopLevelSymbol(parser.state);
if (currentSymbol) { if (currentSymbol) {
InnerGraph.addUsage(parser.state, null, currentSymbol); InnerGraph.addUsage(parser.state, null, currentSymbol);
@ -43,11 +47,12 @@ class JavascriptMetaInfoPlugin {
} }
}); });
parser.hooks.finish.tap(PLUGIN_NAME, () => { parser.hooks.finish.tap(PLUGIN_NAME, () => {
let topLevelDeclarations = const buildInfo =
parser.state.module.buildInfo.topLevelDeclarations; /** @type {BuildInfo} */
(parser.state.module.buildInfo);
let topLevelDeclarations = buildInfo.topLevelDeclarations;
if (topLevelDeclarations === undefined) { if (topLevelDeclarations === undefined) {
topLevelDeclarations = topLevelDeclarations = buildInfo.topLevelDeclarations = new Set();
parser.state.module.buildInfo.topLevelDeclarations = new Set();
} }
for (const name of parser.scope.definitions.asSet()) { for (const name of parser.scope.definitions.asSet()) {
const freeInfo = parser.getFreeInfoFromVariable(name); const freeInfo = parser.getFreeInfoFromVariable(name);

View File

@ -12,15 +12,29 @@ const { compareModulesById } = require("./util/comparators");
const { dirname, mkdirp } = require("./util/fs"); const { dirname, mkdirp } = require("./util/fs");
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Module").BuildMeta} BuildMeta */
/** /**
* @typedef {Object} ManifestModuleData * @typedef {Object} ManifestModuleData
* @property {string | number} id * @property {string | number} id
* @property {Object} buildMeta * @property {BuildMeta} buildMeta
* @property {boolean | string[]} exports * @property {boolean | string[] | undefined} exports
*/
/**
* @typedef {Object} LibManifestPluginOptions
* @property {string=} context Context of requests in the manifest file (defaults to the webpack context).
* @property {boolean=} entryOnly If true, only entry points will be exposed (default: true).
* @property {boolean=} format If true, manifest json file (output) will be formatted.
* @property {string=} name Name of the exposed dll function (external name, use value of 'output.library').
* @property {string} path Absolute path to the manifest json file (output).
* @property {string=} type Type of the dll bundle (external type, use value of 'output.libraryTarget').
*/ */
class LibManifestPlugin { class LibManifestPlugin {
/**
* @param {LibManifestPluginOptions} options the options
*/
constructor(options) { constructor(options) {
this.options = options; this.options = options;
} }
@ -67,7 +81,9 @@ class LibManifestPlugin {
continue; continue;
} }
const ident = module.libIdent({ const ident = module.libIdent({
context: this.options.context || compiler.options.context, context:
this.options.context ||
/** @type {string} */ (compiler.options.context),
associatedObjectForCache: compiler.root associatedObjectForCache: compiler.root
}); });
if (ident) { if (ident) {
@ -76,7 +92,7 @@ class LibManifestPlugin {
/** @type {ManifestModuleData} */ /** @type {ManifestModuleData} */
const data = { const data = {
id: chunkGraph.getModuleId(module), id: chunkGraph.getModuleId(module),
buildMeta: module.buildMeta, buildMeta: /** @type {BuildMeta} */ (module.buildMeta),
exports: Array.isArray(providedExports) exports: Array.isArray(providedExports)
? providedExports ? providedExports
: undefined : undefined

View File

@ -109,6 +109,11 @@ const makeSerializable = require("./util/makeSerializable");
/** @typedef {KnownBuildMeta & Record<string, any>} BuildMeta */ /** @typedef {KnownBuildMeta & Record<string, any>} BuildMeta */
/** @typedef {Record<string, any>} BuildInfo */ /** @typedef {Record<string, any>} BuildInfo */
/**
* @typedef {Object} FactoryMeta
* @property {boolean=} sideEffectFree
*/
const EMPTY_RESOLVE_OPTIONS = {}; const EMPTY_RESOLVE_OPTIONS = {};
let debugId = 1000; let debugId = 1000;
@ -159,7 +164,7 @@ class Module extends DependenciesBlock {
// Info from Factory // Info from Factory
/** @type {ResolveOptions | undefined} */ /** @type {ResolveOptions | undefined} */
this.resolveOptions = EMPTY_RESOLVE_OPTIONS; this.resolveOptions = EMPTY_RESOLVE_OPTIONS;
/** @type {object | undefined} */ /** @type {FactoryMeta | undefined} */
this.factoryMeta = undefined; this.factoryMeta = undefined;
// TODO refactor this -> options object filled from Factory // TODO refactor this -> options object filled from Factory
// TODO webpack 6: use an enum // TODO webpack 6: use an enum

View File

@ -34,6 +34,7 @@ class ModuleProfile {
this.storing = 0; this.storing = 0;
this.storingParallelismFactor = 0; this.storingParallelismFactor = 0;
/** @type {{ start: number, end: number }[] | undefined } */
this.additionalFactoryTimes = undefined; this.additionalFactoryTimes = undefined;
this.additionalFactories = 0; this.additionalFactories = 0;
this.additionalFactoriesParallelismFactor = 0; this.additionalFactoriesParallelismFactor = 0;

View File

@ -16,6 +16,7 @@ class ModuleRestoreError extends WebpackError {
*/ */
constructor(module, err) { constructor(module, err) {
let message = "Module restore failed: "; let message = "Module restore failed: ";
/** @type {string | undefined} */
let details = undefined; let details = undefined;
if (err !== null && typeof err === "object") { if (err !== null && typeof err === "object") {
if (typeof err.stack === "string" && err.stack) { if (typeof err.stack === "string" && err.stack) {
@ -33,6 +34,7 @@ class ModuleRestoreError extends WebpackError {
super(message); super(message);
this.name = "ModuleRestoreError"; this.name = "ModuleRestoreError";
/** @type {string | undefined} */
this.details = details; this.details = details;
this.module = module; this.module = module;
this.error = err; this.error = err;

View File

@ -21,14 +21,23 @@ const { relative } = require("./util/fs");
const { parseResource } = require("./util/identifier"); const { parseResource } = require("./util/identifier");
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
/** @typedef {import("../declarations/WebpackOptions").NodeOptions} NodeOptions */
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Dependency")} Dependency */ /** @typedef {import("./Dependency")} Dependency */
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */ /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
/** @typedef {import("./NormalModule")} NormalModule */
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
const PLUGIN_NAME = "NodeStuffPlugin"; const PLUGIN_NAME = "NodeStuffPlugin";
class NodeStuffPlugin { class NodeStuffPlugin {
/**
* @param {NodeOptions} options options
*/
constructor(options) { constructor(options) {
this.options = options; this.options = options;
} }
@ -43,6 +52,11 @@ class NodeStuffPlugin {
compiler.hooks.compilation.tap( compiler.hooks.compilation.tap(
PLUGIN_NAME, PLUGIN_NAME,
(compilation, { normalModuleFactory }) => { (compilation, { normalModuleFactory }) => {
/**
* @param {JavascriptParser} parser the parser
* @param {JavascriptParserOptions} parserOptions options
* @returns {void}
*/
const handler = (parser, parserOptions) => { const handler = (parser, parserOptions) => {
if (parserOptions.node === false) return; if (parserOptions.node === false) return;
@ -56,10 +70,10 @@ class NodeStuffPlugin {
parser.hooks.expression.for("global").tap(PLUGIN_NAME, expr => { parser.hooks.expression.for("global").tap(PLUGIN_NAME, expr => {
const dep = new ConstDependency( const dep = new ConstDependency(
RuntimeGlobals.global, RuntimeGlobals.global,
expr.range, /** @type {Range} */ (expr.range),
[RuntimeGlobals.global] [RuntimeGlobals.global]
); );
dep.loc = expr.loc; dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep); parser.state.module.addPresentationalDependency(dep);
// TODO webpack 6 remove // TODO webpack 6 remove
@ -76,25 +90,31 @@ class NodeStuffPlugin {
parser.hooks.rename.for("global").tap(PLUGIN_NAME, expr => { parser.hooks.rename.for("global").tap(PLUGIN_NAME, expr => {
const dep = new ConstDependency( const dep = new ConstDependency(
RuntimeGlobals.global, RuntimeGlobals.global,
expr.range, /** @type {Range} */ (expr.range),
[RuntimeGlobals.global] [RuntimeGlobals.global]
); );
dep.loc = expr.loc; dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep); parser.state.module.addPresentationalDependency(dep);
return false; return false;
}); });
} }
/**
* @param {string} expressionName expression name
* @param {(module: NormalModule) => string} fn function
* @param {string=} warning warning
* @returns {void}
*/
const setModuleConstant = (expressionName, fn, warning) => { const setModuleConstant = (expressionName, fn, warning) => {
parser.hooks.expression parser.hooks.expression
.for(expressionName) .for(expressionName)
.tap(PLUGIN_NAME, expr => { .tap(PLUGIN_NAME, expr => {
const dep = new CachedConstDependency( const dep = new CachedConstDependency(
JSON.stringify(fn(parser.state.module)), JSON.stringify(fn(parser.state.module)),
expr.range, /** @type {Range} */ (expr.range),
expressionName expressionName
); );
dep.loc = expr.loc; dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep); parser.state.module.addPresentationalDependency(dep);
// TODO webpack 6 remove // TODO webpack 6 remove
@ -108,6 +128,12 @@ class NodeStuffPlugin {
}); });
}; };
/**
* @param {string} expressionName expression name
* @param {string} value value
* @param {string=} warning warning
* @returns {void}
*/
const setConstant = (expressionName, value, warning) => const setConstant = (expressionName, value, warning) =>
setModuleConstant(expressionName, () => value, warning); setModuleConstant(expressionName, () => value, warning);

View File

@ -14,7 +14,11 @@ const ConstDependency = require("./dependencies/ConstDependency");
const ProvidedDependency = require("./dependencies/ProvidedDependency"); const ProvidedDependency = require("./dependencies/ProvidedDependency");
const { approve } = require("./javascript/JavascriptParserHelpers"); const { approve } = require("./javascript/JavascriptParserHelpers");
/** @typedef {import("../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
const PLUGIN_NAME = "ProvidePlugin"; const PLUGIN_NAME = "ProvidePlugin";
@ -48,6 +52,11 @@ class ProvidePlugin {
ProvidedDependency, ProvidedDependency,
new ProvidedDependency.Template() new ProvidedDependency.Template()
); );
/**
* @param {JavascriptParser} parser the parser
* @param {JavascriptParserOptions} parserOptions options
* @returns {void}
*/
const handler = (parser, parserOptions) => { const handler = (parser, parserOptions) => {
Object.keys(definitions).forEach(name => { Object.keys(definitions).forEach(name => {
const request = [].concat(definitions[name]); const request = [].concat(definitions[name]);
@ -67,9 +76,9 @@ class ProvidePlugin {
request[0], request[0],
nameIdentifier, nameIdentifier,
request.slice(1), request.slice(1),
expr.range /** @type {Range} */ (expr.range)
); );
dep.loc = expr.loc; dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addDependency(dep); parser.state.module.addDependency(dep);
return true; return true;
}); });
@ -82,9 +91,9 @@ class ProvidePlugin {
request[0], request[0],
nameIdentifier, nameIdentifier,
request.slice(1), request.slice(1),
expr.callee.range /** @type {Range} */ (expr.callee.range)
); );
dep.loc = expr.callee.loc; dep.loc = /** @type {DependencyLocation} */ (expr.callee.loc);
parser.state.module.addDependency(dep); parser.state.module.addDependency(dep);
parser.walkExpressions(expr.arguments); parser.walkExpressions(expr.arguments);
return true; return true;

View File

@ -72,7 +72,9 @@ class RawModule extends Module {
* @returns {string} a user readable identifier of the module * @returns {string} a user readable identifier of the module
*/ */
readableIdentifier(requestShortener) { readableIdentifier(requestShortener) {
return requestShortener.shorten(this.readableIdentifierStr); return /** @type {string} */ (
requestShortener.shorten(this.readableIdentifierStr)
);
} }
/** /**

View File

@ -15,7 +15,9 @@ const {
toConstantDependency toConstantDependency
} = require("./javascript/JavascriptParserHelpers"); } = require("./javascript/JavascriptParserHelpers");
/** @typedef {import("../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
const PLUGIN_NAME = "RequireJsStuffPlugin"; const PLUGIN_NAME = "RequireJsStuffPlugin";
@ -33,6 +35,11 @@ module.exports = class RequireJsStuffPlugin {
ConstDependency, ConstDependency,
new ConstDependency.Template() new ConstDependency.Template()
); );
/**
* @param {JavascriptParser} parser the parser
* @param {JavascriptParserOptions} parserOptions options
* @returns {void}
*/
const handler = (parser, parserOptions) => { const handler = (parser, parserOptions) => {
if ( if (
parserOptions.requireJs === undefined || parserOptions.requireJs === undefined ||

View File

@ -166,7 +166,7 @@ class RuntimeModule extends Module {
/* istanbul ignore next */ /* istanbul ignore next */
/** /**
* @abstract * @abstract
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const AbstractMethodError = require("./AbstractMethodError"); const AbstractMethodError = require("./AbstractMethodError");
@ -174,11 +174,11 @@ class RuntimeModule extends Module {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
getGeneratedCode() { getGeneratedCode() {
if (this._cachedGeneratedCode) { if (this._cachedGeneratedCode) {
return this._cachedGeneratedCode; return /** @type {string | null} */ (this._cachedGeneratedCode);
} }
return (this._cachedGeneratedCode = this.generate()); return (this._cachedGeneratedCode = this.generate());
} }

View File

@ -128,7 +128,8 @@ class RuntimePlugin {
}); });
} }
for (const req of Object.keys(TREE_DEPENDENCIES)) { for (const req of Object.keys(TREE_DEPENDENCIES)) {
const deps = TREE_DEPENDENCIES[req]; const deps =
TREE_DEPENDENCIES[/** @type {keyof TREE_DEPENDENCIES} */ (req)];
compilation.hooks.runtimeRequirementInTree compilation.hooks.runtimeRequirementInTree
.for(req) .for(req)
.tap("RuntimePlugin", (chunk, set) => { .tap("RuntimePlugin", (chunk, set) => {
@ -136,7 +137,8 @@ class RuntimePlugin {
}); });
} }
for (const req of Object.keys(MODULE_DEPENDENCIES)) { for (const req of Object.keys(MODULE_DEPENDENCIES)) {
const deps = MODULE_DEPENDENCIES[req]; const deps =
MODULE_DEPENDENCIES[/** @type {keyof MODULE_DEPENDENCIES} */ (req)];
compilation.hooks.runtimeRequirementInModule compilation.hooks.runtimeRequirementInModule
.for(req) .for(req)
.tap("RuntimePlugin", (chunk, set) => { .tap("RuntimePlugin", (chunk, set) => {

View File

@ -7,9 +7,13 @@
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin"); const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
/** @typedef {import("./Compilation")} Compilation */ /** @typedef {import("./Compilation")} Compilation */
class SourceMapDevToolModuleOptionsPlugin { class SourceMapDevToolModuleOptionsPlugin {
/**
* @param {SourceMapDevToolPluginOptions} options options
*/
constructor(options) { constructor(options) {
this.options = options; this.options = options;
} }

View File

@ -22,6 +22,7 @@ const { makePathsAbsolute } = require("./util/identifier");
/** @typedef {import("./Cache").Etag} Etag */ /** @typedef {import("./Cache").Etag} Etag */
/** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */ /** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */
/** @typedef {import("./Chunk")} Chunk */ /** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./Compilation").Asset} Asset */
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */ /** @typedef {import("./Compilation").AssetInfo} AssetInfo */
/** @typedef {import("./Compilation").PathData} PathData */ /** @typedef {import("./Compilation").PathData} PathData */
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
@ -227,7 +228,9 @@ class SourceMapDevToolPlugin {
asyncLib.each( asyncLib.each(
files, files,
(file, callback) => { (file, callback) => {
const asset = compilation.getAsset(file); const asset =
/** @type {Readonly<Asset>} */
(compilation.getAsset(file));
if (asset.info.related && asset.info.related.sourceMap) { if (asset.info.related && asset.info.related.sourceMap) {
fileIndex++; fileIndex++;
return callback(); return callback();
@ -363,7 +366,9 @@ class SourceMapDevToolPlugin {
// find modules with conflicting source names // find modules with conflicting source names
for (let idx = 0; idx < allModules.length; idx++) { for (let idx = 0; idx < allModules.length; idx++) {
const module = allModules[idx]; const module = allModules[idx];
let sourceName = moduleToSourceNameMapping.get(module); let sourceName =
/** @type {string} */
(moduleToSourceNameMapping.get(module));
let hasName = conflictDetectionSet.has(sourceName); let hasName = conflictDetectionSet.has(sourceName);
if (!hasName) { if (!hasName) {
conflictDetectionSet.add(sourceName); conflictDetectionSet.add(sourceName);

View File

@ -13,7 +13,10 @@ const {
const ConstDependency = require("./dependencies/ConstDependency"); const ConstDependency = require("./dependencies/ConstDependency");
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./Module").BuildInfo} BuildInfo */
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */ /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
const PLUGIN_NAME = "UseStrictPlugin"; const PLUGIN_NAME = "UseStrictPlugin";
@ -42,10 +45,14 @@ class UseStrictPlugin {
// Remove "use strict" expression. It will be added later by the renderer again. // Remove "use strict" expression. It will be added later by the renderer again.
// This is necessary in order to not break the strict mode when webpack prepends code. // This is necessary in order to not break the strict mode when webpack prepends code.
// @see https://github.com/webpack/webpack/issues/1970 // @see https://github.com/webpack/webpack/issues/1970
const dep = new ConstDependency("", firstNode.range); const dep = new ConstDependency(
dep.loc = firstNode.loc; "",
/** @type {Range} */ (firstNode.range)
);
dep.loc = /** @type {DependencyLocation} */ (firstNode.loc);
parser.state.module.addPresentationalDependency(dep); parser.state.module.addPresentationalDependency(dep);
parser.state.module.buildInfo.strict = true; /** @type {BuildInfo} */
(parser.state.module.buildInfo).strict = true;
} }
}); });
}; };

View File

@ -16,10 +16,12 @@ const {
toConstantDependency toConstantDependency
} = require("./javascript/JavascriptParserHelpers"); } = require("./javascript/JavascriptParserHelpers");
/** @typedef {import("enhanced-resolve/lib/Resolver")} Resolver */ /** @typedef {import("enhanced-resolve").Resolver} Resolver */
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./Module")} Module */ /** @typedef {import("./Module")} Module */
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */ /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
const PLUGIN_NAME = "WebpackIsIncludedPlugin"; const PLUGIN_NAME = "WebpackIsIncludedPlugin";
@ -61,10 +63,10 @@ class WebpackIsIncludedPlugin {
if (!request.isString()) return; if (!request.isString()) return;
const dep = new WebpackIsIncludedDependency( const dep = new WebpackIsIncludedDependency(
request.string, /** @type {string} */ (request.string),
expr.range /** @type {Range} */ (expr.range)
); );
dep.loc = expr.loc; dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addDependency(dep); parser.state.module.addDependency(dep);
return true; return true;
}); });

View File

@ -181,6 +181,7 @@ class AssetGenerator extends Generator {
); );
} }
/** @type {string | boolean | undefined} */
let mimeType = this.dataUrlOptions.mimetype; let mimeType = this.dataUrlOptions.mimetype;
if (mimeType === undefined) { if (mimeType === undefined) {
const ext = path.extname(module.nameForCondition()); const ext = path.extname(module.nameForCondition());
@ -213,7 +214,7 @@ class AssetGenerator extends Generator {
); );
} }
return mimeType; return /** @type {string} */ (mimeType);
} }
/** /**

View File

@ -9,6 +9,8 @@ const Parser = require("../Parser");
/** @typedef {import("../../declarations/WebpackOptions").AssetParserDataUrlOptions} AssetParserDataUrlOptions */ /** @typedef {import("../../declarations/WebpackOptions").AssetParserDataUrlOptions} AssetParserDataUrlOptions */
/** @typedef {import("../../declarations/WebpackOptions").AssetParserOptions} AssetParserOptions */ /** @typedef {import("../../declarations/WebpackOptions").AssetParserOptions} AssetParserOptions */
/** @typedef {import("../Module").BuildInfo} BuildInfo */
/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../Parser").ParserState} ParserState */ /** @typedef {import("../Parser").ParserState} ParserState */
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */ /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
@ -30,22 +32,25 @@ class AssetParser extends Parser {
if (typeof source === "object" && !Buffer.isBuffer(source)) { if (typeof source === "object" && !Buffer.isBuffer(source)) {
throw new Error("AssetParser doesn't accept preparsed AST"); throw new Error("AssetParser doesn't accept preparsed AST");
} }
state.module.buildInfo.strict = true;
state.module.buildMeta.exportsType = "default"; const buildInfo = /** @type {BuildInfo} */ (state.module.buildInfo);
state.module.buildMeta.defaultObject = false; buildInfo.strict = true;
const buildMeta = /** @type {BuildMeta} */ (state.module.buildMeta);
buildMeta.exportsType = "default";
buildMeta.defaultObject = false;
if (typeof this.dataUrlCondition === "function") { if (typeof this.dataUrlCondition === "function") {
state.module.buildInfo.dataUrl = this.dataUrlCondition(source, { buildInfo.dataUrl = this.dataUrlCondition(source, {
filename: state.module.matchResource || state.module.resource, filename: state.module.matchResource || state.module.resource,
module: state.module module: state.module
}); });
} else if (typeof this.dataUrlCondition === "boolean") { } else if (typeof this.dataUrlCondition === "boolean") {
state.module.buildInfo.dataUrl = this.dataUrlCondition; buildInfo.dataUrl = this.dataUrlCondition;
} else if ( } else if (
this.dataUrlCondition && this.dataUrlCondition &&
typeof this.dataUrlCondition === "object" typeof this.dataUrlCondition === "object"
) { ) {
state.module.buildInfo.dataUrl = buildInfo.dataUrl =
Buffer.byteLength(source) <= Buffer.byteLength(source) <=
/** @type {NonNullable<AssetParserDataUrlOptions["maxSize"]>} */ /** @type {NonNullable<AssetParserDataUrlOptions["maxSize"]>} */
(this.dataUrlCondition.maxSize); (this.dataUrlCondition.maxSize);

View File

@ -7,6 +7,8 @@
const Parser = require("../Parser"); const Parser = require("../Parser");
/** @typedef {import("../Module").BuildInfo} BuildInfo */
/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../Parser").ParserState} ParserState */ /** @typedef {import("../Parser").ParserState} ParserState */
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */ /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
@ -21,9 +23,12 @@ class AssetSourceParser extends Parser {
throw new Error("AssetSourceParser doesn't accept preparsed AST"); throw new Error("AssetSourceParser doesn't accept preparsed AST");
} }
const { module } = state; const { module } = state;
module.buildInfo.strict = true; /** @type {BuildInfo} */
module.buildMeta.exportsType = "default"; (module.buildInfo).strict = true;
state.module.buildMeta.defaultObject = false; /** @type {BuildMeta} */
(module.buildMeta).exportsType = "default";
/** @type {BuildMeta} */
(state.module.buildMeta).defaultObject = false;
return state; return state;
} }

View File

@ -29,6 +29,10 @@ class AwaitDependenciesInitFragment extends InitFragment {
this.promises = promises; this.promises = promises;
} }
/**
* @param {AwaitDependenciesInitFragment} other other AwaitDependenciesInitFragment
* @returns {AwaitDependenciesInitFragment} AwaitDependenciesInitFragment
*/
merge(other) { merge(other) {
const promises = new Set(other.promises); const promises = new Set(other.promises);
for (const p of this.promises) { for (const p of this.promises) {

View File

@ -50,7 +50,7 @@ class IdleFileCachePlugin {
let timeSpendInStore = 0; let timeSpendInStore = 0;
let avgTimeSpendInStore = 0; let avgTimeSpendInStore = 0;
/** @type {Map<string | typeof BUILD_DEPENDENCIES_KEY, () => Promise>} */ /** @type {Map<string | typeof BUILD_DEPENDENCIES_KEY, () => Promise<void>>} */
const pendingIdleTasks = new Map(); const pendingIdleTasks = new Map();
compiler.cache.hooks.store.tap( compiler.cache.hooks.store.tap(
@ -171,6 +171,7 @@ class IdleFileCachePlugin {
isInitialStore = false; isInitialStore = false;
} }
}; };
/** @type {ReturnType<typeof setTimeout> | undefined} */
let idleTimer = undefined; let idleTimer = undefined;
compiler.cache.hooks.beginIdle.tap( compiler.cache.hooks.beginIdle.tap(
{ name: "IdleFileCachePlugin", stage: Cache.STAGE_DISK }, { name: "IdleFileCachePlugin", stage: Cache.STAGE_DISK },

View File

@ -22,6 +22,8 @@ const {
/** @typedef {import("../Compiler")} Compiler */ /** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../FileSystemInfo").Snapshot} Snapshot */ /** @typedef {import("../FileSystemInfo").Snapshot} Snapshot */
/** @typedef {import("../logging/Logger").Logger} Logger */ /** @typedef {import("../logging/Logger").Logger} Logger */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */ /** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
class PackContainer { class PackContainer {
@ -58,6 +60,9 @@ class PackContainer {
writeLazy(this.data); writeLazy(this.data);
} }
/**
* @param {ObjectDeserializerContext} context context
*/
deserialize({ read }) { deserialize({ read }) {
this.version = read(); this.version = read();
this.buildSnapshot = read(); this.buildSnapshot = read();
@ -99,7 +104,7 @@ class Pack {
constructor(logger, maxAge) { constructor(logger, maxAge) {
/** @type {Map<string, PackItemInfo>} */ /** @type {Map<string, PackItemInfo>} */
this.itemInfo = new Map(); this.itemInfo = new Map();
/** @type {string[]} */ /** @type {(string | undefined)[]} */
this.requests = []; this.requests = [];
this.requestsTimeout = undefined; this.requestsTimeout = undefined;
/** @type {Map<string, PackItemInfo>} */ /** @type {Map<string, PackItemInfo>} */
@ -111,6 +116,9 @@ class Pack {
this.maxAge = maxAge; this.maxAge = maxAge;
} }
/**
* @param {string} identifier identifier
*/
_addRequest(identifier) { _addRequest(identifier) {
this.requests.push(identifier); this.requests.push(identifier);
if (this.requestsTimeout === undefined) { if (this.requestsTimeout === undefined) {
@ -149,7 +157,7 @@ class Pack {
if (!this.content[loc]) { if (!this.content[loc]) {
return undefined; return undefined;
} }
return this.content[loc].get(identifier); return /** @type {PackContent} */ (this.content[loc]).get(identifier);
} }
} }
@ -175,7 +183,7 @@ class Pack {
if (loc >= 0) { if (loc >= 0) {
this._addRequest(identifier); this._addRequest(identifier);
this.freshContent.set(identifier, info); this.freshContent.set(identifier, info);
const content = this.content[loc]; const content = /** @type {PackContent} */ (this.content[loc]);
content.delete(identifier); content.delete(identifier);
if (content.items.size === 0) { if (content.items.size === 0) {
this.content[loc] = undefined; this.content[loc] = undefined;
@ -351,11 +359,12 @@ class Pack {
mergedIndices = smallUnusedContents; mergedIndices = smallUnusedContents;
} else return; } else return;
/** @type {PackContent[] } */
const mergedContent = []; const mergedContent = [];
// 3. Remove old content entries // 3. Remove old content entries
for (const i of mergedIndices) { for (const i of mergedIndices) {
mergedContent.push(this.content[i]); mergedContent.push(/** @type {PackContent} */ (this.content[i]));
this.content[i] = undefined; this.content[i] = undefined;
} }
@ -364,7 +373,7 @@ class Pack {
const mergedItems = new Set(); const mergedItems = new Set();
/** @type {Set<string>} */ /** @type {Set<string>} */
const mergedUsedItems = new Set(); const mergedUsedItems = new Set();
/** @type {(function(Map<string, any>): Promise)[]} */ /** @type {(function(Map<string, any>): Promise<void>)[]} */
const addToMergedMap = []; const addToMergedMap = [];
for (const content of mergedContent) { for (const content of mergedContent) {
for (const identifier of content.items) { for (const identifier of content.items) {
@ -498,17 +507,20 @@ class Pack {
* Only runs for one content to avoid large invalidation. * Only runs for one content to avoid large invalidation.
*/ */
_gcOldestContent() { _gcOldestContent() {
/** @type {PackItemInfo} */ /** @type {PackItemInfo | undefined} */
let oldest = undefined; let oldest = undefined;
for (const info of this.itemInfo.values()) { for (const info of this.itemInfo.values()) {
if (oldest === undefined || info.lastAccess < oldest.lastAccess) { if (oldest === undefined || info.lastAccess < oldest.lastAccess) {
oldest = info; oldest = info;
} }
} }
if (Date.now() - oldest.lastAccess > this.maxAge) { if (
const loc = oldest.location; Date.now() - /** @type {PackItemInfo} */ (oldest).lastAccess >
this.maxAge
) {
const loc = /** @type {PackItemInfo} */ (oldest).location;
if (loc < 0) return; if (loc < 0) return;
const content = this.content[loc]; const content = /** @type {PackContent} */ (this.content[loc]);
const items = new Set(content.items); const items = new Set(content.items);
const usedItems = new Set(content.used); const usedItems = new Set(content.used);
this._gcAndUpdateLocation(items, usedItems, loc); this._gcAndUpdateLocation(items, usedItems, loc);
@ -771,6 +783,7 @@ class PackContent {
// We are in state B // We are in state B
const { lazyName } = this; const { lazyName } = this;
/** @type {string | undefined} */
let timeMessage; let timeMessage;
if (lazyName) { if (lazyName) {
// only log once // only log once
@ -811,7 +824,7 @@ class PackContent {
/** /**
* @param {string} reason explanation why unpack is necessary * @param {string} reason explanation why unpack is necessary
* @returns {void | Promise} maybe a promise if lazy * @returns {void | Promise<void>} maybe a promise if lazy
*/ */
unpack(reason) { unpack(reason) {
if (this.content) return; if (this.content) return;
@ -819,6 +832,7 @@ class PackContent {
// Move from state B to C // Move from state B to C
if (this.lazy) { if (this.lazy) {
const { lazyName } = this; const { lazyName } = this;
/** @type {string | undefined} */
let timeMessage; let timeMessage;
if (lazyName) { if (lazyName) {
// only log once // only log once
@ -862,6 +876,9 @@ class PackContent {
return size; return size;
} }
/**
* @param {string} identifier identifier
*/
delete(identifier) { delete(identifier) {
this.items.delete(identifier); this.items.delete(identifier);
this.used.delete(identifier); this.used.delete(identifier);
@ -906,6 +923,7 @@ class PackContent {
} }
// State B2 // State B2
const { lazyName } = this; const { lazyName } = this;
/** @type {string | undefined} */
let timeMessage; let timeMessage;
if (lazyName) { if (lazyName) {
// only log once // only log once
@ -1028,17 +1046,20 @@ class PackFileCacheStrategy {
this.buildDependencies = new Set(); this.buildDependencies = new Set();
/** @type {LazySet<string>} */ /** @type {LazySet<string>} */
this.newBuildDependencies = new LazySet(); this.newBuildDependencies = new LazySet();
/** @type {Snapshot} */ /** @type {Snapshot | undefined} */
this.resolveBuildDependenciesSnapshot = undefined; this.resolveBuildDependenciesSnapshot = undefined;
/** @type {Map<string, string | false>} */ /** @type {Map<string, string | false> | undefined} */
this.resolveResults = undefined; this.resolveResults = undefined;
/** @type {Snapshot} */ /** @type {Snapshot | undefined} */
this.buildSnapshot = undefined; this.buildSnapshot = undefined;
/** @type {Promise<Pack>} */ /** @type {Promise<Pack> | undefined} */
this.packPromise = this._openPack(); this.packPromise = this._openPack();
this.storePromise = Promise.resolve(); this.storePromise = Promise.resolve();
} }
/**
* @returns {Promise<Pack>} pack
*/
_getPack() { _getPack() {
if (this.packPromise === undefined) { if (this.packPromise === undefined) {
this.packPromise = this.storePromise.then(() => this._openPack()); this.packPromise = this.storePromise.then(() => this._openPack());

View File

@ -18,7 +18,7 @@ class RemoteRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { compilation, chunkGraph } = this; const { compilation, chunkGraph } = this;

View File

@ -56,7 +56,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { compilation, chunk, _runtimeRequirements } = this; const { compilation, chunk, _runtimeRequirements } = this;

View File

@ -14,7 +14,7 @@ class AMDDefineRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
return Template.asString([ return Template.asString([
@ -35,7 +35,7 @@ class AMDOptionsRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
return Template.asString([ return Template.asString([

View File

@ -21,6 +21,7 @@ const ModuleDecoratorDependency = require("./ModuleDecoratorDependency");
/** @typedef {import("estree").Expression} Expression */ /** @typedef {import("estree").Expression} Expression */
/** @typedef {import("estree").Super} Super */ /** @typedef {import("estree").Super} Super */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../NormalModule")} NormalModule */ /** @typedef {import("../NormalModule")} NormalModule */
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */ /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
@ -43,7 +44,7 @@ const ModuleDecoratorDependency = require("./ModuleDecoratorDependency");
* ``` * ```
* *
* @param {TODO} expr expression * @param {TODO} expr expression
* @returns {Expression} returns the value of property descriptor * @returns {Expression | undefined} returns the value of property descriptor
*/ */
const getValueOfPropertyDescription = expr => { const getValueOfPropertyDescription = expr => {
if (expr.type !== "ObjectExpression") return; if (expr.type !== "ObjectExpression") return;
@ -127,6 +128,9 @@ const parseRequireCall = (parser, expr) => {
}; };
class CommonJsExportsParserPlugin { class CommonJsExportsParserPlugin {
/**
* @param {ModuleGraph} moduleGraph module graph
*/
constructor(moduleGraph) { constructor(moduleGraph) {
this.moduleGraph = moduleGraph; this.moduleGraph = moduleGraph;
} }
@ -143,7 +147,7 @@ class CommonJsExportsParserPlugin {
/** /**
* @param {boolean} topLevel true, when the export is on top level * @param {boolean} topLevel true, when the export is on top level
* @param {string[]} members members of the export * @param {string[]} members members of the export
* @param {Expression} valueExpr expression for the value * @param {Expression | undefined} valueExpr expression for the value
* @returns {void} * @returns {void}
*/ */
const checkNamespace = (topLevel, members, valueExpr) => { const checkNamespace = (topLevel, members, valueExpr) => {
@ -156,10 +160,16 @@ class CommonJsExportsParserPlugin {
} }
} }
}; };
/**
* @param {string=} reason reason
*/
const bailout = reason => { const bailout = reason => {
DynamicExports.bailout(parser.state); DynamicExports.bailout(parser.state);
if (reason) bailoutHint(reason); if (reason) bailoutHint(reason);
}; };
/**
* @param {string} reason reason
*/
const bailoutHint = reason => { const bailoutHint = reason => {
this.moduleGraph this.moduleGraph
.getOptimizationBailout(parser.state.module) .getOptimizationBailout(parser.state.module)
@ -292,8 +302,8 @@ class CommonJsExportsParserPlugin {
* @param {Expression | Super} expr expression * @param {Expression | Super} expr expression
* @param {CommonJSDependencyBaseKeywords} base commonjs base keywords * @param {CommonJSDependencyBaseKeywords} base commonjs base keywords
* @param {string[]} members members of the export * @param {string[]} members members of the export
* @param {CallExpression} call call expression * @param {CallExpression=} call call expression
* @returns {boolean} true, when the expression was handled * @returns {boolean | void} true, when the expression was handled
*/ */
const handleAccessExport = (expr, base, members, call = undefined) => { const handleAccessExport = (expr, base, members, call = undefined) => {
if (HarmonyExports.isEnabled(parser.state)) return; if (HarmonyExports.isEnabled(parser.state)) return;

View File

@ -29,8 +29,11 @@ const RequireResolveContextDependency = require("./RequireResolveContextDependen
const RequireResolveDependency = require("./RequireResolveDependency"); const RequireResolveDependency = require("./RequireResolveDependency");
const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency"); const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency");
/** @typedef {import("estree").CallExpression} CallExpressionNode */ /** @typedef {import("estree").CallExpression} CallExpression */
/** @typedef {import("estree").Expression} Expression */
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").ImportSource} ImportSource */
const createRequireSpecifierTag = Symbol("createRequire"); const createRequireSpecifierTag = Symbol("createRequire");
const createdRequireIdentifierTag = Symbol("createRequire()"); const createdRequireIdentifierTag = Symbol("createRequire()");
@ -43,6 +46,10 @@ class CommonJsImportsParserPlugin {
this.options = options; this.options = options;
} }
/**
* @param {JavascriptParser} parser the parser
* @returns {void}
*/
apply(parser) { apply(parser) {
const options = this.options; const options = this.options;
@ -138,6 +145,10 @@ class CommonJsImportsParserPlugin {
//#endregion //#endregion
//#region Renaming //#region Renaming
/**
* @param {Expression} expr expression
* @returns {boolean} true when set undefined
*/
const defineUndefined = expr => { const defineUndefined = expr => {
// To avoid "not defined" error, replace the value with undefined // To avoid "not defined" error, replace the value with undefined
const dep = new ConstDependency("undefined", expr.range); const dep = new ConstDependency("undefined", expr.range);
@ -319,12 +330,22 @@ class CommonJsImportsParserPlugin {
//#endregion //#endregion
//#region Require with property access //#region Require with property access
/**
* @param {Expression} expr expression
* @param {string[]} calleeMembers callee members
* @param {CallExpression} callExpr call expression
* @param {string[]} members members
* @returns {boolean | void} true when handled
*/
const chainHandler = (expr, calleeMembers, callExpr, members) => { const chainHandler = (expr, calleeMembers, callExpr, members) => {
if (callExpr.arguments.length !== 1) return; if (callExpr.arguments.length !== 1) return;
const param = parser.evaluateExpression(callExpr.arguments[0]); const param = parser.evaluateExpression(callExpr.arguments[0]);
if (param.isString() && !getLocalModule(parser.state, param.string)) { if (
param.isString() &&
!getLocalModule(parser.state, /** @type {string} */ (param.string))
) {
const dep = new CommonJsFullRequireDependency( const dep = new CommonJsFullRequireDependency(
param.string, /** @type {string} */ (param.string),
expr.range, expr.range,
members members
); );
@ -335,12 +356,22 @@ class CommonJsImportsParserPlugin {
return true; return true;
} }
}; };
/**
* @param {CallExpression} expr expression
* @param {string[]} calleeMembers callee members
* @param {CallExpression} callExpr call expression
* @param {string[]} members members
* @returns {boolean | void} true when handled
*/
const callChainHandler = (expr, calleeMembers, callExpr, members) => { const callChainHandler = (expr, calleeMembers, callExpr, members) => {
if (callExpr.arguments.length !== 1) return; if (callExpr.arguments.length !== 1) return;
const param = parser.evaluateExpression(callExpr.arguments[0]); const param = parser.evaluateExpression(callExpr.arguments[0]);
if (param.isString() && !getLocalModule(parser.state, param.string)) { if (
param.isString() &&
!getLocalModule(parser.state, /** @type {string} */ (param.string))
) {
const dep = new CommonJsFullRequireDependency( const dep = new CommonJsFullRequireDependency(
param.string, /** @type {string} */ (param.string),
expr.callee.range, expr.callee.range,
members members
); );
@ -444,7 +475,9 @@ class CommonJsImportsParserPlugin {
if (!options.createRequire) return; if (!options.createRequire) return;
/** @type {ImportSource[]} */
let moduleName = []; let moduleName = [];
/** @type {string | undefined} */
let specifierName; let specifierName;
if (options.createRequire === true) { if (options.createRequire === true) {
@ -509,8 +542,8 @@ class CommonJsImportsParserPlugin {
.for(createdRequireIdentifierTag) .for(createdRequireIdentifierTag)
.tap("CommonJsImportsParserPlugin", createRequireHandler(false)); .tap("CommonJsImportsParserPlugin", createRequireHandler(false));
/** /**
* @param {CallExpressionNode} expr call expression * @param {CallExpression} expr call expression
* @returns {string} context * @returns {string | void} context
*/ */
const parseCreateRequireArguments = expr => { const parseCreateRequireArguments = expr => {
const args = expr.arguments; const args = expr.arguments;
@ -532,9 +565,9 @@ class CommonJsImportsParserPlugin {
parser.state.module.addWarning(err); parser.state.module.addWarning(err);
return; return;
} }
const ctx = evaluated.string.startsWith("file://") const ctx = /** @type {string} */ (evaluated.string).startsWith("file://")
? fileURLToPath(evaluated.string) ? fileURLToPath(/** @type {string} */ (evaluated.string))
: evaluated.string; : /** @type {string} */ (evaluated.string);
// argument always should be a filename // argument always should be a filename
return ctx.slice(0, ctx.lastIndexOf(ctx.startsWith("/") ? "/" : "\\")); return ctx.slice(0, ctx.lastIndexOf(ctx.startsWith("/") ? "/" : "\\"));
}; };
@ -586,9 +619,9 @@ class CommonJsImportsParserPlugin {
declarator.init.callee.type !== "Identifier" declarator.init.callee.type !== "Identifier"
) )
return; return;
const variableInfo = parser.getVariableInfo( const variableInfo =
declarator.init.callee.name /** @type {TODO} */
); (parser.getVariableInfo(declarator.init.callee.name));
if ( if (
variableInfo && variableInfo &&
variableInfo.tagInfo && variableInfo.tagInfo &&

View File

@ -35,6 +35,7 @@ const {
const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependency"); const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependency");
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Compiler")} Compiler */ /** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../javascript/JavascriptParser")} Parser */ /** @typedef {import("../javascript/JavascriptParser")} Parser */
@ -250,10 +251,10 @@ class HarmonyModuleDecoratorRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { runtimeTemplate } = this.compilation; const { runtimeTemplate } = /** @type {Compilation} */ (this.compilation);
return Template.asString([ return Template.asString([
`${ `${
RuntimeGlobals.harmonyModuleDecorator RuntimeGlobals.harmonyModuleDecorator
@ -280,10 +281,10 @@ class NodeModuleDecoratorRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { runtimeTemplate } = this.compilation; const { runtimeTemplate } = /** @type {Compilation} */ (this.compilation);
return Template.asString([ return Template.asString([
`${RuntimeGlobals.nodeModuleDecorator} = ${runtimeTemplate.basicFunction( `${RuntimeGlobals.nodeModuleDecorator} = ${runtimeTemplate.basicFunction(
"module", "module",

View File

@ -18,7 +18,7 @@ class CommonJsRequireContextDependency extends ContextDependency {
* @param {TODO} options options for the context module * @param {TODO} options options for the context module
* @param {Range} range location in source code * @param {Range} range location in source code
* @param {Range} valueRange location of the require call * @param {Range} valueRange location of the require call
* @param {boolean} inShorthand true, if the require call is in shorthand notation * @param {boolean | string } inShorthand true or name
* @param {string} context context * @param {string} context context
*/ */
constructor(options, range, valueRange, inShorthand, context) { constructor(options, range, valueRange, inShorthand, context) {

View File

@ -15,7 +15,7 @@ class SystemRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
return Template.asString([ return Template.asString([

View File

@ -20,7 +20,7 @@ class ExportWebpackRequireRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
return `export default ${RuntimeGlobals.require};`; return `export default ${RuntimeGlobals.require};`;

View File

@ -80,7 +80,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -14,7 +14,7 @@ class HotModuleReplacementRuntimeModule extends RuntimeModule {
super("hot module replacement", RuntimeModule.STAGE_BASIC); super("hot module replacement", RuntimeModule.STAGE_BASIC);
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
return Template.getFunctionContent( return Template.getFunctionContent(

View File

@ -36,7 +36,7 @@ class HashedModuleIdsPlugin {
/** @type {HashedModuleIdsPluginOptions} */ /** @type {HashedModuleIdsPluginOptions} */
this.options = { this.options = {
context: null, context: undefined,
hashFunction: "md4", hashFunction: "md4",
hashDigest: "base64", hashDigest: "base64",
hashDigestLength: 4, hashDigestLength: 4,

View File

@ -349,7 +349,7 @@ class JavascriptParser extends Parser {
importCall: new SyncBailHook(["expression"]), importCall: new SyncBailHook(["expression"]),
/** @type {SyncBailHook<[Expression], boolean | void>} */ /** @type {SyncBailHook<[Expression], boolean | void>} */
topLevelAwait: new SyncBailHook(["expression"]), topLevelAwait: new SyncBailHook(["expression"]),
/** @type {HookMap<SyncBailHook<[BaseCallExpression], boolean | void>>} */ /** @type {HookMap<SyncBailHook<[CallExpression], boolean | void>>} */
call: new HookMap(() => new SyncBailHook(["expression"])), call: new HookMap(() => new SyncBailHook(["expression"])),
/** Something like "a.b()" */ /** Something like "a.b()" */
/** @type {HookMap<SyncBailHook<[CallExpression, string[], boolean[], Range[]], boolean | void>>} */ /** @type {HookMap<SyncBailHook<[CallExpression, string[], boolean[], Range[]], boolean | void>>} */
@ -374,7 +374,7 @@ class JavascriptParser extends Parser {
]) ])
), ),
/** Something like "a.b().c.d()"" */ /** Something like "a.b().c.d()"" */
/** @type {HookMap<SyncBailHook<[Expression, string[], CallExpression, string[]], boolean | void>>} */ /** @type {HookMap<SyncBailHook<[CallExpression, string[], CallExpression, string[]], boolean | void>>} */
callMemberChainOfCallMemberChain: new HookMap( callMemberChainOfCallMemberChain: new HookMap(
() => () =>
new SyncBailHook([ new SyncBailHook([

View File

@ -5,7 +5,7 @@
"use strict"; "use strict";
const SyncBailHook = require("tapable/lib/SyncBailHook"); const { SyncBailHook } = require("tapable");
const { Logger } = require("./Logger"); const { Logger } = require("./Logger");
const createConsoleLogger = require("./createConsoleLogger"); const createConsoleLogger = require("./createConsoleLogger");

View File

@ -46,7 +46,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { chunkGraph, chunk } = this; const { chunkGraph, chunk } = this;

View File

@ -46,7 +46,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { chunkGraph, chunk } = this; const { chunkGraph, chunk } = this;

View File

@ -16,6 +16,7 @@ const InnerGraph = require("./InnerGraph");
/** @typedef {import("estree").ClassExpression} ClassExpressionNode */ /** @typedef {import("estree").ClassExpression} ClassExpressionNode */
/** @typedef {import("estree").Node} Node */ /** @typedef {import("estree").Node} Node */
/** @typedef {import("estree").VariableDeclarator} VariableDeclaratorNode */ /** @typedef {import("estree").VariableDeclarator} VariableDeclaratorNode */
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
/** @typedef {import("../Compiler")} Compiler */ /** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../Dependency")} Dependency */ /** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../dependencies/HarmonyImportSpecifierDependency")} HarmonyImportSpecifierDependency */ /** @typedef {import("../dependencies/HarmonyImportSpecifierDependency")} HarmonyImportSpecifierDependency */
@ -46,7 +47,7 @@ class InnerGraphPlugin {
/** /**
* @param {JavascriptParser} parser the parser * @param {JavascriptParser} parser the parser
* @param {Object} parserOptions options * @param {JavascriptParserOptions} parserOptions options
* @returns {void} * @returns {void}
*/ */
const handler = (parser, parserOptions) => { const handler = (parser, parserOptions) => {

View File

@ -24,7 +24,7 @@ class ChunkPrefetchFunctionRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { runtimeFunction, runtimeHandlers } = this; const { runtimeFunction, runtimeHandlers } = this;

View File

@ -22,7 +22,7 @@ class ChunkPrefetchStartupRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { startupChunks } = this; const { startupChunks } = this;

View File

@ -21,7 +21,7 @@ class ChunkPrefetchTriggerRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { chunkMap } = this; const { chunkMap } = this;

View File

@ -21,7 +21,7 @@ class ChunkPreloadTriggerRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { chunkMap } = this; const { chunkMap } = this;

View File

@ -16,7 +16,7 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -18,7 +18,7 @@ class AutoPublicPathRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -17,7 +17,7 @@ class BaseUriRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const chunk = /** @type {Chunk} */ (this.chunk); const chunk = /** @type {Chunk} */ (this.chunk);

View File

@ -17,7 +17,7 @@ class ChunkNameRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
return `${RuntimeGlobals.chunkName} = ${JSON.stringify(this.chunkName)};`; return `${RuntimeGlobals.chunkName} = ${JSON.stringify(this.chunkName)};`;

View File

@ -16,7 +16,7 @@ class CompatGetDefaultExportRuntimeModule extends HelperRuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -19,7 +19,7 @@ class CompatRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -16,7 +16,7 @@ class CreateFakeNamespaceObjectRuntimeModule extends HelperRuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -16,7 +16,7 @@ class CreateScriptRuntimeModule extends HelperRuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -16,7 +16,7 @@ class CreateScriptUrlRuntimeModule extends HelperRuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -16,7 +16,7 @@ class DefinePropertyGettersRuntimeModule extends HelperRuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -20,7 +20,7 @@ class EnsureChunkRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -35,7 +35,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { global, contentType, getFilenameForChunk, allChunks } = this; const { global, contentType, getFilenameForChunk, allChunks } = this;

View File

@ -16,7 +16,7 @@ class GetFullHashRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -24,7 +24,7 @@ class GetMainFilenameRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { global, filename } = this; const { global, filename } = this;

View File

@ -20,7 +20,7 @@ class GetTrustedTypesPolicyRuntimeModule extends HelperRuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -14,7 +14,7 @@ class GlobalRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
return Template.asString([ return Template.asString([

View File

@ -17,7 +17,7 @@ class HasOwnPropertyRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -53,7 +53,7 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -16,7 +16,7 @@ class MakeNamespaceObjectRuntimeModule extends HelperRuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -14,7 +14,7 @@ class NonceRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
return `${RuntimeGlobals.scriptNonce} = undefined;`; return `${RuntimeGlobals.scriptNonce} = undefined;`;

View File

@ -16,7 +16,7 @@ class OnChunksLoadedRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -20,7 +20,7 @@ class PublicPathRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const { publicPath } = this; const { publicPath } = this;

View File

@ -16,7 +16,7 @@ class RelativeUrlRuntimeModule extends HelperRuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -16,7 +16,7 @@ class RuntimeIdRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph); const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);

View File

@ -23,7 +23,7 @@ class StartupChunkDependenciesRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph); const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);

View File

@ -20,7 +20,7 @@ class StartupEntrypointRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -15,7 +15,7 @@ class SystemContextRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
return `${RuntimeGlobals.systemContext} = __system_context__;`; return `${RuntimeGlobals.systemContext} = __system_context__;`;

View File

@ -32,7 +32,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -23,7 +23,7 @@ class ShareRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -29,7 +29,7 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -226,7 +226,7 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const fn = RuntimeGlobals.ensureChunkHandlers; const fn = RuntimeGlobals.ensureChunkHandlers;

View File

@ -70,7 +70,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -59,7 +59,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
} }
/** /**
* @returns {string} runtime code * @returns {string | null} runtime code
*/ */
generate() { generate() {
const compilation = /** @type {Compilation} */ (this.compilation); const compilation = /** @type {Compilation} */ (this.compilation);

View File

@ -39,6 +39,7 @@
"@babel/core": "^7.21.4", "@babel/core": "^7.21.4",
"@babel/preset-react": "^7.18.6", "@babel/preset-react": "^7.18.6",
"@types/jest": "^29.5.0", "@types/jest": "^29.5.0",
"@types/mime-types": "^2.1.1",
"@types/node": "^20.1.7", "@types/node": "^20.1.7",
"assemblyscript": "^0.27.2", "assemblyscript": "^0.27.2",
"babel-loader": "^8.1.0", "babel-loader": "^8.1.0",

61
types.d.ts vendored
View File

@ -13,7 +13,6 @@ import {
AssignmentPattern, AssignmentPattern,
AssignmentProperty, AssignmentProperty,
AwaitExpression, AwaitExpression,
BaseCallExpression,
BigIntLiteral, BigIntLiteral,
BinaryExpression, BinaryExpression,
BlockStatement, BlockStatement,
@ -4232,7 +4231,11 @@ declare interface ExternalItemObjectUnknown {
} }
type ExternalItemValue = string | boolean | string[] | { [index: string]: any }; type ExternalItemValue = string | boolean | string[] | { [index: string]: any };
declare class ExternalModule extends Module { declare class ExternalModule extends Module {
constructor(request?: any, type?: any, userRequest?: any); constructor(
request: string | string[] | Record<string, string | string[]>,
type: any,
userRequest: string
);
request: string | string[] | Record<string, string | string[]>; request: string | string[] | Record<string, string | string[]>;
externalType: string; externalType: string;
userRequest: string; userRequest: string;
@ -4348,6 +4351,9 @@ declare interface FactorizeModuleOptions {
contextInfo?: Partial<ModuleFactoryCreateDataContextInfo>; contextInfo?: Partial<ModuleFactoryCreateDataContextInfo>;
context?: string; context?: string;
} }
declare interface FactoryMeta {
sideEffectFree?: boolean;
}
type FakeHook<T> = T & FakeHookMarker; type FakeHook<T> = T & FakeHookMarker;
declare interface FakeHookMarker {} declare interface FakeHookMarker {}
declare interface FallbackCacheGroup { declare interface FallbackCacheGroup {
@ -5119,8 +5125,8 @@ declare abstract class InitFragment<Context> {
endContent?: string | Source; endContent?: string | Source;
getContent(context: Context): string | Source; getContent(context: Context): string | Source;
getEndContent(context: Context): undefined | string | Source; getEndContent(context: Context): undefined | string | Source;
serialize(context?: any): void; serialize(context: ObjectSerializerContext): void;
deserialize(context?: any): void; deserialize(context: ObjectDeserializerContext): void;
merge: any; merge: any;
} }
declare interface InputFileSystem { declare interface InputFileSystem {
@ -5502,7 +5508,7 @@ declare class JavascriptParser extends Parser {
typeof: HookMap<SyncBailHook<[Expression], boolean | void>>; typeof: HookMap<SyncBailHook<[Expression], boolean | void>>;
importCall: SyncBailHook<[ImportExpression], boolean | void>; importCall: SyncBailHook<[ImportExpression], boolean | void>;
topLevelAwait: SyncBailHook<[Expression], boolean | void>; topLevelAwait: SyncBailHook<[Expression], boolean | void>;
call: HookMap<SyncBailHook<[BaseCallExpression], boolean | void>>; call: HookMap<SyncBailHook<[CallExpression], boolean | void>>;
callMemberChain: HookMap< callMemberChain: HookMap<
SyncBailHook< SyncBailHook<
[CallExpression, string[], boolean[], [number, number][]], [CallExpression, string[], boolean[], [number, number][]],
@ -5517,7 +5523,7 @@ declare class JavascriptParser extends Parser {
>; >;
callMemberChainOfCallMemberChain: HookMap< callMemberChainOfCallMemberChain: HookMap<
SyncBailHook< SyncBailHook<
[Expression, string[], CallExpression, string[]], [CallExpression, string[], CallExpression, string[]],
boolean | void boolean | void
> >
>; >;
@ -6884,14 +6890,45 @@ declare interface LibIdentOptions {
associatedObjectForCache?: Object; associatedObjectForCache?: Object;
} }
declare class LibManifestPlugin { declare class LibManifestPlugin {
constructor(options?: any); constructor(options: LibManifestPluginOptions);
options: any; options: LibManifestPluginOptions;
/** /**
* Apply the plugin * Apply the plugin
*/ */
apply(compiler: Compiler): void; apply(compiler: Compiler): void;
} }
declare interface LibManifestPluginOptions {
/**
* Context of requests in the manifest file (defaults to the webpack context).
*/
context?: string;
/**
* If true, only entry points will be exposed (default: true).
*/
entryOnly?: boolean;
/**
* If true, manifest json file (output) will be formatted.
*/
format?: boolean;
/**
* Name of the exposed dll function (external name, use value of 'output.library').
*/
name?: string;
/**
* Absolute path to the manifest json file (output).
*/
path: string;
/**
* Type of the dll bundle (external type, use value of 'output.libraryTarget').
*/
type?: string;
}
declare interface LibraryContext<T> { declare interface LibraryContext<T> {
compilation: Compilation; compilation: Compilation;
chunkGraph: ChunkGraph; chunkGraph: ChunkGraph;
@ -7470,7 +7507,7 @@ declare class Module extends DependenciesBlock {
needId: boolean; needId: boolean;
debugId: number; debugId: number;
resolveOptions?: ResolveOptionsWebpackOptions; resolveOptions?: ResolveOptionsWebpackOptions;
factoryMeta?: object; factoryMeta?: FactoryMeta;
useSourceMap: boolean; useSourceMap: boolean;
useSimpleSourceMap: boolean; useSimpleSourceMap: boolean;
buildMeta?: BuildMeta; buildMeta?: BuildMeta;
@ -8042,7 +8079,7 @@ declare abstract class ModuleProfile {
storingEndTime: number; storingEndTime: number;
storing: number; storing: number;
storingParallelismFactor: number; storingParallelismFactor: number;
additionalFactoryTimes: any; additionalFactoryTimes?: { start: number; end: number }[];
additionalFactories: number; additionalFactories: number;
additionalFactoriesParallelismFactor: number; additionalFactoriesParallelismFactor: number;
additionalIntegration: number; additionalIntegration: number;
@ -11151,8 +11188,8 @@ declare class RuntimeModule extends Module {
fullHash: boolean; fullHash: boolean;
dependentHash: boolean; dependentHash: boolean;
attach(compilation: Compilation, chunk: Chunk, chunkGraph?: ChunkGraph): void; attach(compilation: Compilation, chunk: Chunk, chunkGraph?: ChunkGraph): void;
generate(): string; generate(): null | string;
getGeneratedCode(): string; getGeneratedCode(): null | string;
shouldIsolate(): boolean; shouldIsolate(): boolean;
/** /**

View File

@ -1150,6 +1150,11 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==
"@types/mime-types@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@types/mime-types/-/mime-types-2.1.1.tgz#d9ba43490fa3a3df958759adf69396c3532cf2c1"
integrity sha512-vXOTGVSLR2jMw440moWTC7H19iUyLtP3Z1YTj7cSsubOICinjMxFeb/V57v9QdyyPGbbWolUFSSmSiRSn94tFw==
"@types/minimist@^1.2.2": "@types/minimist@^1.2.2":
version "1.2.2" version "1.2.2"
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c" resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c"