fix: types

This commit is contained in:
Alexander Akait 2025-09-09 18:41:52 +03:00 committed by GitHub
parent c52d8b3b75
commit cc8e6a195a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
45 changed files with 504 additions and 414 deletions

1
declarations.d.ts vendored
View File

@ -1,4 +1,3 @@
type TODO = any;
type EXPECTED_ANY = any;
type EXPECTED_FUNCTION = Function;
type EXPECTED_OBJECT = object;

View File

@ -10,8 +10,9 @@ import type Hash from "../lib/util/Hash";
import type { InputFileSystem } from "../lib/util/fs";
import type { Logger } from "../lib/logging/Logger";
import type {
ImportModuleOptions,
ImportModuleCallback,
ImportModuleOptions
ExecuteModuleExports
} from "../lib/dependencies/LoaderPlugin";
import type { Resolver } from "enhanced-resolve";
import type {
@ -92,7 +93,10 @@ export interface LoaderPluginLoaderContext {
options: ImportModuleOptions | undefined,
callback: ImportModuleCallback
): void;
importModule(request: string, options?: ImportModuleOptions): Promise<any>;
importModule(
request: string,
options?: ImportModuleOptions
): Promise<ExecuteModuleExports>;
}
/** The properties are added by https://github.com/webpack/loader-runner */

View File

@ -19,7 +19,19 @@ const ConstDependency = require("./dependencies/ConstDependency");
/** @typedef {import("./dependencies/ContextDependency")} ContextDependency */
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
/** @typedef {import("./javascript/JavascriptParser").TagData} TagData */
/**
* @typedef {object} CompatibilitySettingsDeclaration
* @property {boolean} updated
* @property {DependencyLocation} loc
* @property {Range} range
*/
/**
* @typedef {object} CompatibilitySettings
* @property {string} name
* @property {CompatibilitySettingsDeclaration} declaration
*/
const nestedWebpackIdentifierTag = Symbol("nested webpack identifier");
const PLUGIN_NAME = "CompatibilityPlugin";
@ -103,7 +115,8 @@ class CompatibilityPlugin {
statement.id.name === RuntimeGlobals.require
) {
const newName = `__nested_webpack_require_${
/** @type {Range} */ (statement.range)[0]
/** @type {Range} */
(statement.range)[0]
}__`;
parser.tagVariable(
statement.id.name,
@ -112,8 +125,8 @@ class CompatibilityPlugin {
name: newName,
declaration: {
updated: false,
loc: statement.id.loc,
range: statement.id.range
loc: /** @type {DependencyLocation} */ (statement.id.loc),
range: /** @type {Range} */ (statement.id.range)
}
}
);
@ -130,8 +143,8 @@ class CompatibilityPlugin {
name: newName,
declaration: {
updated: false,
loc: pattern.loc,
range: pattern.range
loc: /** @type {DependencyLocation} */ (pattern.loc),
range: /** @type {Range} */ (pattern.range)
}
});
return true;
@ -143,8 +156,8 @@ class CompatibilityPlugin {
name: "__nested_webpack_exports__",
declaration: {
updated: false,
loc: pattern.loc,
range: pattern.range
loc: /** @type {DependencyLocation} */ (pattern.loc),
range: /** @type {Range} */ (pattern.range)
}
});
return true;
@ -153,7 +166,7 @@ class CompatibilityPlugin {
.for(nestedWebpackIdentifierTag)
.tap(PLUGIN_NAME, (expr) => {
const { name, declaration } =
/** @type {TagData} */
/** @type {CompatibilitySettings} */
(parser.currentTagData);
if (!declaration.updated) {
const dep = new ConstDependency(name, declaration.range);

View File

@ -721,7 +721,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
processAssetsHook.tapAsync(
getOptions(options),
(assets, callback) =>
/** @type {TODO} */ (fn)(...getArgs(), callback)
/** @type {EXPECTED_ANY} */ (fn)(...getArgs(), callback)
);
},
/** @type {AsyncSeriesHook<T>["tapPromise"]} */
@ -1087,9 +1087,13 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
this.moduleMemCaches = undefined;
/** @type {ModuleMemCaches | undefined} */
this.moduleMemCaches2 = undefined;
/** @type {ModuleGraph} */
this.moduleGraph = new ModuleGraph();
/** @type {ChunkGraph} */
this.chunkGraph = /** @type {TODO} */ (undefined);
this.chunkGraph = new ChunkGraph(
this.moduleGraph,
this.outputOptions.hashFunction
);
/** @type {CodeGenerationResults | undefined} */
this.codeGenerationResults = undefined;
@ -3128,15 +3132,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
this.addModuleQueue.clear();
return callback(err);
};
const chunkGraph = new ChunkGraph(
this.moduleGraph,
this.outputOptions.hashFunction
);
this.chunkGraph = chunkGraph;
if (this._backCompat) {
for (const module of this.modules) {
ChunkGraph.setChunkGraphForModule(module, chunkGraph);
ChunkGraph.setChunkGraphForModule(module, this.chunkGraph);
}
}
@ -3181,7 +3180,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
const module = this.moduleGraph.getModule(dep);
if (module) {
chunkGraph.connectChunkAndEntryModule(chunk, module, entrypoint);
this.chunkGraph.connectChunkAndEntryModule(chunk, module, entrypoint);
entryModules.add(module);
const modulesList = chunkGraphInit.get(entrypoint);
if (modulesList === undefined) {

View File

@ -82,6 +82,7 @@ const webpack = require(".");
* @param {Error | null} err
* @param {Chunk[]=} entries
* @param {Compilation=} compilation
* @returns {void}
*/
/**

View File

@ -97,6 +97,7 @@ const makeSerializable = require("./util/makeSerializable");
* @callback ResolveDependenciesCallback
* @param {Error | null} err
* @param {ContextElementDependency[]=} dependencies
* @returns {void}
*/
/**

View File

@ -45,7 +45,7 @@ const { join } = require("./util/fs");
*/
/** @typedef {ContextResolveData & ContextOptions} BeforeContextResolveData */
/** @typedef {BeforeContextResolveData & { resource: TODO, resourceQuery: string | undefined, resourceFragment: string | undefined, resolveDependencies: ContextModuleFactory["resolveDependencies"] }} AfterContextResolveData */
/** @typedef {BeforeContextResolveData & { resource: string | string[], resourceQuery: string | undefined, resourceFragment: string | undefined, resolveDependencies: ContextModuleFactory["resolveDependencies"] }} AfterContextResolveData */
const EMPTY_RESOLVE_OPTIONS = {};
@ -228,7 +228,7 @@ class ContextModuleFactory extends ModuleFactory {
},
(err, result) => {
if (err) return callback(err);
callback(null, /** @type {string} */ (result));
callback(null, result);
}
);
},
@ -355,6 +355,7 @@ class ContextModuleFactory extends ModuleFactory {
* @param {string} directory directory
* @param {(context: string, subResource: string, callback: () => void) => void} addSubDirectory addSubDirectoryFn
* @param {ResolveDependenciesCallback} callback callback
* @returns {void}
*/
const addDirectory = (ctx, directory, addSubDirectory, callback) => {
fs.readdir(directory, (err, files) => {

View File

@ -124,7 +124,14 @@ class ContextReplacementPlugin {
});
cmf.hooks.afterResolve.tap(PLUGIN_NAME, (result) => {
if (!result) return;
if (resourceRegExp.test(result.resource)) {
const isMatchResourceRegExp = () => {
if (Array.isArray(result.resource)) {
return result.resource.some((item) => resourceRegExp.test(item));
}
return resourceRegExp.test(result.resource);
};
if (isMatchResourceRegExp()) {
if (newContentResource !== undefined) {
if (
newContentResource.startsWith("/") ||
@ -132,10 +139,15 @@ class ContextReplacementPlugin {
) {
result.resource = newContentResource;
} else {
const rootPath =
typeof result.resource === "string"
? result.resource
: /** @type {string} */
(result.resource.find((item) => resourceRegExp.test(item)));
result.resource = join(
/** @type {InputFileSystem} */
(compiler.inputFileSystem),
result.resource,
rootPath,
newContentResource
);
}
@ -155,19 +167,28 @@ class ContextReplacementPlugin {
if (typeof newContentCallback === "function") {
const origResource = result.resource;
newContentCallback(result);
if (result.resource !== origResource) {
const newResource = Array.isArray(result.resource)
? result.resource
: [result.resource];
for (let i = 0; i < newResource.length; i++) {
if (
result.resource !== origResource &&
!result.resource.startsWith("/") &&
(result.resource.length <= 1 || result.resource[1] !== ":")
!newResource[i].startsWith("/") &&
(newResource[i].length <= 1 || newResource[i][1] !== ":")
) {
// When the function changed it to an relative path
result.resource = join(
newResource[i] = join(
/** @type {InputFileSystem} */
(compiler.inputFileSystem),
origResource,
result.resource
origResource[i],
newResource[i]
);
}
}
result.resource = newResource;
}
} else {
for (const d of result.dependencies) {
if (d.critical) d.critical = false;

View File

@ -108,7 +108,7 @@ class ExportsInfo {
constructor() {
/** @type {Exports} */
this._exports = new Map();
this._otherExportsInfo = new ExportInfo(/** @type {TODO} */ (null));
this._otherExportsInfo = new ExportInfo(null);
this._sideEffectsOnlyInfo = new ExportInfo("*side effects only*");
this._exportsAreOrdered = false;
/** @type {ExportsInfo=} */
@ -847,12 +847,12 @@ class ExportsInfo {
class ExportInfo {
/**
* @param {ExportInfoName} name the original name of the export
* @param {ExportInfoName | null} name the original name of the export
* @param {ExportInfo=} initFrom init values from this ExportInfo
*/
constructor(name, initFrom) {
/** @type {ExportInfoName} */
this.name = name;
this.name = /** @type {ExportInfoName} */ (name);
/**
* @private
* @type {ExportInfoUsedName}

View File

@ -98,7 +98,7 @@ const makeSerializable = require("./util/makeSerializable");
/** @typedef {Set<string>} RuntimeRequirements */
/** @typedef {ReadonlySet<string>} ReadOnlyRuntimeRequirements */
/** @typedef {Map<"topLevelDeclarations", Set<string>> & Map<"chunkInitFragments", InitFragment<TODO>[]>} KnownCodeGenerationResultDataForJavascriptModules */
/** @typedef {Map<"topLevelDeclarations", Set<string>> & Map<"chunkInitFragments", InitFragment<EXPECTED_ANY>[]>} KnownCodeGenerationResultDataForJavascriptModules */
/** @typedef {Map<"url", { ["css-url"]: string }>} KnownCodeGenerationResultDataForCssModules */
/** @typedef {Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"fullContentHash", string>} KnownCodeGenerationResultDataForAssetModules */
/** @typedef {Map<"share-init", [{ shareScope: string, initStage: number, init: string }]>} KnownCodeGenerationResultForSharing */

View File

@ -44,6 +44,7 @@ const ArrayQueue = require("./util/ArrayQueue");
* @callback RunWithDependenciesHandler
* @param {Compiler} compiler
* @param {Callback<MultiStats>} callback
* @returns {void}
*/
/**

View File

@ -308,13 +308,13 @@ class NormalModuleFactory extends ModuleFactory {
module: new SyncWaterfallHook(["module", "createData", "resolveData"]),
/** @type {HookMap<SyncBailHook<[ParserOptions], Parser | void>>} */
createParser: new HookMap(() => new SyncBailHook(["parserOptions"])),
/** @type {HookMap<SyncBailHook<[TODO, ParserOptions], void>>} */
/** @type {HookMap<SyncBailHook<[EXPECTED_ANY, ParserOptions], void>>} */
parser: new HookMap(() => new SyncHook(["parser", "parserOptions"])),
/** @type {HookMap<SyncBailHook<[GeneratorOptions], Generator | void>>} */
createGenerator: new HookMap(
() => new SyncBailHook(["generatorOptions"])
),
/** @type {HookMap<SyncBailHook<[TODO, GeneratorOptions], void>>} */
/** @type {HookMap<SyncBailHook<[EXPECTED_ANY, GeneratorOptions], void>>} */
generator: new HookMap(
() => new SyncHook(["generator", "generatorOptions"])
),

View File

@ -144,6 +144,9 @@ class Profiler {
return Promise.resolve();
}
/**
* @returns {Promise<{ profile: { startTime: number, endTime: number } }>} profile result
*/
stopProfiling() {
return this.sendCommand("Profiler.stop").then(({ profile }) => {
const hrtime = process.hrtime();
@ -280,7 +283,10 @@ class ProfilingPlugin {
(hookName)
];
if (hook) {
hook.intercept(makeInterceptorFor("Resolver", tracer)(hookName));
hook.intercept(
/** @type {EXPECTED_ANY} */
(makeInterceptorFor("Resolver", tracer)(hookName))
);
}
}
@ -467,9 +473,10 @@ const interceptAllCssModulesPluginHooks = (compilation, tracer) => {
/** @typedef {(...args: EXPECTED_ANY[]) => EXPECTED_ANY | Promise<(...args: EXPECTED_ANY[]) => EXPECTED_ANY>} PluginFunction */
/**
* @template T
* @param {string} instance instance
* @param {Trace} tracer tracer
* @returns {(hookName: string) => TODO} interceptor
* @returns {(hookName: string) => HookInterceptor<EXPECTED_ANY, EXPECTED_ANY>} interceptor
*/
const makeInterceptorFor = (instance, tracer) => (hookName) => ({
/**

View File

@ -39,6 +39,12 @@ const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency
/** @typedef {import("../javascript/JavascriptParser").ImportSource} ImportSource */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/**
* @typedef {object} CommonJsImportSettings
* @property {string=} name
* @property {string} context
*/
const createRequireSpecifierTag = Symbol("createRequire");
const createdRequireIdentifierTag = Symbol("createRequire()");
@ -58,10 +64,11 @@ class CommonJsImportsParserPlugin {
*/
apply(parser) {
const options = this.options;
const getContext = () => {
if (parser.currentTagData) {
const { context } = parser.currentTagData;
const { context } =
/** @type {CommonJsImportSettings} */
(parser.currentTagData);
return context;
}
};

View File

@ -20,7 +20,7 @@ class CommonJsRequireContextDependency extends ContextDependency {
* @param {Range} range location in source code
* @param {Range | undefined} valueRange location of the require call
* @param {boolean | string } inShorthand true or name
* @param {string} context context
* @param {string=} context context
*/
constructor(options, range, valueRange, inShorthand, context) {
super(options, context);

View File

@ -10,6 +10,7 @@ const DependencyTemplate = require("../DependencyTemplate");
const makeSerializable = require("../util/makeSerializable");
const memoize = require("../util/memoize");
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../ContextModule").ContextOptions} ContextOptions */
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
@ -23,6 +24,8 @@ const getCriticalDependencyWarning = memoize(() =>
/** @typedef {ContextOptions & { request: string }} ContextDependencyOptions */
/** @typedef {{ value: string, range: Range }[]} Replaces */
/**
* @param {RegExp | false | null | undefined} r regexp
* @returns {string} stringified regexp
@ -52,12 +55,15 @@ class ContextDependency extends Dependency {
this.hadGlobalOrStickyRegExp = true;
}
/** @type {string | undefined} */
this.request = undefined;
/** @type {Range | undefined} */
this.range = undefined;
/** @type {Range | undefined} */
this.valueRange = undefined;
/** @type {boolean | string | undefined} */
this.inShorthand = undefined;
// TODO refactor this
/** @type {Replaces | undefined} */
this.replaces = undefined;
this._requestContext = context;
}
@ -142,7 +148,6 @@ class ContextDependency extends Dependency {
write(this._requestContext);
write(this.range);
write(this.valueRange);
write(this.prepend);
write(this.replaces);
super.serialize(context);
@ -162,7 +167,6 @@ class ContextDependency extends Dependency {
this._requestContext = read();
this.range = read();
this.valueRange = read();
this.prepend = read();
this.replaces = read();
super.deserialize(context);

View File

@ -15,6 +15,7 @@ const { parseResource } = require("../util/identifier");
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("./ContextDependency")} ContextDependency */
/** @typedef {import("./ContextDependency").ContextDependencyOptions} ContextDependencyOptions */
/** @typedef {import("./ContextDependency").Replaces} Replaces */
/**
* Escapes regular expression metacharacters
@ -118,7 +119,7 @@ module.exports.create = (
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
/** @type {{ value: string, range: Range }[]} */
/** @type {Replaces} */
const replaces = [];
const parts = /** @type {BasicEvaluatedExpression[]} */ (param.parts);

View File

@ -8,6 +8,7 @@
const ContextDependency = require("./ContextDependency");
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
@ -28,11 +29,13 @@ class ContextDependencyTemplateAsId extends ContextDependency.Template {
const moduleExports = runtimeTemplate.moduleExports({
module,
chunkGraph,
request: dep.request,
request: /** @type {string} */ (dep.request),
weak: dep.weak,
runtimeRequirements
});
const range = /** @type {Range} */ (dep.range);
if (module) {
if (dep.valueRange) {
if (Array.isArray(dep.replaces)) {
@ -41,21 +44,18 @@ class ContextDependencyTemplateAsId extends ContextDependency.Template {
source.replace(rep.range[0], rep.range[1] - 1, rep.value);
}
}
source.replace(dep.valueRange[1], dep.range[1] - 1, ")");
source.replace(dep.valueRange[1], range[1] - 1, ")");
source.replace(
dep.range[0],
range[0],
dep.valueRange[0] - 1,
`${moduleExports}.resolve(`
);
} else {
source.replace(
dep.range[0],
dep.range[1] - 1,
`${moduleExports}.resolve`
);
source.replace(range[0], range[1] - 1, `${moduleExports}.resolve`);
}
} else {
source.replace(dep.range[0], dep.range[1] - 1, moduleExports);
source.replace(range[0], range[1] - 1, moduleExports);
}
}
}

View File

@ -8,6 +8,7 @@
const ContextDependency = require("./ContextDependency");
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
@ -27,13 +28,16 @@ class ContextDependencyTemplateAsRequireCall extends ContextDependency.Template
let moduleExports = runtimeTemplate.moduleExports({
module: moduleGraph.getModule(dep),
chunkGraph,
request: dep.request,
request: /** @type {string} */ (dep.request),
runtimeRequirements
});
if (dep.inShorthand) {
moduleExports = `${dep.inShorthand}: ${moduleExports}`;
}
const range = /** @type {Range} */ (dep.range);
if (moduleGraph.getModule(dep)) {
if (dep.valueRange) {
if (Array.isArray(dep.replaces)) {
@ -42,17 +46,13 @@ class ContextDependencyTemplateAsRequireCall extends ContextDependency.Template
source.replace(rep.range[0], rep.range[1] - 1, rep.value);
}
}
source.replace(dep.valueRange[1], dep.range[1] - 1, ")");
source.replace(
dep.range[0],
dep.valueRange[0] - 1,
`${moduleExports}(`
);
source.replace(dep.valueRange[1], range[1] - 1, ")");
source.replace(range[0], dep.valueRange[0] - 1, `${moduleExports}(`);
} else {
source.replace(dep.range[0], dep.range[1] - 1, moduleExports);
source.replace(range[0], range[1] - 1, moduleExports);
}
} else {
source.replace(dep.range[0], dep.range[1] - 1, moduleExports);
source.replace(range[0], range[1] - 1, moduleExports);
}
}
}

View File

@ -33,7 +33,7 @@ class HarmonyEvaluatedImportSpecifierDependency extends HarmonyImportSpecifierDe
* @param {string[]} ids ids
* @param {string} name name
* @param {Range} range location in source code
* @param {ImportAttributes} attributes import assertions
* @param {ImportAttributes | undefined} attributes import assertions
* @param {string} operator operator
*/
constructor(request, sourceOrder, ids, name, range, attributes, operator) {

View File

@ -25,6 +25,7 @@ const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDepe
/** @typedef {import("../javascript/JavascriptParser").ClassDeclaration} ClassDeclaration */
/** @typedef {import("../javascript/JavascriptParser").FunctionDeclaration} FunctionDeclaration */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
const { HarmonyStarExportsList } = HarmonyExportImportedSpecifierDependency;
@ -156,7 +157,9 @@ module.exports = class HarmonyExportDependencyParserPlugin {
parser.hooks.exportSpecifier.tap(
PLUGIN_NAME,
(statement, id, name, idx) => {
const settings = parser.getTagData(id, harmonySpecifierTag);
const settings =
/** @type {HarmonySettings} */
(parser.getTagData(id, harmonySpecifierTag));
const harmonyNamedExports = (parser.state.harmonyNamedExports =
parser.state.harmonyNamedExports || new Set());
harmonyNamedExports.add(name);

View File

@ -24,25 +24,15 @@ const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDepend
/** @typedef {import("estree").Expression} Expression */
/** @typedef {import("estree").Identifier} Identifier */
/** @typedef {import("estree").Literal} Literal */
/** @typedef {import("estree").MemberExpression} MemberExpression */
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
/** @typedef {import("estree").Property} Property */
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
/** @typedef {import("../javascript/JavascriptParser").ExportAllDeclaration} ExportAllDeclaration */
/** @typedef {import("../javascript/JavascriptParser").ExportNamedDeclaration} ExportNamedDeclaration */
/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
/** @typedef {import("../javascript/JavascriptParser").ImportDeclaration} ImportDeclaration */
/** @typedef {import("../javascript/JavascriptParser").ImportExpression} ImportExpression */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../javascript/JavascriptParser").TagData} TagData */
/** @typedef {import("../optimize/InnerGraph").InnerGraph} InnerGraph */
/** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */
/** @typedef {import("./HarmonyImportDependency")} HarmonyImportDependency */
const harmonySpecifierTag = Symbol("harmony import");
@ -158,14 +148,18 @@ module.exports = class HarmonyImportDependencyParserPlugin {
const defer = this.deferImport
? getImportMode(parser, statement).defer
: false;
parser.tagVariable(name, harmonySpecifierTag, {
parser.tagVariable(
name,
harmonySpecifierTag,
/** @type {HarmonySettings} */ ({
name,
source,
ids,
sourceOrder: parser.state.lastHarmonyImportOrder,
attributes: getImportAttributes(statement),
defer
});
})
);
return true;
}
);
@ -191,7 +185,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
return;
}
const settings =
/** @type {TagData} */
/** @type {HarmonySettings} */
(rootInfo.tagInfo.data);
const members =
/** @type {(() => string[])} */

View File

@ -23,6 +23,7 @@ const LoaderImportDependency = require("./LoaderImportDependency");
* @callback ImportModuleCallback
* @param {(Error | null)=} err error object
* @param {ExecuteModuleExports=} exports exports of the evaluated module
* @returns {void}
*/
/**

View File

@ -36,6 +36,8 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").PrivateIdentifier} PrivateIdentifier */
/** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
/** @typedef {import("estree").Expression} Expression */
/** @typedef {import("estree").ImportAttribute} ImportAttribute */
/** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
/** @typedef {import("estree").Identifier} Identifier */
/** @typedef {import("estree").VariableDeclaration} VariableDeclaration */
/** @typedef {import("estree").IfStatement} IfStatement */
@ -74,6 +76,8 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").WhileStatement} WhileStatement */
/** @typedef {import("estree").ArrowFunctionExpression} ArrowFunctionExpression */
/** @typedef {import("estree").ExpressionStatement} ExpressionStatement */
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
/** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
/** @typedef {import("estree").DoWhileStatement} DoWhileStatement */
/** @typedef {import("estree").TryStatement} TryStatement */
@ -87,6 +91,7 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").TaggedTemplateExpression} TaggedTemplateExpression */
/** @typedef {import("estree").TemplateLiteral} TemplateLiteral */
/** @typedef {import("estree").AssignmentProperty} AssignmentProperty */
/** @typedef {import("estree").ModuleDeclaration} ModuleDeclaration */
/** @typedef {import("estree").MaybeNamedFunctionDeclaration} MaybeNamedFunctionDeclaration */
/** @typedef {import("estree").MaybeNamedClassDeclaration} MaybeNamedClassDeclaration */
/**
@ -105,12 +110,7 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {Set<DestructuringAssignmentProperty>} DestructuringAssignmentProperties */
// TODO remove cast when @types/estree has been updated to import assertions
/** @typedef {import("estree").BaseNode & { type: "ImportAttribute", key: Identifier | Literal, value: Literal }} ImportAttribute */
/** @typedef {import("estree").ImportDeclaration & { attributes?: ImportAttribute[], phase?: "defer" }} ImportDeclaration */
/** @typedef {import("estree").ExportNamedDeclaration & { attributes?: ImportAttribute[] }} ExportNamedDeclaration */
/** @typedef {import("estree").ExportAllDeclaration & { attributes?: ImportAttribute[] }} ExportAllDeclaration */
/** @typedef {import("estree").ImportExpression & { options?: Expression | null, phase?: "defer" }} ImportExpression */
/** @typedef {ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration} ModuleDeclaration */
/** @type {string[]} */
const EMPTY_ARRAY = [];
@ -304,7 +304,15 @@ class VariableInfo {
/** @typedef {Omit<AcornOptions, "sourceType" | "ecmaVersion"> & { sourceType: "module" | "script" | "auto", ecmaVersion?: AcornOptions["ecmaVersion"] }} ParseOptions */
/** @typedef {symbol} Tag */
/** @typedef {Record<string, TODO>} TagData */
/** @typedef {import("../dependencies/HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
/** @typedef {import("../dependencies/ImportParserPlugin").ImportSettings} ImportSettings */
/** @typedef {import("../dependencies/CommonJsImportsParserPlugin").CommonJsImportSettings} CommonJsImportSettings */
/** @typedef {import("../CompatibilityPlugin").CompatibilitySettings} CompatibilitySettings */
/** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */
/** @typedef {HarmonySettings | ImportSettings | CommonJsImportSettings | TopLevelSymbol | CompatibilitySettings} KnownTagData */
/** @typedef {KnownTagData & Record<string, EXPECTED_ANY>} TagData */
/**
* @typedef {object} TagInfo
@ -619,9 +627,9 @@ class JavascriptParser extends Parser {
});
this.sourceType = sourceType;
/** @type {ScopeInfo} */
this.scope = /** @type {TODO} */ (undefined);
this.scope = /** @type {EXPECTED_ANY} */ (undefined);
/** @type {ParserState} */
this.state = /** @type {TODO} */ (undefined);
this.state = /** @type {EXPECTED_ANY} */ (undefined);
/** @type {Comment[] | undefined} */
this.comments = undefined;
/** @type {Set<number> | undefined} */
@ -4098,7 +4106,7 @@ class JavascriptParser extends Parser {
* @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
* @param {ExportedVariableInfo} info variable info
* @param {((name: string) => R | undefined) | undefined} fallback callback when variable in not handled by hooks
* @param {((result?: string) => TODO) | undefined} defined callback when variable is defined
* @param {((result?: string) => R | undefined) | undefined} defined callback when variable is defined
* @param {AsArray<T>} args args for the hook
* @returns {R | undefined} result of hook
*/

View File

@ -7,6 +7,7 @@
const { SyncHook } = require("tapable");
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
/** @typedef {import("../../declarations/WebpackOptions").Falsy} Falsy */
/** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
@ -40,7 +41,7 @@ const { SyncHook } = require("tapable");
* @property {ImportAttributes=} assertions
* @property {string=} mimetype
* @property {string} dependency
* @property {Record<string, EXPECTED_ANY>=} descriptionData
* @property {ResolveRequest["descriptionFileData"]=} descriptionData
* @property {string=} compiler
* @property {string} issuer
* @property {string} issuerLayer
@ -128,7 +129,7 @@ class RuleSetCompiler {
for (const condition of rule.conditions) {
const p = condition.property;
if (Array.isArray(p)) {
/** @type {EffectData | EffectData[keyof EffectData] | undefined} */
/** @type {EXPECTED_ANY} */
let current = data;
for (const subProperty of p) {
if (

View File

@ -112,9 +112,6 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
*/
/** @typedef {KnownStatsAsset & Record<string, EXPECTED_ANY>} StatsAsset */
/** @typedef {ChunkId} KnownStatsAssetChunk */
/** @typedef {ChunkName} KnownStatsAssetChunkName */
/** @typedef {string} KnownStatsAssetChunkIdHint */
/**
* @typedef {object} KnownStatsAsset
* @property {string} type
@ -125,12 +122,12 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
* @property {boolean} comparedForEmit
* @property {boolean} cached
* @property {StatsAsset[]=} related
* @property {KnownStatsAssetChunk[]=} chunks
* @property {KnownStatsAssetChunkName[]=} chunkNames
* @property {KnownStatsAssetChunkIdHint[]=} chunkIdHints
* @property {KnownStatsAssetChunk[]=} auxiliaryChunks
* @property {KnownStatsAssetChunkName[]=} auxiliaryChunkNames
* @property {KnownStatsAssetChunkIdHint[]=} auxiliaryChunkIdHints
* @property {ChunkId[]=} chunks
* @property {ChunkName[]=} chunkNames
* @property {string[]=} chunkIdHints
* @property {ChunkId[]=} auxiliaryChunks
* @property {ChunkName[]=} auxiliaryChunkNames
* @property {string[]=} auxiliaryChunkIdHints
* @property {number=} filteredRelated
* @property {boolean=} isOverSizeLimit
*/
@ -138,7 +135,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
/** @typedef {KnownStatsChunkGroup & Record<string, EXPECTED_ANY>} StatsChunkGroup */
/**
* @typedef {object} KnownStatsChunkGroup
* @property {(string | null)=} name
* @property {ChunkName=} name
* @property {(string | number)[]=} chunks
* @property {({ name: string, size?: number })[]=} assets
* @property {number=} filteredAssets
@ -146,8 +143,8 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
* @property {({ name: string, size?: number })[]=} auxiliaryAssets
* @property {number=} filteredAuxiliaryAssets
* @property {number=} auxiliaryAssetsSize
* @property {{ [x: string]: StatsChunkGroup[] }=} children
* @property {{ [x: string]: string[] }=} childAssets
* @property {Record<string, StatsChunkGroup[]>=} children
* @property {Record<string, string[]>=} childAssets
* @property {boolean=} isOverSizeLimit
*/
@ -166,7 +163,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
* @property {number=} index2
* @property {number=} postOrderIndex
* @property {number=} size
* @property {{ [x: string]: number }=} sizes
* @property {Record<string, number>=} sizes
* @property {boolean=} cacheable
* @property {boolean=} built
* @property {boolean=} codeGenerated
@ -216,7 +213,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
* @typedef {object} KnownStatsModuleIssuer
* @property {string} identifier
* @property {string} name
* @property {(string|number)=} id
* @property {ModuleId=} id
* @property {StatsProfile} profile
*/
@ -233,8 +230,8 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
* @property {string | null} explanation
* @property {string | null} userRequest
* @property {(string | null)=} loc
* @property {(string | number | null)=} moduleId
* @property {(string | number | null)=} resolvedModuleId
* @property {ModuleId | null=} moduleId
* @property {ModuleId | null=} resolvedModuleId
*/
/** @typedef {KnownStatsChunk & Record<string, EXPECTED_ANY>} StatsChunk */
@ -254,10 +251,10 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
* @property {string[]} auxiliaryFiles
* @property {string} hash
* @property {Record<string, ChunkId[]>} childrenByOrder
* @property {(string|number)=} id
* @property {(string|number)[]=} siblings
* @property {(string|number)[]=} parents
* @property {(string|number)[]=} children
* @property {ChunkId=} id
* @property {ChunkId[]=} siblings
* @property {ChunkId[]=} parents
* @property {ChunkId[]=} children
* @property {StatsModule[]=} modules
* @property {number=} filteredModules
* @property {StatsChunkOrigin[]=} origins
@ -282,8 +279,8 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
* @property {string=} moduleIdentifier
* @property {string=} moduleName
* @property {StatsModuleTraceDependency[]=} dependencies
* @property {(string|number)=} originId
* @property {(string|number)=} moduleId
* @property {ModuleId=} originId
* @property {ModuleId=} moduleId
*/
/** @typedef {KnownStatsModuleTraceDependency & Record<string, EXPECTED_ANY>} StatsModuleTraceDependency */
@ -304,7 +301,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
* @property {string=} moduleName
* @property {string=} loc
* @property {ChunkId=} chunkId
* @property {string|number=} moduleId
* @property {ModuleId=} moduleId
* @property {StatsModuleTraceItem[]=} moduleTrace
* @property {string=} details
* @property {string=} stack

View File

@ -10,9 +10,6 @@
/** @typedef {import("./DefaultStatsFactoryPlugin").ChunkId} ChunkId */
/** @typedef {import("./DefaultStatsFactoryPlugin").ChunkName} ChunkName */
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAsset} KnownStatsAsset */
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunk} KnownStatsAssetChunk */
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunkIdHint} KnownStatsAssetChunkIdHint */
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunkName} KnownStatsAssetChunkName */
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunk} KnownStatsChunk */
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunkGroup} KnownStatsChunkGroup */
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunkOrigin} KnownStatsChunkOrigin */
@ -412,9 +409,9 @@ const COMPILATION_SIMPLE_PRINTERS = {
* Printers<KnownStatsAsset["info"], "asset.info"> &
* Exclamation<KnownStatsAsset, "asset.separator", "asset"> &
* { ["asset.filteredChildren"]?: SimplePrinter<number, "asset"> } &
* { assetChunk?: SimplePrinter<KnownStatsAssetChunk, "asset"> } &
* { assetChunkName?: SimplePrinter<KnownStatsAssetChunkName, "asset"> } &
* { assetChunkIdHint?: SimplePrinter<KnownStatsAssetChunkIdHint, "asset"> }} AssetSimplePrinters
* { assetChunk?: SimplePrinter<ChunkId, "asset"> } &
* { assetChunkName?: SimplePrinter<ChunkName, "asset"> } &
* { assetChunkIdHint?: SimplePrinter<string, "asset"> }} AssetSimplePrinters
*/
/** @type {AssetSimplePrinters} */
@ -464,7 +461,6 @@ const ASSET_SIMPLE_PRINTERS = {
: undefined,
assetChunk: (id, { formatChunkId }) => formatChunkId(id),
assetChunkName: (name) => name || undefined,
assetChunkIdHint: (name) => name || undefined
};
@ -1454,7 +1450,12 @@ const AVAILABLE_COLORS = {
* @typedef {T extends [infer Head, ...infer Tail] ? Tail : undefined} Tail
*/
/** @typedef {{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContextWithExtra, ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>>) => string }} AvailableFormats */
/**
* @template {(...args: EXPECTED_ANY[]) => EXPECTED_ANY} T
* @typedef {T extends (firstArg: EXPECTED_ANY, ...rest: infer R) => EXPECTED_ANY ? R : never} TailParameters
*/
/** @typedef {{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContextWithExtra, ...args: TailParameters<NonNullable<KnownStatsPrinterFormatters[Key]>>) => string }} AvailableFormats */
/** @type {AvailableFormats} */
const AVAILABLE_FORMATS = {
@ -1630,16 +1631,14 @@ class DefaultStatsPrinterPlugin {
context[color] = (str) => str;
}
}
for (const _format of Object.keys(AVAILABLE_FORMATS)) {
const format =
/** @type {keyof KnownStatsPrinterFormatters} */
(_format);
for (const format of /** @type {(keyof KnownStatsPrinterFormatters)[]} */ (
Object.keys(AVAILABLE_FORMATS)
)) {
context[format] =
/** @type {(content: Parameters<NonNullable<KnownStatsPrinterFormatters[keyof KnownStatsPrinterFormatters]>>[0], ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[keyof KnownStatsPrinterFormatters]>>>) => string} */
(content, ...args) =>
/** @type {TODO} */
(AVAILABLE_FORMATS)[format](
/** @type {EXPECTED_ANY} */
(AVAILABLE_FORMATS[format])(
content,
/** @type {StatsPrinterContext & Required<KnownStatsPrinterColorFunctions>} */
(context),
@ -1649,15 +1648,12 @@ class DefaultStatsPrinterPlugin {
context.timeReference = compilation.time;
});
for (const key of Object.keys(COMPILATION_SIMPLE_PRINTERS)) {
for (const key of /** @type {(keyof CompilationSimplePrinters)[]} */ (
Object.keys(COMPILATION_SIMPLE_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {TODO} */
(
COMPILATION_SIMPLE_PRINTERS[
/** @type {keyof CompilationSimplePrinters} */
(key)
]
)(
/** @type {EXPECTED_ANY} */
(COMPILATION_SIMPLE_PRINTERS)[key](
obj,
/** @type {DefineStatsPrinterContext<"compilation">} */
(ctx),
@ -1666,15 +1662,12 @@ class DefaultStatsPrinterPlugin {
);
}
for (const key of Object.keys(ASSET_SIMPLE_PRINTERS)) {
for (const key of /** @type {(keyof AssetSimplePrinters)[]} */ (
Object.keys(ASSET_SIMPLE_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {NonNullable<AssetSimplePrinters[keyof AssetSimplePrinters]>} */
(
ASSET_SIMPLE_PRINTERS[
/** @type {keyof AssetSimplePrinters} */
(key)
]
)(
(ASSET_SIMPLE_PRINTERS[key])(
obj,
/** @type {DefineStatsPrinterContext<"asset" | "asset.info">} */
(ctx),
@ -1683,15 +1676,12 @@ class DefaultStatsPrinterPlugin {
);
}
for (const key of Object.keys(MODULE_SIMPLE_PRINTERS)) {
for (const key of /** @type {(keyof ModuleSimplePrinters)[]} */ (
Object.keys(MODULE_SIMPLE_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {TODO} */
(
MODULE_SIMPLE_PRINTERS[
/** @type {keyof ModuleSimplePrinters} */
(key)
]
)(
/** @type {EXPECTED_ANY} */
(MODULE_SIMPLE_PRINTERS)[key](
obj,
/** @type {DefineStatsPrinterContext<"module">} */
(ctx),
@ -1700,15 +1690,12 @@ class DefaultStatsPrinterPlugin {
);
}
for (const key of Object.keys(MODULE_ISSUER_PRINTERS)) {
for (const key of /** @type {(keyof ModuleIssuerPrinters)[]} */ (
Object.keys(MODULE_ISSUER_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {NonNullable<ModuleIssuerPrinters[keyof ModuleIssuerPrinters]>} */
(
MODULE_ISSUER_PRINTERS[
/** @type {keyof ModuleIssuerPrinters} */
(key)
]
)(
(MODULE_ISSUER_PRINTERS[key])(
obj,
/** @type {DefineStatsPrinterContext<"moduleIssuer">} */
(ctx),
@ -1717,15 +1704,12 @@ class DefaultStatsPrinterPlugin {
);
}
for (const key of Object.keys(MODULE_REASON_PRINTERS)) {
for (const key of /** @type {(keyof ModuleReasonsPrinters)[]} */ (
Object.keys(MODULE_REASON_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {TODO} */
(
MODULE_REASON_PRINTERS[
/** @type {keyof ModuleReasonsPrinters} */
(key)
]
)(
/** @type {EXPECTED_ANY} */
(MODULE_REASON_PRINTERS)[key](
obj,
/** @type {DefineStatsPrinterContext<"moduleReason">} */
(ctx),
@ -1734,15 +1718,12 @@ class DefaultStatsPrinterPlugin {
);
}
for (const key of Object.keys(MODULE_PROFILE_PRINTERS)) {
for (const key of /** @type {(keyof ModuleProfilePrinters)[]} */ (
Object.keys(MODULE_PROFILE_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {NonNullable<ModuleProfilePrinters[keyof ModuleProfilePrinters]>} */
(
MODULE_PROFILE_PRINTERS[
/** @type {keyof ModuleProfilePrinters} */
(key)
]
)(
(MODULE_PROFILE_PRINTERS[key])(
obj,
/** @type {DefineStatsPrinterContext<"profile">} */
(ctx),
@ -1751,15 +1732,12 @@ class DefaultStatsPrinterPlugin {
);
}
for (const key of Object.keys(CHUNK_GROUP_PRINTERS)) {
for (const key of /** @type {(keyof ChunkGroupPrinters)[]} */ (
Object.keys(CHUNK_GROUP_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {TODO} */
(
CHUNK_GROUP_PRINTERS[
/** @type {keyof ChunkGroupPrinters} */
(key)
]
)(
/** @type {EXPECTED_ANY} */
(CHUNK_GROUP_PRINTERS)[key](
obj,
/** @type {DefineStatsPrinterContext<"chunkGroupKind" | "chunkGroup">} */
(ctx),
@ -1768,10 +1746,12 @@ class DefaultStatsPrinterPlugin {
);
}
for (const key of Object.keys(CHUNK_PRINTERS)) {
for (const key of /** @type {(keyof ChunkPrinters)[]} */ (
Object.keys(CHUNK_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {TODO} */
(CHUNK_PRINTERS[/** @type {keyof ChunkPrinters} */ (key)])(
/** @type {EXPECTED_ANY} */
(CHUNK_PRINTERS)[key](
obj,
/** @type {DefineStatsPrinterContext<"chunk">} */
(ctx),
@ -1780,10 +1760,12 @@ class DefaultStatsPrinterPlugin {
);
}
for (const key of Object.keys(ERROR_PRINTERS)) {
for (const key of /** @type {(keyof ErrorPrinters)[]} */ (
Object.keys(ERROR_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {TODO} */
(ERROR_PRINTERS[/** @type {keyof ErrorPrinters} */ (key)])(
/** @type {EXPECTED_ANY} */
(ERROR_PRINTERS)[key](
obj,
/** @type {DefineStatsPrinterContext<"error">} */
(ctx),
@ -1792,15 +1774,12 @@ class DefaultStatsPrinterPlugin {
);
}
for (const key of Object.keys(LOG_ENTRY_PRINTERS)) {
for (const key of /** @type {(keyof LogEntryPrinters)[]} */ (
Object.keys(LOG_ENTRY_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {TODO} */
(
LOG_ENTRY_PRINTERS[
/** @type {keyof LogEntryPrinters} */
(key)
]
)(
/** @type {EXPECTED_ANY} */
(LOG_ENTRY_PRINTERS)[key](
obj,
/** @type {DefineStatsPrinterContext<"logging">} */
(ctx),
@ -1809,15 +1788,12 @@ class DefaultStatsPrinterPlugin {
);
}
for (const key of Object.keys(MODULE_TRACE_DEPENDENCY_PRINTERS)) {
for (const key of /** @type {(keyof ModuleTraceDependencyPrinters)[]} */ (
Object.keys(MODULE_TRACE_DEPENDENCY_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {NonNullable<ModuleTraceDependencyPrinters[keyof ModuleTraceDependencyPrinters]>} */
(
MODULE_TRACE_DEPENDENCY_PRINTERS[
/** @type {keyof ModuleTraceDependencyPrinters} */
(key)
]
)(
(MODULE_TRACE_DEPENDENCY_PRINTERS[key])(
obj,
/** @type {DefineStatsPrinterContext<"moduleTraceDependency">} */
(ctx),
@ -1826,15 +1802,12 @@ class DefaultStatsPrinterPlugin {
);
}
for (const key of Object.keys(MODULE_TRACE_ITEM_PRINTERS)) {
for (const key of /** @type {(keyof ModuleTraceItemPrinters)[]} */ (
Object.keys(MODULE_TRACE_ITEM_PRINTERS)
)) {
stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) =>
/** @type {NonNullable<ModuleTraceItemPrinters[keyof ModuleTraceItemPrinters]>} */
(
MODULE_TRACE_ITEM_PRINTERS[
/** @type {keyof ModuleTraceItemPrinters} */
(key)
]
)(
(MODULE_TRACE_ITEM_PRINTERS[key])(
obj,
/** @type {DefineStatsPrinterContext<"moduleTraceItem">} */
(ctx),

View File

@ -70,10 +70,10 @@ const smartGrouping = require("../util/smartGrouping");
* @typedef {T extends ChunkGroupInfoWithName[] ? Record<string, StatsObject<ChunkGroupInfoWithName, F>> : T extends (infer V)[] ? StatsObject<V, F>[] : StatsObject<T, F>} CreatedObject
*/
/** @typedef {TODO} ObjectForExtract */
/** @typedef {TODO} FactoryData */
/** @typedef {TODO} FactoryDataItem */
/** @typedef {TODO} Result */
/** @typedef {EXPECTED_ANY} ObjectForExtract */
/** @typedef {EXPECTED_ANY} FactoryData */
/** @typedef {EXPECTED_ANY} FactoryDataItem */
/** @typedef {EXPECTED_ANY} Result */
/**
* @typedef {object} StatsFactoryHooks

View File

@ -24,7 +24,6 @@ const InnerGraph = require("../optimize/InnerGraph");
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("../NormalModule")} NormalModule */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser")} Parser */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
const PLUGIN_NAME = "URLParserPlugin";
@ -36,7 +35,7 @@ const PLUGIN_NAME = "URLParserPlugin";
const getUrl = (module) => pathToFileURL(module.resource);
/**
* @param {Parser} parser parser parser
* @param {JavascriptParser} parser parser parser
* @param {MemberExpression} arg arg
* @returns {boolean} true when it is `meta.url`, otherwise false
*/
@ -63,7 +62,7 @@ const getEvaluatedExprCache = new WeakMap();
/**
* @param {NewExpressionNode} expr expression
* @param {Parser} parser parser parser
* @param {JavascriptParser} parser parser parser
* @returns {BasicEvaluatedExpression | undefined} basic evaluated expression
*/
const getEvaluatedExpr = (expr, parser) => {

View File

@ -92,7 +92,7 @@ const cachedSetProperty = (obj, property, value) => {
* @template T
* @typedef {object} ObjectParsedPropertyEntry
* @property {T[keyof T] | undefined} base base value
* @property {string | undefined} byProperty the name of the selector property
* @property {`by${string}` | undefined} byProperty the name of the selector property
* @property {ByValues | undefined} byValues value depending on selector property, merged with base
*/
@ -105,7 +105,7 @@ const cachedSetProperty = (obj, property, value) => {
/**
* @template {object} T
* @typedef {{ byProperty: string, fn: DynamicFunction }} ParsedObjectDynamic
* @typedef {{ byProperty: `by${string}`, fn: DynamicFunction }} ParsedObjectDynamic
*/
/**
@ -169,7 +169,7 @@ const parseObject = (obj) => {
for (const key of Object.keys(obj)) {
const entry = getInfo(/** @type {keyof T} */ (key));
if (entry.byProperty === undefined) {
entry.byProperty = byProperty;
entry.byProperty = /** @type {`by${string}`} */ (byProperty);
entry.byValues = new Map();
} else if (entry.byProperty !== byProperty) {
throw new Error(
@ -196,7 +196,7 @@ const parseObject = (obj) => {
} else if (typeof byObj === "function") {
if (dynamicInfo === undefined) {
dynamicInfo = {
byProperty: key,
byProperty: /** @type {`by${string}`} */ (key),
fn: byObj
};
} else {
@ -222,17 +222,16 @@ const parseObject = (obj) => {
/**
* @template {object} T
* @param {ParsedObjectStatic<T>} info static properties (key is property name)
* @param {{ byProperty: string, fn: DynamicFunction } | undefined} dynamicInfo dynamic part
* @param {{ byProperty: `by${string}`, fn: DynamicFunction } | undefined} dynamicInfo dynamic part
* @returns {T} the object
*/
const serializeObject = (info, dynamicInfo) => {
const obj = /** @type {T} */ ({});
const obj = /** @type {EXPECTED_ANY} */ ({});
// Setup byProperty structure
for (const entry of info.values()) {
if (entry.byProperty !== undefined) {
const byProperty = /** @type {keyof T} */ (entry.byProperty);
const byObj = (obj[byProperty] =
obj[byProperty] || /** @type {TODO} */ ({}));
const byProperty = entry.byProperty;
const byObj = (obj[byProperty] = obj[byProperty] || {});
for (const byValue of /** @type {ByValues} */ (entry.byValues).keys()) {
byObj[byValue] = byObj[byValue] || {};
}
@ -240,13 +239,12 @@ const serializeObject = (info, dynamicInfo) => {
}
for (const [key, entry] of info) {
if (entry.base !== undefined) {
obj[/** @type {keyof T} */ (key)] = entry.base;
obj[key] = entry.base;
}
// Fill byProperty structure
if (entry.byProperty !== undefined) {
const byProperty = /** @type {keyof T} */ (entry.byProperty);
const byObj = (obj[byProperty] =
obj[byProperty] || /** @type {TODO} */ ({}));
const byProperty = entry.byProperty;
const byObj = (obj[byProperty] = obj[byProperty] || {});
for (const byValue of Object.keys(byObj)) {
const value = getFromByValues(
/** @type {ByValues} */
@ -258,8 +256,7 @@ const serializeObject = (info, dynamicInfo) => {
}
}
if (dynamicInfo !== undefined) {
/** @type {TODO} */
(obj)[dynamicInfo.byProperty] = dynamicInfo.fn;
obj[dynamicInfo.byProperty] = dynamicInfo.fn;
}
return obj;
};
@ -384,7 +381,7 @@ const _cleverMerge = (first, second, internalCaching = false) => {
* @param {ObjectParsedPropertyEntry<T>} firstEntry a
* @param {ObjectParsedPropertyEntry<O>} secondEntry b
* @param {boolean} internalCaching should parsing of objects and nested merges be cached
* @returns {ObjectParsedPropertyEntry<TODO>} new entry
* @returns {ObjectParsedPropertyEntry<T> | ObjectParsedPropertyEntry<O> | ObjectParsedPropertyEntry<T & O>} new entry
*/
const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
switch (getValueType(secondEntry.base)) {
@ -479,7 +476,7 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
if (!secondEntry.byProperty) {
// = first.base + (first.byProperty + second.base)
return {
base: newBase,
base: /** @type {T[keyof T] & O[keyof O]} */ (newBase),
byProperty: firstEntry.byProperty,
byValues: intermediateByValues
};
@ -499,7 +496,7 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
);
}
return {
base: newBase,
base: /** @type {T[keyof T] & O[keyof O]} */ (newBase),
byProperty: firstEntry.byProperty,
byValues: newByValues
};

View File

@ -75,33 +75,32 @@ const DISABLED_METHODS = [
/**
* @template T
* @typedef {Set<T> & {[Symbol.isConcatSpreadable]?: boolean} & { push?: (...items: T[]) => void } & { [P in DISABLED_METHODS_NAMES]?: () => void } & { [P in COPY_METHODS_NAMES]?: () => TODO }} SetWithDeprecatedArrayMethods
* @typedef {Set<T> & { [Symbol.isConcatSpreadable]: boolean } & { push: (...items: T[]) => void, length?: number } & { [P in DISABLED_METHODS_NAMES]: () => void } & { [P in COPY_METHODS_NAMES]: P extends keyof Array<T> ? () => Pick<Array<T>, P> : never }} SetWithDeprecatedArrayMethods
*/
/**
* @template T
* @param {SetWithDeprecatedArrayMethods<T>} set new set
* @param {Set<T>} set new set
* @param {string} name property name
* @returns {void}
*/
module.exports.arrayToSetDeprecation = (set, name) => {
for (const method of COPY_METHODS) {
if (set[method]) continue;
if (/** @type {SetWithDeprecatedArrayMethods<T>} */ (set)[method]) continue;
const d = createDeprecation(
`${name} was changed from Array to Set (using Array method '${method}' is deprecated)`,
"ARRAY_TO_SET"
);
/**
* @deprecated
* @this {Set<T>}
* @returns {number} count
*/
/** @type {EXPECTED_ANY} */
(set)[method] =
// eslint-disable-next-line func-names
set[method] = function () {
function () {
d();
// eslint-disable-next-line unicorn/prefer-spread
const array = Array.from(this);
return Array.prototype[/** @type {keyof COPY_METHODS} */ (method)].apply(
return Array.prototype[
/** @type {keyof COPY_METHODS} */ (method)
].apply(
array,
// eslint-disable-next-line prefer-rest-params
arguments
@ -120,12 +119,8 @@ module.exports.arrayToSetDeprecation = (set, name) => {
`${name} was changed from Array to Set (indexing Array is deprecated)`,
"ARRAY_TO_SET_INDEXER"
);
/**
* @deprecated
* @this {Set<T>}
* @returns {number} count
*/
set.push = function push() {
/** @type {SetWithDeprecatedArrayMethods<T>} */
(set).push = function push() {
dPush();
// eslint-disable-next-line prefer-rest-params, unicorn/prefer-spread
for (const item of Array.from(arguments)) {
@ -134,9 +129,10 @@ module.exports.arrayToSetDeprecation = (set, name) => {
return this.size;
};
for (const method of DISABLED_METHODS) {
if (set[method]) continue;
if (/** @type {SetWithDeprecatedArrayMethods<T>} */ (set)[method]) continue;
set[method] = () => {
/** @type {SetWithDeprecatedArrayMethods<T>} */
(set)[method] = () => {
throw new Error(
`${name} was changed from Array to Set (using Array method '${method}' is not possible)`
);
@ -191,7 +187,8 @@ module.exports.arrayToSetDeprecation = (set, name) => {
);
}
});
set[Symbol.isConcatSpreadable] = true;
/** @type {SetWithDeprecatedArrayMethods<T>} */
(set)[Symbol.isConcatSpreadable] = true;
};
/**
@ -214,7 +211,8 @@ module.exports.createArrayToSetDeprecationSet = (name) => {
if (!initialized) {
initialized = true;
module.exports.arrayToSetDeprecation(
SetDeprecatedArray.prototype,
/** @type {SetWithDeprecatedArrayMethods<T>} */
(SetDeprecatedArray.prototype),
name
);
}

View File

@ -5,10 +5,11 @@ const acornParser = acorn.Parser;
/** @type {import("../../../../").LoaderDefinition} */
module.exports = function (source) {
/** @type {TODO} */
/** @type {acorn.Comment[]} */
const comments = [];
const semicolons = new Set();
//@ts-ignore
const ast = acornParser.parse(source, {
ranges: true,
locations: true,

View File

@ -0,0 +1,6 @@
const load = id => import(`app/${id}?query#hash`);
it("show override request", async () => {
expect((await load("a")).default).toBe("override/a");
});

View File

@ -0,0 +1 @@
export default "foo/a";

View File

@ -0,0 +1 @@
export default "main/a";

View File

@ -0,0 +1 @@
export default "override/a";

View File

@ -0,0 +1,14 @@
"use strict";
const path = require("path");
const webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
resolve: {
alias: {
app: [path.join(__dirname, "src/main"), path.join(__dirname, "src/foo")]
}
},
plugins: [new webpack.ContextReplacementPlugin(/main/, "../override")]
};

View File

@ -0,0 +1,6 @@
const load = id => import(`app/${id}?query#hash`);
it("show override request", async () => {
expect((await load("a")).default).toBe("override/a");
});

View File

@ -0,0 +1 @@
export default "foo/a";

View File

@ -0,0 +1 @@
export default "main/a";

View File

@ -0,0 +1 @@
export default "override/a";

View File

@ -0,0 +1,20 @@
"use strict";
const path = require("path");
const webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
resolve: {
alias: {
app: [path.join(__dirname, "src/main"), path.join(__dirname, "src/foo")]
}
},
plugins: [
new webpack.ContextReplacementPlugin(/main/, (context) => {
Object.assign(context, {
resource: ["../override"] // resolved relatively
});
})
]
};

View File

@ -1,5 +1,7 @@
"use strict";
/** @typedef {import("../../../../").Compiler} Compiler */
const DefinePlugin = require("../../../../").DefinePlugin;
const nullValue = null;
@ -16,19 +18,15 @@ class FailPlugin {
class TestChildCompilationPlugin {
/**
* @param {TODO} compiler compiler
* @param {Compiler} compiler compiler
*/
apply(compiler) {
compiler.hooks.make.tapAsync(
"TestChildCompilationFailurePlugin",
/**
* @param {TODO} compilation compilation
* @param {TODO} cb cb
*/
(compilation, cb) => {
const child = compilation.createChildCompiler(
"name",
compiler.outputOptions,
compilation.outputOptions,
[
undefinedValue && new FailPlugin(),
nullValue && new FailPlugin(),
@ -38,7 +36,9 @@ class TestChildCompilationPlugin {
]
);
child.runAsChild(cb);
child.runAsChild((err) => {
cb(err);
});
}
);
}

269
types.d.ts vendored
View File

@ -15,7 +15,6 @@ import {
AssignmentPattern,
AssignmentProperty,
AwaitExpression,
BaseNode,
BigIntLiteral,
BinaryExpression,
BlockStatement,
@ -32,9 +31,9 @@ import {
Directive,
DoWhileStatement,
EmptyStatement,
ExportAllDeclaration as ExportAllDeclarationImport,
ExportAllDeclaration,
ExportDefaultDeclaration,
ExportNamedDeclaration as ExportNamedDeclarationImport,
ExportNamedDeclaration,
ExportSpecifier,
ExpressionStatement,
ForInStatement,
@ -44,7 +43,7 @@ import {
FunctionExpression,
Identifier,
IfStatement,
ImportDeclaration as ImportDeclarationImport,
ImportDeclaration,
ImportDefaultSpecifier,
ImportExpression as ImportExpressionImport,
ImportNamespaceSpecifier,
@ -196,7 +195,7 @@ declare interface AdditionalData {
}
type AfterContextResolveData = ContextResolveData &
ContextOptions & {
resource: any;
resource: string | string[];
resourceQuery?: string;
resourceFragment?: string;
resolveDependencies: (
@ -205,7 +204,7 @@ type AfterContextResolveData = ContextResolveData &
callback: (
err: null | Error,
dependencies?: ContextElementDependency[]
) => any
) => void
) => void;
};
declare class AggressiveMergingPlugin {
@ -623,9 +622,9 @@ declare abstract class BasicEvaluatedExpression {
getMemberRanges?: () => [number, number][];
expression?:
| Program
| ImportDeclarationImport
| ExportNamedDeclarationImport
| ExportAllDeclarationImport
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
@ -854,9 +853,9 @@ declare abstract class BasicEvaluatedExpression {
setExpression(
expression?:
| Program
| ImportDeclarationImport
| ExportNamedDeclarationImport
| ExportAllDeclarationImport
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
@ -2037,6 +2036,10 @@ declare interface ColorsOptions {
*/
useColor?: boolean;
}
declare interface CommonJsImportSettings {
name?: string;
context: string;
}
declare interface Comparator<T> {
(a: T, b: T): 0 | 1 | -1;
}
@ -2044,6 +2047,15 @@ declare class CompatSource extends Source {
constructor(sourceLike: SourceLike);
static from(sourceLike: SourceLike): Source;
}
declare interface CompatibilitySettings {
name: string;
declaration: CompatibilitySettingsDeclaration;
}
declare interface CompatibilitySettingsDeclaration {
updated: boolean;
loc: DependencyLocation;
range: [number, number];
}
declare class Compilation {
/**
* Creates an instance of Compilation.
@ -2748,7 +2760,7 @@ declare class Compiler {
err: null | Error,
entries?: Chunk[],
compilation?: Compilation
) => any
) => void
): void;
purgeInputFileSystem(): void;
emitAssets(
@ -3320,12 +3332,11 @@ declare abstract class ContextDependency extends Dependency {
userRequest: string;
critical?: string | false;
hadGlobalOrStickyRegExp: boolean;
request: any;
range: any;
valueRange: any;
request?: string;
range?: [number, number];
valueRange?: [number, number];
inShorthand?: string | boolean;
replaces: any;
prepend: any;
replaces?: { value: string; range: [number, number] }[];
}
type ContextDependencyOptions = ContextOptions & { request: string };
declare abstract class ContextElementDependency extends ModuleDependency {
@ -3390,7 +3401,7 @@ declare abstract class ContextModuleFactory extends ModuleFactory {
callback: (
err: null | Error,
dependencies?: ContextElementDependency[]
) => any
) => void
): void;
}
type ContextModuleOptions = ContextOptions & ContextModuleOptionsExtras;
@ -4342,7 +4353,7 @@ declare interface EffectData {
assertions?: ImportAttributes;
mimetype?: string;
dependency: string;
descriptionData?: Record<string, any>;
descriptionData?: JsonObjectTypes;
compiler?: string;
issuer: string;
issuerLayer: string;
@ -4943,9 +4954,6 @@ declare interface ExperimentsNormalizedExtra {
*/
lazyCompilation?: false | LazyCompilationOptions;
}
type ExportAllDeclarationJavascriptParser = ExportAllDeclarationImport & {
attributes?: ImportAttribute[];
};
declare abstract class ExportInfo {
name: string;
@ -5045,9 +5053,6 @@ declare abstract class ExportInfo {
| "not provided";
getRenameInfo(): string;
}
type ExportNamedDeclarationJavascriptParser = ExportNamedDeclarationImport & {
attributes?: ImportAttribute[];
};
type ExportPresenceMode = false | 0 | 1 | 2 | 3;
declare interface ExportSpec {
/**
@ -6120,6 +6125,15 @@ declare class HarmonyImportDependencyTemplate extends DependencyTemplate {
referencedModule: Module
): undefined | string | boolean | SortableSet<string>;
}
declare interface HarmonySettings {
ids: string[];
source: string;
sourceOrder: number;
name: string;
await: boolean;
attributes?: ImportAttributes;
defer?: boolean;
}
declare class Hash {
constructor();
@ -6341,16 +6355,7 @@ type IgnorePluginOptions =
*/
checkResource: (resource: string, context: string) => boolean;
};
type ImportAttribute = BaseNode & {
type: "ImportAttribute";
key: Identifier | SimpleLiteral | RegExpLiteral | BigIntLiteral;
value: Literal;
};
type ImportAttributes = Record<string, string> & {};
type ImportDeclarationJavascriptParser = ImportDeclarationImport & {
attributes?: ImportAttribute[];
phase?: "defer";
};
declare interface ImportDependencyMeta {
attributes?: ImportAttributes;
externalType?: "import" | "module";
@ -6403,6 +6408,10 @@ declare interface ImportModuleOptions {
*/
baseUri?: string;
}
declare interface ImportSettings {
references: string[][];
expression: ImportExpressionJavascriptParser;
}
type ImportSource =
| undefined
| null
@ -6765,9 +6774,9 @@ declare class JavascriptParser extends ParserClass {
>;
preStatement: SyncBailHook<
[
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| FunctionDeclaration
| MaybeNamedFunctionDeclaration
| VariableDeclaration
@ -6798,9 +6807,9 @@ declare class JavascriptParser extends ParserClass {
>;
blockPreStatement: SyncBailHook<
[
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| FunctionDeclaration
| MaybeNamedFunctionDeclaration
| VariableDeclaration
@ -6831,9 +6840,9 @@ declare class JavascriptParser extends ParserClass {
>;
statement: SyncBailHook<
[
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| FunctionDeclaration
| MaybeNamedFunctionDeclaration
| VariableDeclaration
@ -6886,33 +6895,24 @@ declare class JavascriptParser extends ParserClass {
boolean | void
>;
label: HookMap<SyncBailHook<[LabeledStatement], boolean | void>>;
import: SyncBailHook<
[ImportDeclarationJavascriptParser, ImportSource],
boolean | void
>;
import: SyncBailHook<[ImportDeclaration, ImportSource], boolean | void>;
importSpecifier: SyncBailHook<
[ImportDeclarationJavascriptParser, ImportSource, null | string, string],
[ImportDeclaration, ImportSource, null | string, string],
boolean | void
>;
export: SyncBailHook<
[ExportNamedDeclarationJavascriptParser | ExportDefaultDeclaration],
[ExportNamedDeclaration | ExportDefaultDeclaration],
boolean | void
>;
exportImport: SyncBailHook<
[
(
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
),
ImportSource
],
[ExportNamedDeclaration | ExportAllDeclaration, ImportSource],
boolean | void
>;
exportDeclaration: SyncBailHook<
[
(
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ExportNamedDeclaration
| ExportAllDeclaration
| ExportDefaultDeclaration
),
Declaration
@ -6959,8 +6959,8 @@ declare class JavascriptParser extends ParserClass {
exportSpecifier: SyncBailHook<
[
(
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ExportNamedDeclaration
| ExportAllDeclaration
| ExportDefaultDeclaration
),
string,
@ -6971,10 +6971,7 @@ declare class JavascriptParser extends ParserClass {
>;
exportImportSpecifier: SyncBailHook<
[
(
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
),
ExportNamedDeclaration | ExportAllDeclaration,
ImportSource,
null | string,
null | string,
@ -7099,9 +7096,9 @@ declare class JavascriptParser extends ParserClass {
semicolons?: Set<number>;
statementPath?: StatementPathItem[];
prevStatement?:
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
@ -7158,7 +7155,12 @@ declare class JavascriptParser extends ParserClass {
Expression,
Set<DestructuringAssignmentProperty>
>;
currentTagData?: TagData;
currentTagData?:
| (TopLevelSymbol & Record<string, any>)
| (HarmonySettings & Record<string, any>)
| (ImportSettings & Record<string, any>)
| (CommonJsImportSettings & Record<string, any>)
| (CompatibilitySettings & Record<string, any>);
magicCommentContext: Context;
destructuringAssignmentPropertiesFor(
node: Expression
@ -7203,9 +7205,9 @@ declare class JavascriptParser extends ParserClass {
*/
modulePreWalkStatements(
statements: (
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -7237,9 +7239,9 @@ declare class JavascriptParser extends ParserClass {
*/
preWalkStatements(
statements: (
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -7271,9 +7273,9 @@ declare class JavascriptParser extends ParserClass {
*/
blockPreWalkStatements(
statements: (
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -7305,9 +7307,9 @@ declare class JavascriptParser extends ParserClass {
*/
walkStatements(
statements: (
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -7339,9 +7341,9 @@ declare class JavascriptParser extends ParserClass {
*/
preWalkStatement(
statement:
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| FunctionDeclaration
| MaybeNamedFunctionDeclaration
| VariableDeclaration
@ -7370,9 +7372,9 @@ declare class JavascriptParser extends ParserClass {
): void;
blockPreWalkStatement(
statement:
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| FunctionDeclaration
| MaybeNamedFunctionDeclaration
| VariableDeclaration
@ -7401,9 +7403,9 @@ declare class JavascriptParser extends ParserClass {
): void;
walkStatement(
statement:
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| FunctionDeclaration
| MaybeNamedFunctionDeclaration
| VariableDeclaration
@ -7503,29 +7505,19 @@ declare class JavascriptParser extends ParserClass {
| ThisExpression
| UpdateExpression
| YieldExpression;
modulePreWalkImportDeclaration(
statement: ImportDeclarationJavascriptParser
): void;
modulePreWalkImportDeclaration(statement: ImportDeclaration): void;
enterDeclaration(
declaration: Declaration,
onIdent: (ident: string, identifier: Identifier) => void
): void;
modulePreWalkExportNamedDeclaration(
statement: ExportNamedDeclarationJavascriptParser
): void;
blockPreWalkExportNamedDeclaration(
statement: ExportNamedDeclarationJavascriptParser
): void;
walkExportNamedDeclaration(
statement: ExportNamedDeclarationJavascriptParser
): void;
modulePreWalkExportNamedDeclaration(statement: ExportNamedDeclaration): void;
blockPreWalkExportNamedDeclaration(statement: ExportNamedDeclaration): void;
walkExportNamedDeclaration(statement: ExportNamedDeclaration): void;
blockPreWalkExportDefaultDeclaration(
statement: ExportDefaultDeclaration
): void;
walkExportDefaultDeclaration(statement: ExportDefaultDeclaration): void;
modulePreWalkExportAllDeclaration(
statement: ExportAllDeclarationJavascriptParser
): void;
modulePreWalkExportAllDeclaration(statement: ExportAllDeclaration): void;
preWalkVariableDeclaration(statement: VariableDeclaration): void;
blockPreWalkVariableDeclaration(statement: VariableDeclaration): void;
preWalkVariableDeclarator(declarator: VariableDeclarator): void;
@ -7735,7 +7727,7 @@ declare class JavascriptParser extends ParserClass {
hookMap: HookMap<SyncBailHook<T, R>>,
info: ExportedVariableInfo,
fallback: undefined | ((name: string) => undefined | R),
defined: undefined | ((result?: string) => any),
defined: undefined | ((result?: string) => undefined | R),
...args: AsArray<T>
): undefined | R;
callHooksForNameWithFallback<T, R>(
@ -7775,9 +7767,9 @@ declare class JavascriptParser extends ParserClass {
inBlockScope(fn: () => void, inExecutedPath?: boolean): void;
detectMode(
statements: (
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -7928,11 +7920,25 @@ declare class JavascriptParser extends ParserClass {
setAsiPosition(pos: number): void;
unsetAsiPosition(pos: number): void;
isStatementLevelExpression(expr: Expression): boolean;
getTagData(name: string, tag: symbol): undefined | TagData;
getTagData(
name: string,
tag: symbol
):
| undefined
| (TopLevelSymbol & Record<string, any>)
| (HarmonySettings & Record<string, any>)
| (ImportSettings & Record<string, any>)
| (CommonJsImportSettings & Record<string, any>)
| (CompatibilitySettings & Record<string, any>);
tagVariable(
name: string,
tag: symbol,
data?: TagData,
data?:
| (TopLevelSymbol & Record<string, any>)
| (HarmonySettings & Record<string, any>)
| (ImportSettings & Record<string, any>)
| (CommonJsImportSettings & Record<string, any>)
| (CompatibilitySettings & Record<string, any>),
flags?: 0 | 1 | 2 | 4
): void;
defineVariable(name: string): void;
@ -8071,9 +8077,9 @@ declare class JavascriptParser extends ParserClass {
}>;
static getImportAttributes: (
node:
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| ImportExpressionJavascriptParser
) => undefined | ImportAttributes;
}
@ -8718,9 +8724,9 @@ declare interface KnownStatsChunk {
hash: string;
childrenByOrder: Record<string, ChunkId[]>;
id?: string | number;
siblings?: (string | number)[];
parents?: (string | number)[];
children?: (string | number)[];
siblings?: ChunkId[];
parents?: ChunkId[];
children?: ChunkId[];
modules?: StatsModule[];
filteredModules?: number;
origins?: StatsChunkOrigin[];
@ -8734,8 +8740,8 @@ declare interface KnownStatsChunkGroup {
auxiliaryAssets?: { name: string; size?: number }[];
filteredAuxiliaryAssets?: number;
auxiliaryAssetsSize?: number;
children?: { [index: string]: StatsChunkGroup[] };
childAssets?: { [index: string]: string[] };
children?: Record<string, StatsChunkGroup[]>;
childAssets?: Record<string, string[]>;
isOverSizeLimit?: boolean;
}
declare interface KnownStatsChunkOrigin {
@ -8827,7 +8833,7 @@ declare interface KnownStatsModule {
index2?: number;
postOrderIndex?: number;
size?: number;
sizes?: { [index: string]: number };
sizes?: Record<string, number>;
cacheable?: boolean;
built?: boolean;
codeGenerated?: boolean;
@ -9295,7 +9301,6 @@ declare interface LimitChunkCountPluginOptions {
*/
maxChunks: number;
}
type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
declare interface LoadScriptCompilationHooks {
createScript: SyncWaterfallHook<[string, Chunk], string>;
}
@ -9432,7 +9437,7 @@ declare interface LoaderPluginLoaderContext {
importModule(
request: string,
options: undefined | ImportModuleOptions,
callback: (err?: null | Error, exports?: any) => any
callback: (err?: null | Error, exports?: any) => void
): void;
importModule(request: string, options?: ImportModuleOptions): Promise<any>;
}
@ -10871,7 +10876,7 @@ declare class MultiCompiler {
fn: (
compiler: Compiler,
callback: CallbackWebpackFunction_2<MultiStats, void>
) => any,
) => void,
callback: CallbackWebpackFunction_2<Stats[], void>
): void;
watch(
@ -13162,7 +13167,7 @@ declare class Profiler {
startProfiling(): Promise<void> | Promise<[any, any, any]>;
sendCommand(method: string, params?: object): Promise<any>;
destroy(): Promise<void>;
stopProfiling(): Promise<{ profile: any }>;
stopProfiling(): Promise<{ profile: { startTime: number; endTime: number } }>;
}
declare class ProfilingPlugin {
constructor(options?: ProfilingPluginOptions);
@ -16726,9 +16731,9 @@ type Statement =
| ForInStatement
| ForOfStatement;
type StatementPathItem =
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportDeclaration
| ExportNamedDeclaration
| ExportAllDeclaration
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
@ -17425,12 +17430,14 @@ declare interface SyntheticDependencyLocation {
declare const TOMBSTONE: unique symbol;
declare const TRANSITIVE: unique symbol;
declare const TRANSITIVE_ONLY: unique symbol;
declare interface TagData {
[index: string]: any;
}
declare interface TagInfo {
tag: symbol;
data?: TagData;
data?:
| (TopLevelSymbol & Record<string, any>)
| (HarmonySettings & Record<string, any>)
| (ImportSettings & Record<string, any>)
| (CommonJsImportSettings & Record<string, any>)
| (CompatibilitySettings & Record<string, any>);
next?: TagInfo;
}
declare interface TargetItemWithConnection {