| /* | ||
| MIT License http://www.opensource.org/licenses/mit-license.php | ||
| Author Natsu @xiaoxiaojx | ||
| */ | ||
| "use strict"; | ||
| const InitFragment = require("../InitFragment"); | ||
| const makeSerializable = require("../util/makeSerializable"); | ||
| const NullDependency = require("./NullDependency"); | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** | ||
| * A dependency that adds an init fragment to the module | ||
| */ | ||
| class ModuleInitFragmentDependency extends NullDependency { | ||
| /** | ||
| * @param {string} initCode the initialization code | ||
| * @param {string[]} runtimeRequirements runtime requirements | ||
| * @param {string=} key unique key to avoid emitting the same initialization code twice | ||
| */ | ||
| constructor(initCode, runtimeRequirements, key) { | ||
| super(); | ||
| this.initCode = initCode; | ||
| this.runtimeRequirements = runtimeRequirements; | ||
| this.key = key; | ||
| } | ||
| /** | ||
| * @param {ObjectSerializerContext} context context | ||
| */ | ||
| serialize(context) { | ||
| const { write } = context; | ||
| write(this.initCode); | ||
| write(this.runtimeRequirements); | ||
| write(this.key); | ||
| super.serialize(context); | ||
| } | ||
| /** | ||
| * @param {ObjectDeserializerContext} context context | ||
| */ | ||
| deserialize(context) { | ||
| const { read } = context; | ||
| this.initCode = read(); | ||
| this.runtimeRequirements = read(); | ||
| this.key = read(); | ||
| super.deserialize(context); | ||
| } | ||
| } | ||
| makeSerializable( | ||
| ModuleInitFragmentDependency, | ||
| "webpack/lib/dependencies/ModuleInitFragmentDependency" | ||
| ); | ||
| ModuleInitFragmentDependency.Template = class ModuleInitFragmentDependencyTemplate extends ( | ||
| NullDependency.Template | ||
| ) { | ||
| /** | ||
| * @param {Dependency} dependency the dependency for which the template should be applied | ||
| * @param {ReplaceSource} source the current replace source which can be modified | ||
| * @param {DependencyTemplateContext} templateContext the context object | ||
| * @returns {void} | ||
| */ | ||
| apply(dependency, source, { initFragments, runtimeRequirements }) { | ||
| const dep = /** @type {ModuleInitFragmentDependency} */ (dependency); | ||
| for (const req of dep.runtimeRequirements) { | ||
| runtimeRequirements.add(req); | ||
| } | ||
| initFragments.push( | ||
| new InitFragment( | ||
| dep.initCode, | ||
| InitFragment.STAGE_CONSTANTS, | ||
| 0, | ||
| dep.key, | ||
| undefined | ||
| ) | ||
| ); | ||
| } | ||
| }; | ||
| module.exports = ModuleInitFragmentDependency; |
| /* | ||
| MIT License http://www.opensource.org/licenses/mit-license.php | ||
| Author Ivan Kopeykin @vankop | ||
| */ | ||
| "use strict"; | ||
| /** | ||
| * @template T | ||
| */ | ||
| class AppendOnlyStackedSet { | ||
| /** | ||
| * @param {Set<T>[]} sets an optional array of sets | ||
| */ | ||
| constructor(sets = []) { | ||
| /** @type {Set<T>[]} */ | ||
| this._sets = sets; | ||
| /** @type {Set<T> | undefined} */ | ||
| this._current = undefined; | ||
| } | ||
| /** | ||
| * @param {T} el element | ||
| */ | ||
| add(el) { | ||
| if (!this._current) { | ||
| this._current = new Set(); | ||
| this._sets.push(this._current); | ||
| } | ||
| this._current.add(el); | ||
| } | ||
| /** | ||
| * @param {T} el element | ||
| * @returns {boolean} result | ||
| */ | ||
| has(el) { | ||
| for (const set of this._sets) { | ||
| if (set.has(el)) return true; | ||
| } | ||
| return false; | ||
| } | ||
| clear() { | ||
| this._sets = []; | ||
| if (this._current) this._current.clear(); | ||
| } | ||
| /** | ||
| * @returns {AppendOnlyStackedSet<T>} child | ||
| */ | ||
| createChild() { | ||
| return new AppendOnlyStackedSet(this._sets.length ? [...this._sets] : []); | ||
| } | ||
| } | ||
| module.exports = AppendOnlyStackedSet; |
+6
-3
@@ -60,5 +60,7 @@ #!/usr/bin/env node | ||
| // https://github.com/nodejs/node/blob/v18.9.1/lib/internal/modules/cjs/loader.js#L1274 | ||
| // eslint-disable-next-line no-warning-comments | ||
| // @ts-ignore | ||
| for (const internalPath of require("module").globalPaths) { | ||
| const { globalPaths } = | ||
| /** @type {typeof import("module") & { globalPaths: string[] }} */ | ||
| (require("module")); | ||
| for (const internalPath of globalPaths) { | ||
| try { | ||
@@ -85,2 +87,3 @@ if (fs.statSync(path.join(internalPath, packageName)).isDirectory()) { | ||
| /** @type {Record<string, EXPECTED_ANY> & { type: string, bin: Record<string, string> }} */ | ||
| const pkg = require(pkgPath); | ||
@@ -87,0 +90,0 @@ |
@@ -51,2 +51,3 @@ /* | ||
| super(new Message().message); | ||
| /** @type {string} */ | ||
| this.name = "AbstractMethodError"; | ||
@@ -53,0 +54,0 @@ } |
+85
-15
@@ -19,2 +19,4 @@ /* | ||
| const ConstDependency = require("./dependencies/ConstDependency"); | ||
| const ModuleInitFragmentDependency = require("./dependencies/ModuleInitFragmentDependency"); | ||
| const RuntimeRequirementsDependency = require("./dependencies/RuntimeRequirementsDependency"); | ||
| const BasicEvaluatedExpression = require("./javascript/BasicEvaluatedExpression"); | ||
@@ -36,3 +38,3 @@ const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin"); | ||
| /** | ||
| * @returns {Record<string, {expr: string, req: string[] | null, type?: string, assign: boolean}>} replacements | ||
| * @returns {Record<string, { expr: string, req: string[] | null, type?: string, assign: boolean }>} replacements | ||
| */ | ||
@@ -165,2 +167,6 @@ function getReplacements() { | ||
| ); | ||
| compilation.dependencyTemplates.set( | ||
| ModuleInitFragmentDependency, | ||
| new ModuleInitFragmentDependency.Template() | ||
| ); | ||
@@ -207,2 +213,36 @@ compilation.hooks.runtimeRequirementInTree | ||
| const handler = (parser) => { | ||
| parser.hooks.preDeclarator.tap(PLUGIN_NAME, (declarator) => { | ||
| if ( | ||
| parser.scope.topLevelScope === true && | ||
| declarator.id.type === "Identifier" && | ||
| declarator.id.name === "module" | ||
| ) { | ||
| /** @type {BuildInfo} */ | ||
| (parser.state.module.buildInfo).moduleArgument = | ||
| "__webpack_module__"; | ||
| } | ||
| }); | ||
| parser.hooks.preStatement.tap(PLUGIN_NAME, (statement) => { | ||
| if (parser.scope.topLevelScope === true) { | ||
| if ( | ||
| statement.type === "FunctionDeclaration" && | ||
| statement.id && | ||
| statement.id.name === "module" | ||
| ) { | ||
| /** @type {BuildInfo} */ | ||
| (parser.state.module.buildInfo).moduleArgument = | ||
| "__webpack_module__"; | ||
| } else if ( | ||
| statement.type === "ClassDeclaration" && | ||
| statement.id && | ||
| statement.id.name === "module" | ||
| ) { | ||
| /** @type {BuildInfo} */ | ||
| (parser.state.module.buildInfo).moduleArgument = | ||
| "__webpack_module__"; | ||
| } | ||
| } | ||
| }); | ||
| for (const key of Object.keys(REPLACEMENTS)) { | ||
@@ -282,9 +322,24 @@ const info = REPLACEMENTS[key]; | ||
| "__webpack_module__.id"; | ||
| const dep = new ConstDependency( | ||
| `${parser.state.module.moduleArgument}.id`, | ||
| /** @type {Range} */ (expr.range), | ||
| [RuntimeGlobals.moduleId] | ||
| ); | ||
| dep.loc = /** @type {DependencyLocation} */ (expr.loc); | ||
| parser.state.module.addPresentationalDependency(dep); | ||
| const moduleArgument = parser.state.module.moduleArgument; | ||
| if (moduleArgument === "__webpack_module__") { | ||
| const dep = new RuntimeRequirementsDependency([ | ||
| RuntimeGlobals.moduleId | ||
| ]); | ||
| dep.loc = /** @type {DependencyLocation} */ (expr.loc); | ||
| parser.state.module.addPresentationalDependency(dep); | ||
| } else { | ||
| const initDep = new ModuleInitFragmentDependency( | ||
| `var __webpack_internal_module_id__ = ${moduleArgument}.id;\n`, | ||
| [RuntimeGlobals.moduleId], | ||
| "__webpack_internal_module_id__" | ||
| ); | ||
| parser.state.module.addPresentationalDependency(initDep); | ||
| const dep = new ConstDependency( | ||
| "__webpack_internal_module_id__", | ||
| /** @type {Range} */ (expr.range), | ||
| [] | ||
| ); | ||
| dep.loc = /** @type {DependencyLocation} */ (expr.loc); | ||
| parser.state.module.addPresentationalDependency(dep); | ||
| } | ||
| return true; | ||
@@ -299,9 +354,24 @@ }); | ||
| "__webpack_module__"; | ||
| const dep = new ConstDependency( | ||
| parser.state.module.moduleArgument, | ||
| /** @type {Range} */ (expr.range), | ||
| [RuntimeGlobals.module] | ||
| ); | ||
| dep.loc = /** @type {DependencyLocation} */ (expr.loc); | ||
| parser.state.module.addPresentationalDependency(dep); | ||
| const moduleArgument = parser.state.module.moduleArgument; | ||
| if (moduleArgument === "__webpack_module__") { | ||
| const dep = new RuntimeRequirementsDependency([ | ||
| RuntimeGlobals.module | ||
| ]); | ||
| dep.loc = /** @type {DependencyLocation} */ (expr.loc); | ||
| parser.state.module.addPresentationalDependency(dep); | ||
| } else { | ||
| const initDep = new ModuleInitFragmentDependency( | ||
| `var __webpack_internal_module__ = ${moduleArgument};\n`, | ||
| [RuntimeGlobals.module], | ||
| "__webpack_internal_module__" | ||
| ); | ||
| parser.state.module.addPresentationalDependency(initDep); | ||
| const dep = new ConstDependency( | ||
| "__webpack_internal_module__", | ||
| /** @type {Range} */ (expr.range), | ||
| [] | ||
| ); | ||
| dep.loc = /** @type {DependencyLocation} */ (expr.loc); | ||
| parser.state.module.addPresentationalDependency(dep); | ||
| } | ||
| return true; | ||
@@ -308,0 +378,0 @@ }); |
@@ -63,2 +63,3 @@ /* | ||
| /** @type {string} */ | ||
| let sourceContent; | ||
@@ -65,0 +66,0 @@ if (concatenationScope) { |
@@ -65,2 +65,3 @@ /* | ||
| const mergeMaybeArrays = (a, b) => { | ||
| /** @type {Set<T | U | null | undefined | string | Set<T> | Set<U>>} */ | ||
| const set = new Set(); | ||
@@ -71,3 +72,3 @@ if (Array.isArray(a)) for (const item of a) set.add(item); | ||
| else set.add(b); | ||
| return [...set]; | ||
| return /** @type {T[] & U[]} */ ([.../** @type {Set<T | U>} */ (set)]); | ||
| }; | ||
@@ -338,2 +339,3 @@ | ||
| /** @type {undefined | string} */ | ||
| let assetPath; | ||
@@ -463,2 +465,3 @@ | ||
| /** @type {string} */ | ||
| let encodedSource; | ||
@@ -487,2 +490,3 @@ | ||
| /** @type {string} */ | ||
| let encodedContent; | ||
@@ -498,3 +502,5 @@ | ||
| ) { | ||
| encodedContent = module.resourceResolveData.encodedContent; | ||
| encodedContent = | ||
| /** @type {string} */ | ||
| (module.resourceResolveData.encodedContent); | ||
| } else { | ||
@@ -529,6 +535,6 @@ encodedContent = encodeDataUri( | ||
| /** @type {string} */ | ||
| let content; | ||
| const needContent = type === JAVASCRIPT_TYPE || type === CSS_URL_TYPE; | ||
| const data = getData ? getData() : undefined; | ||
@@ -535,0 +541,0 @@ |
@@ -15,3 +15,3 @@ /* | ||
| } = require("../ModuleTypeConstants"); | ||
| const { compareModulesByIdOrIdentifier } = require("../util/comparators"); | ||
| const { compareModulesByFullName } = require("../util/comparators"); | ||
| const createSchemaValidation = require("../util/create-schema-validation"); | ||
@@ -22,2 +22,6 @@ const memoize = require("../util/memoize"); | ||
| /** @typedef {import("schema-utils").Schema} Schema */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").AssetGeneratorDataUrl} AssetGeneratorDataUrl */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").AssetModuleOutputPath} AssetModuleOutputPath */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").RawPublicPath} RawPublicPath */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").FilenameTemplate} FilenameTemplate */ | ||
| /** @typedef {import("../Compilation").AssetInfo} AssetInfo */ | ||
@@ -28,2 +32,3 @@ /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../NormalModule")} NormalModule */ | ||
| /** @typedef {import("../NormalModule").NormalModuleCreateData} NormalModuleCreateData */ | ||
@@ -82,2 +87,3 @@ /** | ||
| const getAssetBytesGenerator = memoize(() => require("./AssetBytesGenerator")); | ||
| const getNormalModule = memoize(() => require("../NormalModule")); | ||
@@ -97,2 +103,23 @@ const type = ASSET_MODULE_TYPE; | ||
| (compilation, { normalModuleFactory }) => { | ||
| const NormalModule = getNormalModule(); | ||
| for (const type of [ | ||
| ASSET_MODULE_TYPE, | ||
| ASSET_MODULE_TYPE_BYTES, | ||
| ASSET_MODULE_TYPE_INLINE, | ||
| ASSET_MODULE_TYPE_RESOURCE, | ||
| ASSET_MODULE_TYPE_SOURCE | ||
| ]) { | ||
| normalModuleFactory.hooks.createModuleClass | ||
| .for(type) | ||
| .tap(PLUGIN_NAME, (createData, _resolveData) => { | ||
| // TODO create the module via new AssetModule with its own properties | ||
| const module = new NormalModule( | ||
| /** @type {NormalModuleCreateData} */ | ||
| (createData) | ||
| ); | ||
| module.factoryMeta = { sideEffectFree: true }; | ||
| return module; | ||
| }); | ||
| } | ||
| normalModuleFactory.hooks.createParser | ||
@@ -154,2 +181,3 @@ .for(ASSET_MODULE_TYPE) | ||
| /** @type {undefined | AssetGeneratorDataUrl} */ | ||
| let dataUrl; | ||
@@ -167,4 +195,7 @@ if (type !== ASSET_MODULE_TYPE_RESOURCE) { | ||
| /** @type {undefined | FilenameTemplate} */ | ||
| let filename; | ||
| /** @type {undefined | RawPublicPath} */ | ||
| let publicPath; | ||
| /** @type {undefined | AssetModuleOutputPath} */ | ||
| let outputPath; | ||
@@ -212,3 +243,3 @@ if (type !== ASSET_MODULE_TYPE_INLINE) { | ||
| ASSET_MODULE_TYPE, | ||
| compareModulesByIdOrIdentifier(chunkGraph) | ||
| compareModulesByFullName(compilation.compiler) | ||
| ); | ||
@@ -215,0 +246,0 @@ if (modules) { |
@@ -62,2 +62,3 @@ /* | ||
| /** @type {string} */ | ||
| let sourceContent; | ||
@@ -64,0 +65,0 @@ if (concatenationScope) { |
@@ -25,4 +25,6 @@ /* | ||
| /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */ | ||
| /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */ | ||
| /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */ | ||
| /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../Module").Sources} Sources */ | ||
| /** @typedef {import("../Module").SourceTypes} SourceTypes */ | ||
@@ -118,2 +120,3 @@ /** @typedef {import("../RequestShortener")} RequestShortener */ | ||
| } | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -124,2 +127,3 @@ sources.set( | ||
| ); | ||
| /** @type {CodeGenerationResultData} */ | ||
| const data = new Map(); | ||
@@ -126,0 +130,0 @@ data.set("url", { |
@@ -15,2 +15,4 @@ /* | ||
| /** @typedef {Map<string, string>} Dependencies */ | ||
| /** | ||
@@ -21,3 +23,3 @@ * @extends {InitFragment<GenerateContext>} | ||
| /** | ||
| * @param {Map<string, string>} dependencies maps an import var to an async module that needs to be awaited | ||
| * @param {Dependencies} dependencies maps an import var to an async module that needs to be awaited | ||
| */ | ||
@@ -31,2 +33,3 @@ constructor(dependencies) { | ||
| ); | ||
| /** @type {Dependencies} */ | ||
| this.dependencies = dependencies; | ||
@@ -33,0 +36,0 @@ } |
@@ -19,3 +19,3 @@ /* | ||
| /** @typedef {(ChunkGroupOptions & { entryOptions?: EntryOptions }) | string} GroupOptions */ | ||
| /** @typedef {(ChunkGroupOptions & { entryOptions?: EntryOptions } & { circular?: boolean }) | string} GroupOptions */ | ||
@@ -35,5 +35,10 @@ class AsyncDependenciesBlock extends DependenciesBlock { | ||
| } | ||
| if (typeof groupOptions.circular !== "boolean") { | ||
| // default allow circular references | ||
| groupOptions.circular = true; | ||
| } | ||
| this.groupOptions = groupOptions; | ||
| this.loc = loc; | ||
| this.request = request; | ||
| /** @type {undefined | string} */ | ||
| this._stringifiedGroupOptions = undefined; | ||
@@ -61,2 +66,9 @@ } | ||
| /** | ||
| * @returns {boolean} Whether circular references are allowed | ||
| */ | ||
| get circular() { | ||
| return Boolean(this.groupOptions.circular); | ||
| } | ||
| /** | ||
| * @param {Hash} hash the hash used to track dependencies | ||
@@ -63,0 +75,0 @@ * @param {UpdateHashContext} context context |
@@ -25,2 +25,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "AsyncDependencyToInitialChunkError"; | ||
@@ -27,0 +28,0 @@ this.module = module; |
@@ -32,3 +32,3 @@ /* | ||
| ); | ||
| /** @type {{context: string | null, request: string}[] | null} */ | ||
| /** @type {{ context: string | null, request: string }[] | null} */ | ||
| let lastModules = null; | ||
@@ -35,0 +35,0 @@ compiler.hooks.afterCompile.tap(PLUGIN_NAME, (compilation) => { |
@@ -14,2 +14,3 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../declarations/plugins/BannerPlugin").BannerFunction} BannerFunction */ | ||
@@ -92,2 +93,3 @@ /** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */ | ||
| ); | ||
| /** @type {WeakMap<Source, { source: ConcatSource, comment: string }>} */ | ||
| const cache = new WeakMap(); | ||
@@ -94,0 +96,0 @@ const stage = |
@@ -53,2 +53,4 @@ /* | ||
| * @property {boolean} asyncChunks create async chunks | ||
| * @property {Module | null} depModule the module that is the dependency of the block | ||
| * @property {boolean} circular Whether to deduplicate to avoid circular references | ||
| */ | ||
@@ -169,2 +171,3 @@ | ||
| if (modules.length === 0) continue; | ||
| /** @type {undefined | Map<Module | ModuleGraphConnection | ConnectionState, number>} */ | ||
| let indexMap; | ||
@@ -365,2 +368,5 @@ let length = 0; | ||
| /** @type {Map<Module, ChunkGroupInfo>} */ | ||
| const depModuleAsyncEntrypoints = new Map(); | ||
| /** @type {Set<ChunkGroupInfo>} */ | ||
@@ -379,3 +385,4 @@ const outdatedOrderIndexChunkGroups = new Set(); | ||
| /** @type {Map<ChunkGroupInfo, Set<[ChunkGroupInfo, QueueItem | null]>>} */ | ||
| /** @typedef {Set<[ChunkGroupInfo, QueueItem | null]>} ConnectList */ | ||
| /** @type {Map<ChunkGroupInfo, ConnectList>} */ | ||
| const queueConnect = new Map(); | ||
@@ -395,2 +402,4 @@ /** @type {Set<ChunkGroupInfo>} */ | ||
| const chunkGroupInfo = { | ||
| depModule: null, | ||
| circular: false, | ||
| initialized: false, | ||
@@ -504,2 +513,4 @@ chunkGroup, | ||
| let entrypoint; | ||
| /** @type {Module | null} */ | ||
| const depModule = moduleGraph.getModule(b.dependencies[0]); | ||
| const entryOptions = b.groupOptions && b.groupOptions.entryOptions; | ||
@@ -510,2 +521,5 @@ if (cgi === undefined) { | ||
| cgi = namedAsyncEntrypoints.get(/** @type {string} */ (chunkName)); | ||
| if (!cgi && !b.circular && depModule) { | ||
| cgi = depModuleAsyncEntrypoints.get(depModule); | ||
| } | ||
| if (!cgi) { | ||
@@ -521,2 +535,4 @@ entrypoint = compilation.addAsyncEntrypoint( | ||
| cgi = { | ||
| depModule, | ||
| circular: b.circular, | ||
| chunkGroup: entrypoint, | ||
@@ -559,2 +575,8 @@ initialized: false, | ||
| } | ||
| if (!b.circular && depModule) { | ||
| depModuleAsyncEntrypoints.set( | ||
| depModule, | ||
| /** @type {ChunkGroupInfo} */ (cgi) | ||
| ); | ||
| } | ||
| } else { | ||
@@ -602,2 +624,4 @@ entrypoint = /** @type {Entrypoint} */ (cgi.chunkGroup); | ||
| cgi = { | ||
| depModule, | ||
| circular: b.circular, | ||
| initialized: false, | ||
@@ -664,2 +688,3 @@ chunkGroup: c, | ||
| if (connectList === undefined) { | ||
| /** @type {ConnectList} */ | ||
| connectList = new Set(); | ||
@@ -679,3 +704,6 @@ queueConnect.set(chunkGroupInfo, connectList); | ||
| ]); | ||
| } else if (entrypoint !== undefined) { | ||
| } else if ( | ||
| entrypoint !== undefined && | ||
| (chunkGroupInfo.circular || chunkGroupInfo.depModule !== depModule) | ||
| ) { | ||
| chunkGroupInfo.chunkGroup.addAsyncEntrypoint(entrypoint); | ||
@@ -1106,2 +1134,3 @@ } | ||
| if (connectList === undefined) { | ||
| /** @type {ConnectList} */ | ||
| connectList = new Set(); | ||
@@ -1108,0 +1137,0 @@ queueConnect.set(info, connectList); |
@@ -13,2 +13,3 @@ /* | ||
| /** @typedef {typeof import("../util/Hash")} HashConstructor */ | ||
| /** @typedef {import("../util/Hash").HashFunction} HashFunction */ | ||
@@ -23,7 +24,10 @@ /** | ||
| * @param {HashableObject} obj object with updateHash method | ||
| * @param {string | HashConstructor} hashFunction the hash function to use | ||
| * @param {HashFunction} hashFunction the hash function to use | ||
| */ | ||
| constructor(obj, hashFunction = DEFAULTS.HASH_FUNCTION) { | ||
| /** @type {HashableObject} */ | ||
| this._obj = obj; | ||
| /** @type {undefined | string} */ | ||
| this._hash = undefined; | ||
| /** @type {HashFunction} */ | ||
| this._hashFunction = hashFunction; | ||
@@ -45,6 +49,8 @@ } | ||
| /** @type {Map<string | HashConstructor, WeakMap<HashableObject, LazyHashedEtag>>} */ | ||
| /** @typedef {WeakMap<HashableObject, LazyHashedEtag>} InnerCache */ | ||
| /** @type {Map<HashFunction, InnerCache>} */ | ||
| const mapStrings = new Map(); | ||
| /** @type {WeakMap<HashConstructor, WeakMap<HashableObject, LazyHashedEtag>>} */ | ||
| /** @type {WeakMap<HashConstructor, InnerCache>} */ | ||
| const mapObjects = new WeakMap(); | ||
@@ -54,6 +60,7 @@ | ||
| * @param {HashableObject} obj object with updateHash method | ||
| * @param {(string | HashConstructor)=} hashFunction the hash function to use | ||
| * @param {HashFunction=} hashFunction the hash function to use | ||
| * @returns {LazyHashedEtag} etag | ||
| */ | ||
| const getter = (obj, hashFunction = DEFAULTS.HASH_FUNCTION) => { | ||
| /** @type {undefined | InnerCache} */ | ||
| let innerMap; | ||
@@ -64,2 +71,3 @@ if (typeof hashFunction === "string") { | ||
| const newHash = new LazyHashedEtag(obj, hashFunction); | ||
| /** @type {InnerCache} */ | ||
| innerMap = new WeakMap(); | ||
@@ -74,2 +82,3 @@ innerMap.set(obj, newHash); | ||
| const newHash = new LazyHashedEtag(obj, hashFunction); | ||
| /** @type {InnerCache} */ | ||
| innerMap = new WeakMap(); | ||
@@ -76,0 +85,0 @@ innerMap.set(obj, newHash); |
@@ -46,2 +46,3 @@ /* | ||
| let clearedEntries = 0; | ||
| /** @type {undefined | string} */ | ||
| let lastClearedIdentifier; | ||
@@ -48,0 +49,0 @@ // Avoid coverage problems due indirect changes |
@@ -25,3 +25,5 @@ /* | ||
| /** @type {WeakMap<Etag, WeakMap<Etag, MergedEtag>>} */ | ||
| const dualObjectMap = new WeakMap(); | ||
| /** @type {WeakMap<Etag, WeakMap<Etag, MergedEtag>>} */ | ||
| const objectStringMap = new WeakMap(); | ||
@@ -32,3 +34,3 @@ | ||
| * @param {Etag} b second | ||
| * @returns {Etag} result | ||
| * @returns {string | MergedEtag} result | ||
| */ | ||
@@ -35,0 +37,0 @@ const mergeEtags = (a, b) => { |
@@ -31,3 +31,3 @@ /* | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {typeof import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/Hash").HashFunction} HashFunction */ | ||
| /** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */ | ||
@@ -138,2 +138,3 @@ | ||
| this.requests = []; | ||
| /** @type {undefined | NodeJS.Timeout} */ | ||
| this.requestsTimeout = undefined; | ||
@@ -144,4 +145,7 @@ /** @type {ItemInfo} */ | ||
| this.content = []; | ||
| /** @type {boolean} */ | ||
| this.invalid = false; | ||
| /** @type {Logger} */ | ||
| this.logger = logger; | ||
| /** @type {number} */ | ||
| this.maxAge = maxAge; | ||
@@ -249,2 +253,3 @@ } | ||
| _findLocation() { | ||
| /** @type {number} */ | ||
| let i; | ||
@@ -263,2 +268,3 @@ for (i = 0; i < this.content.length && this.content[i] !== undefined; i++); | ||
| let count = 0; | ||
| /** @type {undefined | string} */ | ||
| let lastGC; | ||
@@ -389,2 +395,3 @@ const now = Date.now(); | ||
| // 2. Check if minimum number is reached | ||
| /** @type {number[]} */ | ||
| let mergedIndices; | ||
@@ -514,2 +521,3 @@ if ( | ||
| const unusedItems = new Set(content.items); | ||
| /** @type {Items} */ | ||
| const usedOfUnusedItems = new Set(); | ||
@@ -531,2 +539,3 @@ for (const identifier of usedItems) { | ||
| ); | ||
| /** @type {Content} */ | ||
| const map = new Map(); | ||
@@ -590,2 +599,3 @@ for (const identifier of unusedItems) { | ||
| ); | ||
| /** @type {Content} */ | ||
| const map = new Map(); | ||
@@ -703,3 +713,3 @@ for (const identifier of items) { | ||
| /** | ||
| * @param {ObjectSerializerContext & { logger: Logger, profile: boolean | undefined }} context context | ||
| * @param {ObjectSerializerContext & { logger: Logger, profile: boolean | undefined }} context context | ||
| */ | ||
@@ -787,2 +797,3 @@ serialize({ write, snapshot, rollback, logger, profile }) { | ||
| } else if (profile) { | ||
| /** @type {Map<EXPECTED_ANY, EXPECTED_ANY>} */ | ||
| const map = new Map(); | ||
@@ -813,2 +824,3 @@ let key = read(); | ||
| } else { | ||
| /** @type {Map<EXPECTED_ANY, EXPECTED_ANY>} */ | ||
| const map = new Map(); | ||
@@ -831,3 +843,3 @@ let key = read(); | ||
| /** @typedef {(() => Promise<PackContentItems> | PackContentItems) & Partial<{ options: { size?: number }}>} LazyFunction */ | ||
| /** @typedef {(() => Promise<PackContentItems> | PackContentItems) & Partial<{ options: { size?: number } }>} LazyFunction */ | ||
@@ -862,2 +874,3 @@ class PackContent { | ||
| constructor(items, usedItems, dataOrFn, logger, lazyName) { | ||
| /** @type {Items} */ | ||
| this.items = items; | ||
@@ -868,5 +881,9 @@ /** @type {LazyFunction | undefined} */ | ||
| this.content = typeof dataOrFn === "function" ? undefined : dataOrFn.map; | ||
| /** @type {boolean} */ | ||
| this.outdated = false; | ||
| /** @type {Items} */ | ||
| this.used = usedItems; | ||
| /** @type {Logger | undefined} */ | ||
| this.logger = logger; | ||
| /** @type {string | undefined} */ | ||
| this.lazyName = lazyName; | ||
@@ -1109,6 +1126,6 @@ } | ||
| * @param {number} options.maxAge max age of cache items | ||
| * @param {boolean | undefined} options.profile track and log detailed timing information for individual cache items | ||
| * @param {boolean | undefined} options.allowCollectingMemory allow to collect unused memory created during deserialization | ||
| * @param {false | "gzip" | "brotli" | undefined} options.compression compression used | ||
| * @param {boolean | undefined} options.readonly disable storing cache into filesystem | ||
| * @param {boolean=} options.profile track and log detailed timing information for individual cache items | ||
| * @param {boolean=} options.allowCollectingMemory allow to collect unused memory created during deserialization | ||
| * @param {false | "gzip" | "brotli"=} options.compression compression used | ||
| * @param {boolean=} options.readonly disable storing cache into filesystem | ||
| */ | ||
@@ -1132,5 +1149,6 @@ constructor({ | ||
| fs, | ||
| /** @type {string | Hash} */ | ||
| /** @type {HashFunction} */ | ||
| (compiler.options.output.hashFunction) | ||
| ); | ||
| /** @type {FileSystemInfo} */ | ||
| this.fileSystemInfo = new FileSystemInfo(fs, { | ||
@@ -1142,12 +1160,23 @@ managedPaths: snapshot.managedPaths, | ||
| }); | ||
| /** @type {Compiler} */ | ||
| this.compiler = compiler; | ||
| /** @type {string} */ | ||
| this.context = context; | ||
| /** @type {string} */ | ||
| this.cacheLocation = cacheLocation; | ||
| /** @type {string} */ | ||
| this.version = version; | ||
| /** @type {Logger} */ | ||
| this.logger = logger; | ||
| /** @type {number} */ | ||
| this.maxAge = maxAge; | ||
| /** @type {boolean | undefined} */ | ||
| this.profile = profile; | ||
| /** @type {boolean | undefined} */ | ||
| this.readonly = readonly; | ||
| /** @type {boolean | undefined} */ | ||
| this.allowCollectingMemory = allowCollectingMemory; | ||
| /** @type {false | "gzip" | "brotli" | undefined} */ | ||
| this.compression = compression; | ||
| /** @type {string} */ | ||
| this._extension = | ||
@@ -1159,2 +1188,3 @@ compression === "brotli" | ||
| : ".pack"; | ||
| /** @type {SnapshotOptions} */ | ||
| this.snapshot = snapshot; | ||
@@ -1173,2 +1203,3 @@ /** @type {BuildDependencies} */ | ||
| this.packPromise = this._openPack(); | ||
| /** @type {Promise<void>} */ | ||
| this.storePromise = Promise.resolve(); | ||
@@ -1405,3 +1436,5 @@ } | ||
| this.logger.log("Storing pack..."); | ||
| /** @type {undefined | Promise<void>} */ | ||
| let promise; | ||
| /** @type {Set<string>} */ | ||
| const newBuildDependencies = new Set(); | ||
@@ -1408,0 +1441,0 @@ for (const dep of this.newBuildDependencies) { |
@@ -16,3 +16,3 @@ /* | ||
| /** @typedef {import("./cache/getLazyHashedEtag").HashableObject} HashableObject */ | ||
| /** @typedef {typeof import("./util/Hash")} HashConstructor */ | ||
| /** @typedef {import("./util/Hash").HashFunction} HashFunction */ | ||
@@ -200,3 +200,3 @@ /** | ||
| * @param {string} name the child cache name | ||
| * @param {(string | HashConstructor)=} hashFunction the hash function to use | ||
| * @param {HashFunction=} hashFunction the hash function to use | ||
| */ | ||
@@ -203,0 +203,0 @@ constructor(cache, name, hashFunction) { |
@@ -66,2 +66,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "CaseSensitiveModulesWarning"; | ||
@@ -68,0 +69,0 @@ this.module = sortedModules[0]; |
+8
-4
@@ -722,3 +722,3 @@ /* | ||
| getChildIdsByOrders(chunkGraph, filterFn) { | ||
| /** @type {Map<string, {order: number, group: ChunkGroup}[]>} */ | ||
| /** @type {Map<string, { order: number, group: ChunkGroup }[]>} */ | ||
| const lists = new Map(); | ||
@@ -781,2 +781,3 @@ for (const group of this.groupsIterable) { | ||
| getChildrenOfTypeInOrder(chunkGraph, type) { | ||
| /** @type {{ order: number, group: ChunkGroup, childGroup: ChunkGroup }[]} */ | ||
| const list = []; | ||
@@ -786,3 +787,4 @@ for (const group of this.groupsIterable) { | ||
| const order = | ||
| childGroup.options[/** @type {keyof ChunkGroupOptions} */ (type)]; | ||
| /** @type {number} */ | ||
| (childGroup.options[/** @type {keyof ChunkGroupOptions} */ (type)]); | ||
| if (order === undefined) continue; | ||
@@ -798,8 +800,10 @@ list.push({ | ||
| list.sort((a, b) => { | ||
| const cmp = | ||
| /** @type {number} */ (b.order) - /** @type {number} */ (a.order); | ||
| const cmp = b.order - a.order; | ||
| if (cmp !== 0) return cmp; | ||
| return a.group.compareTo(chunkGraph, b.group); | ||
| }); | ||
| /** @typedef {{ onChunks: Chunk[], chunks: Chunks }} Entry */ | ||
| /** @type {Entry[]} */ | ||
| const result = []; | ||
| /** @type {undefined | Entry} */ | ||
| let lastEntry; | ||
@@ -806,0 +810,0 @@ for (const { group, childGroup } of list) { |
+30
-9
@@ -46,3 +46,3 @@ /* | ||
| /** @typedef {import("./RuntimeModule")} RuntimeModule */ | ||
| /** @typedef {typeof import("./util/Hash")} Hash */ | ||
| /** @typedef {import("./util/Hash").HashFunction} HashFunction */ | ||
| /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */ | ||
@@ -73,3 +73,5 @@ | ||
| constructor(hash, renderedHash) { | ||
| /** @type {string} */ | ||
| this.hash = hash; | ||
| /** @type {string} */ | ||
| this.renderedHash = renderedHash; | ||
@@ -100,6 +102,7 @@ } | ||
| * @param {SourceTypesByModule | undefined} sourceTypesByModule sourceTypesByModule | ||
| * @returns {(set: SortableSet<Module>) => Map<string, SortableSet<Module>>} modules by source type | ||
| * @returns {ModulesBySourceType} modules by source type | ||
| */ | ||
| const modulesBySourceType = (sourceTypesByModule) => (set) => { | ||
| /** @type {Map<SourceType, SortableSet<Module>>} */ | ||
| /** @typedef {SortableSet<Module>} ModuleSortableSet */ | ||
| /** @type {Map<SourceType, ModuleSortableSet>} */ | ||
| const map = new Map(); | ||
@@ -113,2 +116,3 @@ for (const module of set) { | ||
| if (innerSet === undefined) { | ||
| /** @type {ModuleSortableSet} */ | ||
| innerSet = new SortableSet(); | ||
@@ -129,2 +133,6 @@ map.set(sourceType, innerSet); | ||
| }; | ||
| /** @typedef {(set: SortableSet<Module>) => Map<string, SortableSet<Module>>} ModulesBySourceType */ | ||
| /** @type {ModulesBySourceType} */ | ||
| const defaultModulesBySourceType = modulesBySourceType(undefined); | ||
@@ -172,7 +180,10 @@ | ||
| /** @typedef {Record<string, number>} SizesOfModules */ | ||
| /** | ||
| * @param {Iterable<Module>} modules the sortable Set to get the size of | ||
| * @returns {Record<string, number>} the sizes of the modules | ||
| * @returns {SizesOfModules} the sizes of the modules | ||
| */ | ||
| const getModulesSizes = (modules) => { | ||
| /** @type {SizesOfModules} */ | ||
| const sizes = Object.create(null); | ||
@@ -208,2 +219,3 @@ for (const module of modules) { | ||
| /** @typedef {string | number} ModuleId */ | ||
| /** @typedef {RuntimeSpecMap<Set<string>, RuntimeRequirements>} ChunkGraphRuntimeRequirements */ | ||
@@ -222,3 +234,3 @@ class ChunkGraphModule { | ||
| this.id = null; | ||
| /** @type {RuntimeSpecMap<Set<string>, RuntimeRequirements> | undefined} */ | ||
| /** @type {ChunkGraphRuntimeRequirements | undefined} */ | ||
| this.runtimeRequirements = undefined; | ||
@@ -253,3 +265,3 @@ /** @type {RuntimeSpecMap<string, bigint> | undefined} */ | ||
| this.runtimeRequirementsInTree = new Set(); | ||
| /** @type {ModulesBySourceType} */ | ||
| this._modulesBySourceType = defaultModulesBySourceType; | ||
@@ -263,2 +275,3 @@ } | ||
| /** @typedef {Record<ChunkId, ModuleId[]>} ChunkModuleIdMap */ | ||
| /** @typedef {Record<ChunkId, boolean>} ChunkConditionMap */ | ||
@@ -270,3 +283,3 @@ /** @typedef {(a: Module, b: Module) => -1 | 0 | 1} ModuleComparator */ | ||
| * @param {ModuleGraph} moduleGraph the module graph | ||
| * @param {string | Hash} hashFunction the hash function to use | ||
| * @param {HashFunction} hashFunction the hash function to use | ||
| */ | ||
@@ -823,2 +836,3 @@ constructor(moduleGraph, hashFunction = DEFAULTS.HASH_FUNCTION) { | ||
| if (idToHashMap === undefined) { | ||
| /** @type {IdToHashMap} */ | ||
| idToHashMap = Object.create(null); | ||
@@ -845,5 +859,6 @@ chunkModuleHashMap[/** @type {ChunkId} */ (asyncChunk.id)] = | ||
| * @param {ChunkFilterPredicate} filterFn function used to filter chunks | ||
| * @returns {Record<ChunkId, boolean>} chunk map | ||
| * @returns {ChunkConditionMap} chunk condition map | ||
| */ | ||
| getChunkConditionMap(chunk, filterFn) { | ||
| /** @type {ChunkConditionMap} */ | ||
| const map = Object.create(null); | ||
@@ -864,2 +879,3 @@ for (const c of chunk.getAllReferencedChunks()) { | ||
| const queue = new Set(chunk.groupsIterable); | ||
| /** @type {Set<Chunk>} */ | ||
| const chunksProcessed = new Set(); | ||
@@ -1573,2 +1589,3 @@ | ||
| if (runtimeRequirementsMap === undefined) { | ||
| /** @type {ChunkGraphRuntimeRequirements} */ | ||
| const map = new RuntimeSpecMap(); | ||
@@ -1758,2 +1775,3 @@ // TODO avoid cloning item and track ownership instead | ||
| for (const connection of connections) { | ||
| /** @type {Set<ConnectionState>} */ | ||
| const states = new Set(); | ||
@@ -1773,3 +1791,6 @@ let stateInfo = ""; | ||
| if (state === false) continue; | ||
| stateInfo = activeStateToString(state); | ||
| stateInfo = activeStateToString( | ||
| /** @type {ConnectionState} */ | ||
| (state) | ||
| ); | ||
| } | ||
@@ -1776,0 +1797,0 @@ processConnection(connection, stateInfo); |
@@ -59,3 +59,3 @@ /* | ||
| * @param {OriginRecord} b the second comparator in sort | ||
| * @returns {1 | -1| 0} returns sorting order as index | ||
| * @returns {1 | -1 | 0} returns sorting order as index | ||
| */ | ||
@@ -83,3 +83,4 @@ const sortOrigin = (a, b) => { | ||
| this.groupDebugId = debugId++; | ||
| this.options = /** @type {ChunkGroupOptions} */ (options); | ||
| /** @type {ChunkGroupOptions} */ | ||
| this.options = options; | ||
| /** @type {SortableSet<ChunkGroup>} */ | ||
@@ -91,2 +92,3 @@ this._children = new SortableSet(undefined, sortById); | ||
| this._asyncEntrypoints = new SortableSet(undefined, sortById); | ||
| /** @type {SortableSet<AsyncDependenciesBlock>} */ | ||
| this._blocks = new SortableSet(); | ||
@@ -435,2 +437,3 @@ /** @type {Chunk[]} */ | ||
| getFiles() { | ||
| /** @type {Set<string>} */ | ||
| const files = new Set(); | ||
@@ -512,3 +515,3 @@ | ||
| getChildrenByOrders(moduleGraph, chunkGraph) { | ||
| /** @type {Map<string, {order: number, group: ChunkGroup}[]>} */ | ||
| /** @type {Map<string, { order: number, group: ChunkGroup }[]>} */ | ||
| const lists = new Map(); | ||
@@ -515,0 +518,0 @@ for (const childGroup of this._children) { |
@@ -22,2 +22,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "ChunkRenderError"; | ||
@@ -32,2 +33,3 @@ this.error = error; | ||
| /** @type {typeof ChunkRenderError} */ | ||
| module.exports = ChunkRenderError; |
@@ -73,2 +73,3 @@ /* | ||
| function getDirectories(assets) { | ||
| /** @type {Set<string>} */ | ||
| const directories = new Set(); | ||
@@ -147,2 +148,3 @@ /** | ||
| const getDiffToOldAssets = (currentAssets, oldAssets) => { | ||
| /** @type {Diff} */ | ||
| const diff = new Set(); | ||
@@ -421,3 +423,4 @@ const now = Date.now(); | ||
| for (const asset of Object.keys(compilation.assets)) { | ||
| if (/^[A-Za-z]:\\|^\/|^\\\\/.test(asset)) continue; | ||
| if (/^[a-z]:\\|^\/|^\\\\/i.test(asset)) continue; | ||
| /** @type {string} */ | ||
| let normalizedAsset; | ||
@@ -424,0 +427,0 @@ let newNormalizedAsset = asset.replace(/\\/g, "/"); |
+3
-1
@@ -430,2 +430,3 @@ /* | ||
| /** @type {WeakMap<EXPECTED_OBJECT, number>} */ | ||
| const cliAddedItems = new WeakMap(); | ||
@@ -625,3 +626,3 @@ | ||
| if (typeof value === "number") return value; | ||
| if (typeof value === "string" && /^[+-]?\d*(\.\d*)[eE]\d+$/) { | ||
| if (typeof value === "string" && /^[+-]?\d*(\.\d*)e\d+$/i) { | ||
| const n = Number(value); | ||
@@ -690,2 +691,3 @@ if (!Number.isNaN(n)) return n; | ||
| const processValue = (value, i) => { | ||
| /** @type {Problem[]} */ | ||
| const currentProblems = []; | ||
@@ -692,0 +694,0 @@ for (const argConfig of arg.configs) { |
@@ -21,10 +21,16 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "CodeGenerationError"; | ||
| /** @type {Module} */ | ||
| this.module = module; | ||
| /** @type {Error} */ | ||
| this.error = error; | ||
| /** @type {string} */ | ||
| this.message = error.message; | ||
| /** @type {string} */ | ||
| this.details = error.stack; | ||
| this.module = module; | ||
| } | ||
| } | ||
| /** @type {typeof CodeGenerationError} */ | ||
| module.exports = CodeGenerationError; |
@@ -20,3 +20,3 @@ /* | ||
| /** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */ | ||
| /** @typedef {typeof import("./util/Hash")} Hash */ | ||
| /** @typedef {import("./util/Hash").HashFunction} HashFunction */ | ||
| /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */ | ||
@@ -26,3 +26,3 @@ | ||
| /** | ||
| * @param {string | Hash} hashFunction the hash function to use | ||
| * @param {HashFunction} hashFunction the hash function to use | ||
| */ | ||
@@ -32,2 +32,3 @@ constructor(hashFunction = DEFAULTS.HASH_FUNCTION) { | ||
| this.map = new Map(); | ||
| /** @type {HashFunction} */ | ||
| this._hashFunction = hashFunction; | ||
@@ -158,3 +159,9 @@ } | ||
| add(module, runtime, result) { | ||
| const map = getOrInsert(this.map, module, () => new RuntimeSpecMap()); | ||
| const map = getOrInsert( | ||
| this.map, | ||
| module, | ||
| () => | ||
| /** @type {RuntimeSpecMap<CodeGenerationResult>} */ | ||
| new RuntimeSpecMap() | ||
| ); | ||
| map.set(runtime, result); | ||
@@ -161,0 +168,0 @@ } |
@@ -21,4 +21,5 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "CommentCompilationWarning"; | ||
| /** @type {DependencyLocation} */ | ||
| this.loc = loc; | ||
@@ -25,0 +26,0 @@ } |
+3
-2
@@ -759,2 +759,3 @@ /* | ||
| sizeOnlySource: undefined, | ||
| /** @type {CacheEntry["writtenTo"]} */ | ||
| writtenTo: new Map() | ||
@@ -1059,3 +1060,3 @@ }; | ||
| ], | ||
| (err) => callback(err) | ||
| (err) => callback(/** @type {Error | null} */ (err)) | ||
| ); | ||
@@ -1133,3 +1134,3 @@ } else { | ||
| ], | ||
| (err) => callback(err) | ||
| (err) => callback(/** @type {Error | null} */ (err)) | ||
| ); | ||
@@ -1136,0 +1137,0 @@ } else { |
@@ -40,5 +40,6 @@ /* | ||
| if (Array.isArray(modulesMap)) { | ||
| /** @type {Map<Module, ConcatenatedModuleInfo>} */ | ||
| const map = new Map(); | ||
| for (const info of modulesMap) { | ||
| map.set(info.module, info); | ||
| map.set(info.module, /** @type {ConcatenatedModuleInfo} */ (info)); | ||
| } | ||
@@ -45,0 +46,0 @@ modulesMap = map; |
@@ -12,8 +12,8 @@ /* | ||
| constructor() { | ||
| super(); | ||
| super( | ||
| "You ran Webpack twice. Each instance only supports a single concurrent compilation at a time." | ||
| ); | ||
| this.name = "ConcurrentCompilationError"; | ||
| this.message = | ||
| "You ran Webpack twice. Each instance only supports a single concurrent compilation at a time."; | ||
| } | ||
| }; |
@@ -27,2 +27,7 @@ /* | ||
| /** | ||
| * @typedef {object} WebpackOptionsInterception | ||
| * @property {WebpackOptionsNormalized["devtool"]=} devtool | ||
| */ | ||
| const handledDeprecatedNoEmitOnErrors = util.deprecate( | ||
@@ -586,2 +591,93 @@ /** | ||
| /** | ||
| * @param {WebpackOptionsNormalized} options options to be intercepted | ||
| * @returns {{ options: WebpackOptionsNormalized, interception?: WebpackOptionsInterception }} options and interception | ||
| */ | ||
| const applyWebpackOptionsInterception = (options) => { | ||
| // Return origin options when backCompat is disabled | ||
| if (options.experiments.futureDefaults) { | ||
| return { | ||
| options | ||
| }; | ||
| } | ||
| // TODO webpack6 - remove compatibility logic and move `devtools` fully into `devtool` with multi-type support | ||
| let _devtool = options.devtool; | ||
| /** @type {WebpackOptionsNormalized["devtool"]} */ | ||
| let cached; | ||
| const devtoolBackCompat = () => { | ||
| if (Array.isArray(_devtool)) { | ||
| if (cached) return cached; | ||
| // Prefer `all`, then `javascript`, then `css` | ||
| const match = ["all", "javascript", "css"] | ||
| .map((type) => | ||
| /** @type {Extract<WebpackOptionsNormalized["devtool"], EXPECTED_ANY[]>} */ ( | ||
| _devtool | ||
| ).find((item) => item.type === type) | ||
| ) | ||
| .find(Boolean); | ||
| // If `devtool: []` is specified, return `false` here | ||
| return (cached = match ? match.use : false); | ||
| } | ||
| return _devtool; | ||
| }; | ||
| /** @type {ProxyHandler<WebpackOptionsNormalized>} */ | ||
| const handler = Object.create(null); | ||
| handler.get = (target, prop, receiver) => { | ||
| if (prop === "devtool") { | ||
| return devtoolBackCompat(); | ||
| } | ||
| return Reflect.get(target, prop, receiver); | ||
| }; | ||
| handler.set = (target, prop, value, receiver) => { | ||
| if (prop === "devtool") { | ||
| _devtool = value; | ||
| cached = undefined; | ||
| return true; | ||
| } | ||
| return Reflect.set(target, prop, value, receiver); | ||
| }; | ||
| handler.deleteProperty = (target, prop) => { | ||
| if (prop === "devtool") { | ||
| _devtool = undefined; | ||
| cached = undefined; | ||
| return true; | ||
| } | ||
| return Reflect.deleteProperty(target, prop); | ||
| }; | ||
| handler.defineProperty = (target, prop, descriptor) => { | ||
| if (prop === "devtool") { | ||
| _devtool = descriptor.value; | ||
| cached = undefined; | ||
| return true; | ||
| } | ||
| return Reflect.defineProperty(target, prop, descriptor); | ||
| }; | ||
| handler.getOwnPropertyDescriptor = (target, prop) => { | ||
| if (prop === "devtool") { | ||
| return { | ||
| configurable: true, | ||
| enumerable: true, | ||
| value: devtoolBackCompat(), | ||
| writable: true | ||
| }; | ||
| } | ||
| return Reflect.getOwnPropertyDescriptor(target, prop); | ||
| }; | ||
| return { | ||
| options: new Proxy(options, handler), | ||
| interception: { | ||
| get devtool() { | ||
| return _devtool; | ||
| } | ||
| } | ||
| }; | ||
| }; | ||
| module.exports.applyWebpackOptionsInterception = | ||
| applyWebpackOptionsInterception; | ||
| module.exports.getNormalizedWebpackOptions = getNormalizedWebpackOptions; |
@@ -31,2 +31,3 @@ /* | ||
| /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../Module").Sources} Sources */ | ||
| /** @typedef {import("../Module").SourceTypes} SourceTypes */ | ||
@@ -151,2 +152,3 @@ /** @typedef {import("../RequestShortener")} RequestShortener */ | ||
| codeGeneration({ moduleGraph, chunkGraph, runtimeTemplate }) { | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -158,2 +160,3 @@ const runtimeRequirements = new Set([ | ||
| ]); | ||
| /** @type {string[]} */ | ||
| const getters = []; | ||
@@ -173,2 +176,3 @@ | ||
| /** @type {string} */ | ||
| let str; | ||
@@ -175,0 +179,0 @@ |
@@ -31,2 +31,3 @@ /* | ||
| /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../Module").Sources} Sources */ | ||
| /** @typedef {import("../Module").SourceTypes} SourceTypes */ | ||
@@ -162,2 +163,3 @@ /** @typedef {import("../RequestShortener")} RequestShortener */ | ||
| ]); | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -164,0 +166,0 @@ sources.set(JAVASCRIPT_TYPE, new RawSource(code)); |
@@ -37,3 +37,5 @@ /* | ||
| getModuleFederationPlugin().getCompilationHooks(compilation); | ||
| /** @type {Set<Dependency>} */ | ||
| const depsToTrace = new Set(); | ||
| /** @type {Set<Dependency>} */ | ||
| const entryExternalsToHoist = new Set(); | ||
@@ -93,2 +95,3 @@ hooks.addContainerEntryDependency.tap(PLUGIN_NAME, (dep) => { | ||
| const containerRuntimes = chunkGraph.getModuleRuntimes(entryModule); | ||
| /** @type {Set<string>} */ | ||
| const runtimes = new Set(); | ||
@@ -141,2 +144,3 @@ | ||
| chunkGraph.getModuleRuntimes(containerEntryModule); | ||
| /** @type {Set<string>} */ | ||
| const runtimes = new Set(); | ||
@@ -204,3 +208,5 @@ | ||
| const collectedModules = new Set(includeInitial ? [module] : []); | ||
| /** @type {WeakSet<Module>} */ | ||
| const visitedModules = new WeakSet([module]); | ||
| /** @type {Module[]} */ | ||
| const stack = [module]; | ||
@@ -207,0 +213,0 @@ |
@@ -21,2 +21,3 @@ /* | ||
| /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */ | ||
| /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */ | ||
| /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */ | ||
@@ -28,3 +29,6 @@ /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../Module").Sources} Sources */ | ||
| /** @typedef {import("../Module").SourceTypes} SourceTypes */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../Module").ExportsType} ExportsType */ | ||
| /** @typedef {import("../RequestShortener")} RequestShortener */ | ||
@@ -134,2 +138,15 @@ /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** | ||
| * @param {ModuleGraph} moduleGraph the module graph | ||
| * @param {boolean | undefined} strict the importing module is strict | ||
| * @returns {ExportsType} export type | ||
| * "namespace": Exports is already a namespace object. namespace = exports. | ||
| * "dynamic": Check at runtime if __esModule is set. When set: namespace = { ...exports, default: exports }. When not set: namespace = { default: exports }. | ||
| * "default-only": Provide a namespace object with only default export. namespace = { default: exports } | ||
| * "default-with-named": Provide a namespace object with named and default export. namespace = { ...exports, default: exports } | ||
| */ | ||
| getExportsType(moduleGraph, strict) { | ||
| return "dynamic"; | ||
| } | ||
| /** | ||
| * @returns {NameForCondition | null} absolute path which should be used for condition matching (usually the resource path) | ||
@@ -148,4 +165,6 @@ */ | ||
| const id = module && chunkGraph.getModuleId(module); | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
| sources.set("remote", new RawSource("")); | ||
| /** @type {CodeGenerationResultData} */ | ||
| const data = new Map(); | ||
@@ -152,0 +171,0 @@ data.set("share-init", [ |
+248
-111
@@ -21,2 +21,6 @@ /* | ||
| const { | ||
| getOutgoingAsyncModules | ||
| } = require("./async-modules/AsyncModuleHelpers"); | ||
| const { ImportPhase, ImportPhaseUtils } = require("./dependencies/ImportPhase"); | ||
| const { | ||
| compareLocations, | ||
@@ -58,2 +62,4 @@ compareModulesById, | ||
| /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("./Module").Sources} Sources */ | ||
| /** @typedef {import("./RequestShortener")} RequestShortener */ | ||
@@ -67,2 +73,3 @@ /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ | ||
| /** @typedef {import("./dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */ | ||
@@ -87,2 +94,3 @@ /** @typedef {"sync" | "eager" | "weak" | "async-weak" | "lazy" | "lazy-once"} ContextMode Context mode */ | ||
| * @property {ImportAttributes=} attributes | ||
| * @property {ImportPhaseType=} phase | ||
| */ | ||
@@ -117,2 +125,3 @@ | ||
| /** @typedef {Record<ModuleId, FakeMapType>} FakeMap */ | ||
| /** @typedef {Record<string, ModuleId>} UserRequestMap */ | ||
@@ -268,2 +277,5 @@ class ContextModule extends Module { | ||
| } | ||
| if (this.options.phase) { | ||
| identifier += `|importPhase: ${this.options.phase}`; | ||
| } | ||
| if (this.layer) { | ||
@@ -287,3 +299,5 @@ identifier += `|layer: ${this.layer}`; | ||
| readableIdentifier(requestShortener) { | ||
| /** @type {string} */ | ||
| let identifier; | ||
| if (this.context) { | ||
@@ -352,2 +366,3 @@ identifier = `${requestShortener.shorten(this.context)}/`; | ||
| libIdent(options) { | ||
| /** @type {string} */ | ||
| let identifier; | ||
@@ -520,3 +535,3 @@ | ||
| if (chunkName) { | ||
| if (!/\[(index|request)\]/.test(chunkName)) { | ||
| if (!/\[(?:index|request)\]/.test(chunkName)) { | ||
| chunkName += "[index]"; | ||
@@ -597,3 +612,3 @@ } | ||
| * @param {ChunkGraph} chunkGraph chunk graph | ||
| * @returns {Map<string, ModuleId>} map with user requests | ||
| * @returns {UserRequestMap} map with user requests | ||
| */ | ||
@@ -615,6 +630,9 @@ getUserRequestMap(dependencies, chunkGraph) { | ||
| }); | ||
| /** @type {UserRequestMap} */ | ||
| const map = Object.create(null); | ||
| for (const dep of sortedDependencies) { | ||
| const module = /** @type {Module} */ (moduleGraph.getModule(dep)); | ||
| map[dep.userRequest] = chunkGraph.getModuleId(module); | ||
| map[dep.userRequest] = | ||
| /** @type {ModuleId} */ | ||
| (chunkGraph.getModuleId(module)); | ||
| } | ||
@@ -705,2 +723,43 @@ return map; | ||
| /** | ||
| * @param {Dependency[]} dependencies all dependencies | ||
| * @param {ChunkGraph} chunkGraph chunk graph | ||
| * @returns {Map<string, ModuleId[] | undefined>} map with user requests | ||
| */ | ||
| getModuleDeferredAsyncDepsMap(dependencies, chunkGraph) { | ||
| const moduleGraph = chunkGraph.moduleGraph; | ||
| const comparator = compareModulesById(chunkGraph); | ||
| // if we filter first we get a new array | ||
| // therefore we don't need to create a clone of dependencies explicitly | ||
| // therefore the order of this is !important! | ||
| const sortedModules = dependencies | ||
| .map( | ||
| (dependency) => | ||
| /** @type {Module} */ (moduleGraph.getModule(dependency)) | ||
| ) | ||
| .filter(Boolean) | ||
| .sort(comparator); | ||
| const map = Object.create(null); | ||
| for (const module of sortedModules) { | ||
| if (!(/** @type {BuildMeta} */ (module.buildMeta).async)) { | ||
| const id = /** @type {ModuleId} */ (chunkGraph.getModuleId(module)); | ||
| map[id] = Array.from( | ||
| getOutgoingAsyncModules(chunkGraph.moduleGraph, module), | ||
| (m) => chunkGraph.getModuleId(m) | ||
| ).filter((id) => id !== null); | ||
| } | ||
| } | ||
| return map; | ||
| } | ||
| /** | ||
| * @param {false | Map<string, ModuleId[] | undefined>} asyncDepsMap fake map | ||
| * @returns {string} async deps map init statement | ||
| */ | ||
| getModuleDeferredAsyncDepsMapInitStatement(asyncDepsMap) { | ||
| return typeof asyncDepsMap === "object" | ||
| ? `var asyncDepsMap = ${JSON.stringify(asyncDepsMap, null, "\t")};` | ||
| : ""; | ||
| } | ||
| /** | ||
| * @param {FakeMapType} type type | ||
@@ -721,3 +780,4 @@ * @param {boolean=} asyncModule is async module | ||
| * @param {FakeMap | FakeMapType} fakeMap fake map | ||
| * @param {boolean=} asyncModule us async module | ||
| * @param {boolean=} asyncModule is async module | ||
| * @param {string=} asyncDeps async deps for deferred module | ||
| * @param {string=} fakeMapDataExpression fake map data expression | ||
@@ -729,10 +789,18 @@ * @returns {string} module object source | ||
| asyncModule, | ||
| asyncDeps, | ||
| fakeMapDataExpression = "fakeMap[id]" | ||
| ) { | ||
| if (typeof fakeMap === "number") { | ||
| return `return ${this.getReturn(fakeMap, asyncModule)};`; | ||
| const source = | ||
| typeof fakeMap === "number" | ||
| ? this.getReturn(fakeMap, asyncModule) | ||
| : `${RuntimeGlobals.createFakeNamespaceObject}(id, ${fakeMapDataExpression}${asyncModule ? " | 16" : ""})`; | ||
| if (asyncDeps) { | ||
| if (!asyncModule) { | ||
| throw new Error("Must be async when module is deferred"); | ||
| } | ||
| const type = | ||
| typeof fakeMap === "number" ? fakeMap : fakeMapDataExpression; | ||
| return `${asyncDeps} ? ${asyncDeps}.length ? ${RuntimeGlobals.deferredModuleAsyncTransitiveDependencies}(${asyncDeps}).then(${RuntimeGlobals.makeDeferredNamespaceObject}.bind(${RuntimeGlobals.require}, id, ${type} ^ 1, true)) : ${RuntimeGlobals.makeDeferredNamespaceObject}(id, ${type} ^ 1 | 16) : ${source}`; | ||
| } | ||
| return `return ${ | ||
| RuntimeGlobals.createFakeNamespaceObject | ||
| }(id, ${fakeMapDataExpression}${asyncModule ? " | 16" : ""})`; | ||
| return source; | ||
| } | ||
@@ -756,3 +824,3 @@ | ||
| var id = webpackContextResolve(req); | ||
| ${returnModuleObject} | ||
| return ${returnModuleObject}; | ||
| } | ||
@@ -796,3 +864,3 @@ function webpackContextResolve(req) { | ||
| } | ||
| ${returnModuleObject} | ||
| return ${returnModuleObject}; | ||
| } | ||
@@ -818,2 +886,3 @@ function webpackContextResolve(req) { | ||
| * @param {ModuleId} id module id | ||
| * @param {ImportPhaseType} phase import phase | ||
| * @param {object} context context | ||
@@ -824,22 +893,32 @@ * @param {ChunkGraph} context.chunkGraph the chunk graph | ||
| */ | ||
| getAsyncWeakSource(dependencies, id, { chunkGraph, runtimeTemplate }) { | ||
| const arrow = runtimeTemplate.supportsArrowFunction(); | ||
| getAsyncWeakSource(dependencies, id, phase, { chunkGraph, runtimeTemplate }) { | ||
| const map = this.getUserRequestMap(dependencies, chunkGraph); | ||
| const fakeMap = this.getFakeMap(dependencies, chunkGraph); | ||
| const returnModuleObject = this.getReturnModuleObjectSource(fakeMap, true); | ||
| const asyncDepsMap = | ||
| ImportPhaseUtils.isDefer(phase) && | ||
| this.getModuleDeferredAsyncDepsMap(dependencies, chunkGraph); | ||
| const returnModuleObject = this.getReturnModuleObjectSource( | ||
| fakeMap, | ||
| true, | ||
| asyncDepsMap ? "asyncDepsMap[id]" : undefined | ||
| ); | ||
| return `var map = ${JSON.stringify(map, null, "\t")}; | ||
| ${this.getFakeMapInitStatement(fakeMap)} | ||
| ${this.getModuleDeferredAsyncDepsMapInitStatement(asyncDepsMap)} | ||
| function webpackAsyncContext(req) { | ||
| return webpackAsyncContextResolve(req).then(${ | ||
| arrow ? "id =>" : "function(id)" | ||
| } { | ||
| if(!${RuntimeGlobals.moduleFactories}[id]) { | ||
| var e = new Error("Module '" + req + "' ('" + id + "') is not available (weak dependency)"); | ||
| e.code = 'MODULE_NOT_FOUND'; | ||
| throw e; | ||
| } | ||
| ${returnModuleObject} | ||
| }); | ||
| return webpackAsyncContextResolve(req).then(${runtimeTemplate.basicFunction( | ||
| "id", | ||
| [ | ||
| `if(!${RuntimeGlobals.moduleFactories}[id]) {`, | ||
| Template.indent([ | ||
| 'var e = new Error("Module \'" + req + "\' (\'" + id + "\') is not available (weak dependency)");', | ||
| "e.code = 'MODULE_NOT_FOUND';", | ||
| "throw e;" | ||
| ]), | ||
| "}", | ||
| `return ${returnModuleObject};` | ||
| ] | ||
| )}); | ||
| } | ||
@@ -849,10 +928,12 @@ function webpackAsyncContextResolve(req) { | ||
| // uncaught exception popping up in devtools | ||
| return Promise.resolve().then(${arrow ? "() =>" : "function()"} { | ||
| if(!${RuntimeGlobals.hasOwnProperty}(map, req)) { | ||
| var e = new Error("Cannot find module '" + req + "'"); | ||
| e.code = 'MODULE_NOT_FOUND'; | ||
| throw e; | ||
| } | ||
| return map[req]; | ||
| }); | ||
| return Promise.resolve().then(${runtimeTemplate.basicFunction("", [ | ||
| `if(!${RuntimeGlobals.hasOwnProperty}(map, req)) {`, | ||
| Template.indent([ | ||
| 'var e = new Error("Cannot find module \'" + req + "\'");', | ||
| "e.code = 'MODULE_NOT_FOUND';", | ||
| "throw e;" | ||
| ]), | ||
| "}", | ||
| "return map[req];" | ||
| ])}); | ||
| } | ||
@@ -870,2 +951,3 @@ webpackAsyncContext.keys = ${runtimeTemplate.returningFunction( | ||
| * @param {ModuleId} id module id | ||
| * @param {ImportPhaseType} phase import phase | ||
| * @param {object} context context | ||
@@ -876,14 +958,20 @@ * @param {ChunkGraph} context.chunkGraph the chunk graph | ||
| */ | ||
| getEagerSource(dependencies, id, { chunkGraph, runtimeTemplate }) { | ||
| const arrow = runtimeTemplate.supportsArrowFunction(); | ||
| getEagerSource(dependencies, id, phase, { chunkGraph, runtimeTemplate }) { | ||
| const map = this.getUserRequestMap(dependencies, chunkGraph); | ||
| const fakeMap = this.getFakeMap(dependencies, chunkGraph); | ||
| const thenFunction = | ||
| fakeMap !== 9 | ||
| ? `${arrow ? "id =>" : "function(id)"} { | ||
| ${this.getReturnModuleObjectSource(fakeMap, true)} | ||
| }` | ||
| : RuntimeGlobals.require; | ||
| const asyncDepsMap = | ||
| ImportPhaseUtils.isDefer(phase) && | ||
| this.getModuleDeferredAsyncDepsMap(dependencies, chunkGraph); | ||
| const thenFunction = runtimeTemplate.returningFunction( | ||
| this.getReturnModuleObjectSource( | ||
| fakeMap, | ||
| true, | ||
| asyncDepsMap ? "asyncDepsMap[id]" : undefined | ||
| ), | ||
| "id" | ||
| ); | ||
| return `var map = ${JSON.stringify(map, null, "\t")}; | ||
| ${this.getFakeMapInitStatement(fakeMap)} | ||
| ${this.getModuleDeferredAsyncDepsMapInitStatement(asyncDepsMap)} | ||
@@ -896,10 +984,12 @@ function webpackAsyncContext(req) { | ||
| // uncaught exception popping up in devtools | ||
| return Promise.resolve().then(${arrow ? "() =>" : "function()"} { | ||
| if(!${RuntimeGlobals.hasOwnProperty}(map, req)) { | ||
| var e = new Error("Cannot find module '" + req + "'"); | ||
| e.code = 'MODULE_NOT_FOUND'; | ||
| throw e; | ||
| } | ||
| return map[req]; | ||
| }); | ||
| return Promise.resolve().then(${runtimeTemplate.basicFunction("", [ | ||
| `if(!${RuntimeGlobals.hasOwnProperty}(map, req)) {`, | ||
| Template.indent([ | ||
| 'var e = new Error("Cannot find module \'" + req + "\'");', | ||
| "e.code = 'MODULE_NOT_FOUND';", | ||
| "throw e;" | ||
| ]), | ||
| "}", | ||
| "return map[req];" | ||
| ])}); | ||
| } | ||
@@ -918,2 +1008,3 @@ webpackAsyncContext.keys = ${runtimeTemplate.returningFunction( | ||
| * @param {ModuleId} id module id | ||
| * @param {ImportPhaseType} phase import phase | ||
| * @param {object} options options object | ||
@@ -924,3 +1015,9 @@ * @param {RuntimeTemplate} options.runtimeTemplate the runtime template | ||
| */ | ||
| getLazyOnceSource(block, dependencies, id, { runtimeTemplate, chunkGraph }) { | ||
| getLazyOnceSource( | ||
| block, | ||
| dependencies, | ||
| id, | ||
| phase, | ||
| { runtimeTemplate, chunkGraph } | ||
| ) { | ||
| const promise = runtimeTemplate.blockPromise({ | ||
@@ -930,16 +1027,22 @@ chunkGraph, | ||
| message: "lazy-once context", | ||
| /** @type {RuntimeRequirements} */ | ||
| runtimeRequirements: new Set() | ||
| }); | ||
| const arrow = runtimeTemplate.supportsArrowFunction(); | ||
| const map = this.getUserRequestMap(dependencies, chunkGraph); | ||
| const fakeMap = this.getFakeMap(dependencies, chunkGraph); | ||
| const thenFunction = | ||
| fakeMap !== 9 | ||
| ? `${arrow ? "id =>" : "function(id)"} { | ||
| ${this.getReturnModuleObjectSource(fakeMap, true)}; | ||
| }` | ||
| : RuntimeGlobals.require; | ||
| const asyncDepsMap = | ||
| ImportPhaseUtils.isDefer(phase) && | ||
| this.getModuleDeferredAsyncDepsMap(dependencies, chunkGraph); | ||
| const thenFunction = runtimeTemplate.returningFunction( | ||
| this.getReturnModuleObjectSource( | ||
| fakeMap, | ||
| true, | ||
| asyncDepsMap ? "asyncDepsMap[id]" : undefined | ||
| ), | ||
| "id" | ||
| ); | ||
| return `var map = ${JSON.stringify(map, null, "\t")}; | ||
| ${this.getFakeMapInitStatement(fakeMap)} | ||
| ${this.getModuleDeferredAsyncDepsMapInitStatement(asyncDepsMap)} | ||
@@ -950,10 +1053,12 @@ function webpackAsyncContext(req) { | ||
| function webpackAsyncContextResolve(req) { | ||
| return ${promise}.then(${arrow ? "() =>" : "function()"} { | ||
| if(!${RuntimeGlobals.hasOwnProperty}(map, req)) { | ||
| var e = new Error("Cannot find module '" + req + "'"); | ||
| e.code = 'MODULE_NOT_FOUND'; | ||
| throw e; | ||
| } | ||
| return map[req]; | ||
| }); | ||
| return ${promise}.then(${runtimeTemplate.basicFunction("", [ | ||
| `if(!${RuntimeGlobals.hasOwnProperty}(map, req)) {`, | ||
| Template.indent([ | ||
| 'var e = new Error("Cannot find module \'" + req + "\'");', | ||
| "e.code = 'MODULE_NOT_FOUND';", | ||
| "throw e;" | ||
| ]), | ||
| "}", | ||
| "return map[req];" | ||
| ])}); | ||
| } | ||
@@ -971,2 +1076,3 @@ webpackAsyncContext.keys = ${runtimeTemplate.returningFunction( | ||
| * @param {ModuleId} id module id | ||
| * @param {ImportPhaseType} phase import phase | ||
| * @param {object} context context | ||
@@ -977,7 +1083,7 @@ * @param {ChunkGraph} context.chunkGraph the chunk graph | ||
| */ | ||
| getLazySource(blocks, id, { chunkGraph, runtimeTemplate }) { | ||
| getLazySource(blocks, id, phase, { chunkGraph, runtimeTemplate }) { | ||
| const moduleGraph = chunkGraph.moduleGraph; | ||
| const arrow = runtimeTemplate.supportsArrowFunction(); | ||
| let hasMultipleOrNoChunks = false; | ||
| let hasNoChunk = true; | ||
| let hasNoModuleDeferred = true; | ||
| const fakeMap = this.getFakeMap( | ||
@@ -988,3 +1094,3 @@ blocks.map((b) => b.dependencies[0]), | ||
| const hasFakeMap = typeof fakeMap === "object"; | ||
| /** @typedef {{userRequest: string, dependency: ContextElementDependency, chunks: undefined | Chunk[], module: Module, block: AsyncDependenciesBlock}} Item */ | ||
| /** @typedef {{ userRequest: string, dependency: ContextElementDependency, chunks: undefined | Chunk[], module: Module, block: AsyncDependenciesBlock, asyncDeps: undefined | ModuleId[] }} Item */ | ||
| /** | ||
@@ -1003,3 +1109,4 @@ * @type {Item[]} | ||
| userRequest: dependency.userRequest, | ||
| chunks: undefined | ||
| chunks: undefined, | ||
| asyncDeps: undefined | ||
| }; | ||
@@ -1018,4 +1125,15 @@ }) | ||
| } | ||
| const isModuleDeferred = | ||
| ImportPhaseUtils.isDefer(phase) && | ||
| !(/** @type {BuildMeta} */ (item.module.buildMeta).async); | ||
| if (isModuleDeferred) { | ||
| const asyncDeps = Array.from( | ||
| getOutgoingAsyncModules(chunkGraph.moduleGraph, item.module), | ||
| (m) => chunkGraph.getModuleId(m) | ||
| ).filter((id) => id !== null); | ||
| item.asyncDeps = asyncDeps; | ||
| hasNoModuleDeferred = false; | ||
| } | ||
| } | ||
| const shortMode = hasNoChunk && !hasFakeMap; | ||
| const shortMode = hasNoChunk && hasNoModuleDeferred && !hasFakeMap; | ||
| const sortedItems = items.sort((a, b) => { | ||
@@ -1025,3 +1143,3 @@ if (a.userRequest === b.userRequest) return 0; | ||
| }); | ||
| /** @type {Record<string, ModuleId | (ModuleId[] | ChunkId[])>} */ | ||
| /** @type {Record<string, ModuleId | (ModuleId | FakeMapType | ChunkId[] | (ModuleId[] | undefined))[]>} */ | ||
| const map = Object.create(null); | ||
@@ -1035,24 +1153,32 @@ for (const item of sortedItems) { | ||
| } else { | ||
| /** @type {(ModuleId | ChunkId)[]} */ | ||
| const arrayStart = [moduleId]; | ||
| /** @type {(ModuleId | FakeMapType | ChunkId[] | (ModuleId[] | undefined))[]} */ | ||
| const array = [moduleId]; | ||
| if (hasFakeMap) { | ||
| arrayStart.push(fakeMap[moduleId]); | ||
| array.push(fakeMap[moduleId]); | ||
| } | ||
| map[item.userRequest] = [ | ||
| ...arrayStart, | ||
| .../** @type {Chunk[]} */ | ||
| (item.chunks).map((chunk) => /** @type {ChunkId} */ (chunk.id)) | ||
| ]; | ||
| if (!hasNoChunk) { | ||
| array.push( | ||
| /** @type {Chunk[]} */ (item.chunks).map( | ||
| (chunk) => /** @type {ChunkId} */ (chunk.id) | ||
| ) | ||
| ); | ||
| } | ||
| if (!hasNoModuleDeferred) { | ||
| array.push(item.asyncDeps); | ||
| } | ||
| map[item.userRequest] = array; | ||
| } | ||
| } | ||
| const chunksStartPosition = hasFakeMap ? 2 : 1; | ||
| const chunksPosition = hasFakeMap ? 2 : 1; | ||
| const asyncDepsPosition = chunksPosition + 1; | ||
| const requestPrefix = hasNoChunk | ||
| ? "Promise.resolve()" | ||
| : hasMultipleOrNoChunks | ||
| ? `Promise.all(ids.slice(${chunksStartPosition}).map(${RuntimeGlobals.ensureChunk}))` | ||
| : `${RuntimeGlobals.ensureChunk}(ids[${chunksStartPosition}])`; | ||
| ? `Promise.all(ids[${chunksPosition}].map(${RuntimeGlobals.ensureChunk}))` | ||
| : `${RuntimeGlobals.ensureChunk}(ids[${chunksPosition}][0])`; | ||
| const returnModuleObject = this.getReturnModuleObjectSource( | ||
| fakeMap, | ||
| true, | ||
| hasNoModuleDeferred ? undefined : `ids[${asyncDepsPosition}]`, | ||
| shortMode ? "invalid" : "ids[1]" | ||
@@ -1065,26 +1191,25 @@ ); | ||
| function webpackAsyncContext(req) { | ||
| return Promise.resolve().then(${arrow ? "() =>" : "function()"} { | ||
| if(!${RuntimeGlobals.hasOwnProperty}(map, req)) { | ||
| var e = new Error("Cannot find module '" + req + "'"); | ||
| e.code = 'MODULE_NOT_FOUND'; | ||
| throw e; | ||
| } | ||
| ${shortMode ? "var id = map[req];" : "var ids = map[req], id = ids[0];"} | ||
| ${returnModuleObject} | ||
| }); | ||
| return Promise.resolve().then(${runtimeTemplate.basicFunction("", [ | ||
| `if(!${RuntimeGlobals.hasOwnProperty}(map, req)) {`, | ||
| Template.indent([ | ||
| 'var e = new Error("Cannot find module \'" + req + "\'");', | ||
| "e.code = 'MODULE_NOT_FOUND';", | ||
| "throw e;" | ||
| ]), | ||
| "}", | ||
| shortMode ? "var id = map[req];" : "var ids = map[req], id = ids[0];", | ||
| `return ${returnModuleObject};` | ||
| ])}); | ||
| }` | ||
| : `function webpackAsyncContext(req) { | ||
| if(!${RuntimeGlobals.hasOwnProperty}(map, req)) { | ||
| return Promise.resolve().then(${arrow ? "() =>" : "function()"} { | ||
| var e = new Error("Cannot find module '" + req + "'"); | ||
| e.code = 'MODULE_NOT_FOUND'; | ||
| throw e; | ||
| }); | ||
| return Promise.resolve().then(${runtimeTemplate.basicFunction("", [ | ||
| 'var e = new Error("Cannot find module \'" + req + "\'");', | ||
| "e.code = 'MODULE_NOT_FOUND';", | ||
| "throw e;" | ||
| ])}); | ||
| } | ||
| var ids = map[req], id = ids[0]; | ||
| return ${requestPrefix}.then(${arrow ? "() =>" : "function()"} { | ||
| ${returnModuleObject} | ||
| }); | ||
| return ${requestPrefix}.then(${runtimeTemplate.returningFunction(returnModuleObject)}); | ||
| }`; | ||
@@ -1124,11 +1249,10 @@ | ||
| getSourceForEmptyAsyncContext(id, runtimeTemplate) { | ||
| const arrow = runtimeTemplate.supportsArrowFunction(); | ||
| return `function webpackEmptyAsyncContext(req) { | ||
| // Here Promise.resolve().then() is used instead of new Promise() to prevent | ||
| // uncaught exception popping up in devtools | ||
| return Promise.resolve().then(${arrow ? "() =>" : "function()"} { | ||
| var e = new Error("Cannot find module '" + req + "'"); | ||
| e.code = 'MODULE_NOT_FOUND'; | ||
| throw e; | ||
| }); | ||
| return Promise.resolve().then(${runtimeTemplate.basicFunction("", [ | ||
| 'var e = new Error("Cannot find module \'" + req + "\'");', | ||
| "e.code = 'MODULE_NOT_FOUND';", | ||
| "throw e;" | ||
| ])}); | ||
| } | ||
@@ -1143,10 +1267,11 @@ webpackEmptyAsyncContext.keys = ${runtimeTemplate.returningFunction("[]")}; | ||
| * @param {string} asyncMode module mode | ||
| * @param {ImportPhaseType} phase import phase | ||
| * @param {CodeGenerationContext} context context info | ||
| * @returns {string} the source code | ||
| */ | ||
| getSourceString(asyncMode, { runtimeTemplate, chunkGraph }) { | ||
| getSourceString(asyncMode, phase, { runtimeTemplate, chunkGraph }) { | ||
| const id = /** @type {ModuleId} */ (chunkGraph.getModuleId(this)); | ||
| if (asyncMode === "lazy") { | ||
| if (this.blocks && this.blocks.length > 0) { | ||
| return this.getLazySource(this.blocks, id, { | ||
| return this.getLazySource(this.blocks, id, phase, { | ||
| runtimeTemplate, | ||
@@ -1160,3 +1285,3 @@ chunkGraph | ||
| if (this.dependencies && this.dependencies.length > 0) { | ||
| return this.getEagerSource(this.dependencies, id, { | ||
| return this.getEagerSource(this.dependencies, id, phase, { | ||
| chunkGraph, | ||
@@ -1171,3 +1296,3 @@ runtimeTemplate | ||
| if (block) { | ||
| return this.getLazyOnceSource(block, block.dependencies, id, { | ||
| return this.getLazyOnceSource(block, block.dependencies, id, phase, { | ||
| runtimeTemplate, | ||
@@ -1181,3 +1306,3 @@ chunkGraph | ||
| if (this.dependencies && this.dependencies.length > 0) { | ||
| return this.getAsyncWeakSource(this.dependencies, id, { | ||
| return this.getAsyncWeakSource(this.dependencies, id, phase, { | ||
| chunkGraph, | ||
@@ -1227,2 +1352,4 @@ runtimeTemplate | ||
| const { chunkGraph, compilation } = context; | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -1232,6 +1359,11 @@ sources.set( | ||
| this.getSource( | ||
| this.getSourceString(this.options.mode, context), | ||
| this.getSourceString( | ||
| this.options.mode, | ||
| this.options.phase || ImportPhase.Evaluation, | ||
| context | ||
| ), | ||
| compilation | ||
| ) | ||
| ); | ||
| /** @type {RuntimeRequirements} */ | ||
| const set = new Set(); | ||
@@ -1263,2 +1395,7 @@ const allDeps = | ||
| } | ||
| if ( | ||
| ImportPhaseUtils.isDefer(this.options.phase || ImportPhase.Evaluation) | ||
| ) { | ||
| set.add(RuntimeGlobals.makeDeferredNamespaceObject); | ||
| } | ||
| } | ||
@@ -1265,0 +1402,0 @@ return { |
@@ -100,2 +100,3 @@ /* | ||
| }); | ||
| /** @type {ResolverFactory} */ | ||
| this.resolverFactory = resolverFactory; | ||
@@ -114,4 +115,7 @@ } | ||
| const dependency = dependencies[0]; | ||
| /** @type {FileSystemDependencies} */ | ||
| const fileDependencies = new LazySet(); | ||
| /** @type {FileSystemDependencies} */ | ||
| const missingDependencies = new LazySet(); | ||
| /** @type {FileSystemDependencies} */ | ||
| const contextDependencies = new LazySet(); | ||
@@ -159,2 +163,3 @@ this.hooks.beforeResolve.callAsync( | ||
| let loadersRequest = request.slice(0, idx + 1); | ||
| /** @type {number} */ | ||
| let i; | ||
@@ -171,3 +176,3 @@ for ( | ||
| .replace(/!+$/, "") | ||
| .replace(/!!+/g, "!"); | ||
| .replace(/!{2,}/g, "!"); | ||
| loaders = loadersRequest === "" ? [] : loadersRequest.split("!"); | ||
@@ -446,2 +451,3 @@ resource = request.slice(idx + 1); | ||
| /** @type {ContextElementDependency[]} */ | ||
| const flattenedResult = []; | ||
@@ -474,3 +480,9 @@ | ||
| if (typeof fs.realpath === "function") { | ||
| addDirectoryChecked(resource, resource, new Set(), callback); | ||
| addDirectoryChecked( | ||
| resource, | ||
| resource, | ||
| /** @type {Set<string>} */ | ||
| new Set(), | ||
| callback | ||
| ); | ||
| } else { | ||
@@ -477,0 +489,0 @@ addDirectory(resource, resource, addSubDirectory, callback); |
@@ -22,2 +22,3 @@ /* | ||
| const CssImportDependency = require("../dependencies/CssImportDependency"); | ||
| const EntryDependency = require("../dependencies/EntryDependency"); | ||
| const { getUndoPath } = require("../util/identifier"); | ||
@@ -366,2 +367,3 @@ const memoize = require("../util/memoize"); | ||
| const source = new ConcatSource(); | ||
| /** @type {Set<string>} */ | ||
| const usedIdentifiers = new Set(); | ||
@@ -418,2 +420,3 @@ const { RESERVED_IDENTIFIER } = getPropertyName(); | ||
| /** @type {string[]} */ | ||
| const exports = []; | ||
@@ -471,9 +474,15 @@ | ||
| getTypes(module) { | ||
| if (this._generatesJsOnly(module)) { | ||
| return JAVASCRIPT_TYPES; | ||
| } | ||
| const exportType = /** @type {BuildMeta} */ (module.buildMeta).exportType; | ||
| const sourceTypes = new Set(); | ||
| const connections = this._moduleGraph.getIncomingConnections(module); | ||
| let isEntryModule = false; | ||
| for (const connection of connections) { | ||
| if (connection.dependency instanceof CssImportDependency) { | ||
| if (connection.dependency instanceof EntryDependency) { | ||
| isEntryModule = true; | ||
| } | ||
| if ( | ||
| exportType === "link" && | ||
| connection.dependency instanceof CssImportDependency | ||
| ) { | ||
| continue; | ||
@@ -486,4 +495,22 @@ } | ||
| sourceTypes.add(JAVASCRIPT_TYPE); | ||
| } else { | ||
| const originModule = /** @type {CssModule} */ connection.originModule; | ||
| const originExportType = /** @type {BuildMeta} */ ( | ||
| originModule.buildMeta | ||
| ).exportType; | ||
| if ( | ||
| /** @type {boolean} */ ( | ||
| originExportType && originExportType !== "link" | ||
| ) | ||
| ) { | ||
| sourceTypes.add(JAVASCRIPT_TYPE); | ||
| } | ||
| } | ||
| } | ||
| if (this._generatesJsOnly(module)) { | ||
| if (sourceTypes.has(JAVASCRIPT_TYPE) || isEntryModule) { | ||
| return JAVASCRIPT_TYPES; | ||
| } | ||
| return new Set(); | ||
| } | ||
| if (sourceTypes.has(JAVASCRIPT_TYPE)) { | ||
@@ -490,0 +517,0 @@ return JAVASCRIPT_AND_CSS_TYPES; |
@@ -38,3 +38,3 @@ /* | ||
| const JavascriptModulesPlugin = require("../javascript/JavascriptModulesPlugin"); | ||
| const { compareModulesByIdOrIdentifier } = require("../util/comparators"); | ||
| const { compareModulesByFullName } = require("../util/comparators"); | ||
| const createSchemaValidation = require("../util/create-schema-validation"); | ||
@@ -315,3 +315,3 @@ const createHash = require("../util/createHash"); | ||
| if (parent instanceof CssModule) { | ||
| /** @type {import("../CssModule").Inheritance | undefined} */ | ||
| /** @type {Inheritance | undefined} */ | ||
| let inheritance; | ||
@@ -422,2 +422,3 @@ | ||
| }); | ||
| /** @type {WeakMap<Chunk, CssModule[]>} */ | ||
| const orderedCssModulesPerChunk = new WeakMap(); | ||
@@ -532,2 +533,3 @@ compilation.hooks.afterCodeGeneration.tap(PLUGIN_NAME, () => { | ||
| }; | ||
| /** @type {WeakSet<Chunk>} */ | ||
| const onceForChunkSet = new WeakSet(); | ||
@@ -604,3 +606,3 @@ /** | ||
| * @param {Chunk} chunk chunk | ||
| * @param {Iterable<Module>} modules unordered modules | ||
| * @param {Iterable<Module> | undefined} modules unordered modules | ||
| * @param {Compilation} compilation compilation | ||
@@ -640,4 +642,4 @@ * @returns {Module[]} ordered modules | ||
| const boundCompareModulesByIdOrIdentifier = compareModulesByIdOrIdentifier( | ||
| compilation.chunkGraph | ||
| const boundCompareModulesByFullName = compareModulesByFullName( | ||
| compilation.compiler | ||
| ); | ||
@@ -655,6 +657,3 @@ | ||
| if (b.length === 0) return -1; | ||
| return boundCompareModulesByIdOrIdentifier( | ||
| a[a.length - 1], | ||
| b[b.length - 1] | ||
| ); | ||
| return boundCompareModulesByFullName(a[a.length - 1], b[b.length - 1]); | ||
| }; | ||
@@ -668,2 +667,3 @@ | ||
| for (;;) { | ||
| /** @type {Set<Module>} */ | ||
| const failedModules = new Set(); | ||
@@ -677,2 +677,3 @@ const list = modulesByChunkGroup[0].list; | ||
| let selectedModule = list[list.length - 1]; | ||
| /** @type {undefined | false | Module} */ | ||
| let hasFailed; | ||
@@ -702,7 +703,6 @@ outer: for (;;) { | ||
| new WebpackError( | ||
| `chunk ${chunk.name || chunk.id}\nConflicting order between ${ | ||
| /** @type {Module} */ | ||
| (hasFailed).readableIdentifier(compilation.requestShortener) | ||
| } and ${selectedModule.readableIdentifier( | ||
| `chunk ${chunk.name || chunk.id}\nConflicting order between ${hasFailed.readableIdentifier( | ||
| compilation.requestShortener | ||
| )} and ${selectedModule.readableIdentifier( | ||
| compilation.requestShortener | ||
| )}` | ||
@@ -734,15 +734,12 @@ ) | ||
| * @param {Compilation} compilation compilation | ||
| * @returns {Module[]} ordered css modules | ||
| * @returns {CssModule[]} ordered css modules | ||
| */ | ||
| getOrderedChunkCssModules(chunk, chunkGraph, compilation) { | ||
| return [ | ||
| return /** @type {CssModule[]} */ ([ | ||
| ...this.getModulesInOrder( | ||
| chunk, | ||
| /** @type {Iterable<Module>} */ | ||
| ( | ||
| chunkGraph.getOrderedChunkModulesIterableBySourceType( | ||
| chunk, | ||
| CSS_IMPORT_TYPE, | ||
| compareModulesByIdOrIdentifier(chunkGraph) | ||
| ) | ||
| chunkGraph.getOrderedChunkModulesIterableBySourceType( | ||
| chunk, | ||
| CSS_IMPORT_TYPE, | ||
| compareModulesByFullName(compilation.compiler) | ||
| ), | ||
@@ -753,13 +750,10 @@ compilation | ||
| chunk, | ||
| /** @type {Iterable<Module>} */ | ||
| ( | ||
| chunkGraph.getOrderedChunkModulesIterableBySourceType( | ||
| chunk, | ||
| CSS_TYPE, | ||
| compareModulesByIdOrIdentifier(chunkGraph) | ||
| ) | ||
| chunkGraph.getOrderedChunkModulesIterableBySourceType( | ||
| chunk, | ||
| CSS_TYPE, | ||
| compareModulesByFullName(compilation.compiler) | ||
| ), | ||
| compilation | ||
| ) | ||
| ]; | ||
| ]); | ||
| } | ||
@@ -783,2 +777,3 @@ | ||
| /** @type {CachedSource} */ | ||
| let source; | ||
@@ -808,2 +803,3 @@ if ( | ||
| let moduleSource = new ReplaceSource(moduleSourceContent); | ||
| /** @type {null | RegExpExecArray} */ | ||
| let match; | ||
@@ -810,0 +806,0 @@ while ((match = publicPathAutoRegex.exec(moduleSourceCode))) { |
@@ -564,2 +564,3 @@ /* | ||
| }); | ||
| /** @type {PluginFunction} */ | ||
| let r; | ||
@@ -566,0 +567,0 @@ try { |
@@ -141,3 +141,3 @@ /* | ||
| /** | ||
| * @param {EXPECTED_ANY[] | {[k: string]: EXPECTED_ANY}} obj obj | ||
| * @param {EXPECTED_ANY[] | { [k: string]: EXPECTED_ANY }} obj obj | ||
| * @param {JavascriptParser} parser Parser | ||
@@ -162,2 +162,3 @@ * @param {ValueCacheVersions} valueCacheVersions valueCacheVersions | ||
| ) => { | ||
| /** @type {string} */ | ||
| let code; | ||
@@ -423,2 +424,3 @@ const arr = Array.isArray(obj); | ||
| const handler = (parser) => { | ||
| /** @type {Set<string>} */ | ||
| const hooked = new Set(); | ||
@@ -425,0 +427,0 @@ const mainValue = |
@@ -35,2 +35,4 @@ /* | ||
| /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("./Module").Sources} Sources */ | ||
| /** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("./RequestShortener")} RequestShortener */ | ||
@@ -80,2 +82,3 @@ /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| // Build info | ||
| /** @type {undefined | DelegatedSourceDependency} */ | ||
| this.delegatedSourceDependency = undefined; | ||
@@ -157,2 +160,3 @@ } | ||
| const sourceModule = moduleGraph.getModule(dep); | ||
| /** @type {string} */ | ||
| let str; | ||
@@ -169,2 +173,3 @@ | ||
| request: dep.request, | ||
| /** @type {RuntimeRequirements} */ | ||
| runtimeRequirements: new Set() | ||
@@ -185,2 +190,3 @@ })})`; | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -187,0 +193,0 @@ if (this.useSourceMap || this.useSimpleSourceMap) { |
@@ -12,2 +12,3 @@ /* | ||
| /** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsContent} DllReferencePluginOptionsContent */ | ||
| /** @typedef {import("./DelegatedModule").DelegatedModuleData} DelegatedModuleData */ | ||
| /** @typedef {import("./DelegatedModule").DelegatedModuleSourceRequest} DelegatedModuleSourceRequest */ | ||
@@ -55,2 +56,3 @@ /** @typedef {import("./DelegatedModule").DelegatedModuleType} DelegatedModuleType */ | ||
| const innerRequest = `.${request.slice(scope.length)}`; | ||
| /** @type {undefined | DelegatedModuleData} */ | ||
| let resolved; | ||
@@ -57,0 +59,0 @@ if (innerRequest in this.options.content) { |
@@ -13,2 +13,3 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("./LocalModule")} LocalModule */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
@@ -124,2 +125,3 @@ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| this.namedModule = namedModule; | ||
| /** @type {LocalModule | null} */ | ||
| this.localModule = null; | ||
@@ -187,3 +189,3 @@ } | ||
| * @param {AMDDefineDependency} dependency dependency | ||
| * @returns {string} variable name | ||
| * @returns {string | false | null} variable name | ||
| */ | ||
@@ -190,0 +192,0 @@ localModuleVar(dependency) { |
@@ -29,2 +29,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
@@ -35,2 +36,3 @@ /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("./LocalModule")} LocalModule */ | ||
@@ -128,3 +130,5 @@ /** | ||
| for (const [idx, request] of array.entries()) { | ||
| /** @type {string | LocalModuleDependency | AMDRequireItemDependency} */ | ||
| let dep; | ||
| /** @type {undefined | null | LocalModule} */ | ||
| let localModule; | ||
@@ -180,3 +184,5 @@ if (request === "require") { | ||
| } else if (param.isString()) { | ||
| /** @type {Dependency} */ | ||
| let dep; | ||
| /** @type {undefined | null | LocalModule} */ | ||
| let localModule; | ||
@@ -183,0 +189,0 @@ |
@@ -61,3 +61,3 @@ /* | ||
| apply(compiler) { | ||
| const amdOptions = this.amdOptions; | ||
| const { amdOptions } = this; | ||
| compiler.hooks.compilation.tap( | ||
@@ -64,0 +64,0 @@ PLUGIN_NAME, |
@@ -28,2 +28,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
@@ -33,2 +34,3 @@ /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("./LocalModule")} LocalModule */ | ||
@@ -107,4 +109,6 @@ const PLUGIN_NAME = "AMDRequireDependenciesBlockParserPlugin"; | ||
| const deps = []; | ||
| for (const request of /** @type {EXPECTED_ANY[]} */ (param.array)) { | ||
| for (const request of /** @type {string[]} */ (param.array)) { | ||
| /** @type {string | LocalModuleDependency | AMDRequireItemDependency} */ | ||
| let dep; | ||
| /** @type {undefined | null | LocalModule} */ | ||
| let localModule; | ||
@@ -158,3 +162,5 @@ if (request === "require") { | ||
| } else if (param.isString()) { | ||
| /** @type {Dependency} */ | ||
| let dep; | ||
| /** @type {LocalModule | null | undefined} */ | ||
| let localModule; | ||
@@ -161,0 +167,0 @@ if (param.string === "require") { |
@@ -41,2 +41,3 @@ /* | ||
| this.place = place; | ||
| /** @type {undefined | string} */ | ||
| this._hashUpdate = undefined; | ||
@@ -43,0 +44,0 @@ } |
@@ -25,3 +25,5 @@ /* | ||
| ) => { | ||
| /** @type {string} */ | ||
| let base; | ||
| /** @type {string} */ | ||
| let type; | ||
@@ -28,0 +30,0 @@ switch (depBase) { |
@@ -60,2 +60,3 @@ /* | ||
| this.resultUsed = resultUsed; | ||
| /** @type {undefined | boolean} */ | ||
| this.asiSafe = undefined; | ||
@@ -62,0 +63,0 @@ } |
@@ -44,3 +44,5 @@ /* | ||
| this.idRanges = idRanges; | ||
| /** @type {boolean} */ | ||
| this.call = false; | ||
| /** @type {undefined | boolean} */ | ||
| this.asiSafe = undefined; | ||
@@ -47,0 +49,0 @@ } |
@@ -43,2 +43,3 @@ /* | ||
| /** @typedef {import("../javascript/JavascriptParser").CalleeMembers} CalleeMembers */ | ||
| /** @typedef {import("./LocalModule")} LocalModule */ | ||
@@ -303,2 +304,3 @@ /** | ||
| if (expr.arguments.length !== 1) return; | ||
| /** @type {null | LocalModule} */ | ||
| let localModule; | ||
@@ -591,2 +593,3 @@ const param = parser.evaluateExpression(expr.arguments[0]); | ||
| } else { | ||
| /** @type {undefined | string} */ | ||
| let moduleName; | ||
@@ -593,0 +596,0 @@ const match = /^(.*) from (.*)$/.exec(options.createRequire); |
@@ -21,4 +21,4 @@ /* | ||
| * @param {Range} range location in source code | ||
| * @param {Range | undefined} valueRange location of the require call | ||
| * @param {boolean | string} inShorthand true or name | ||
| * @param {Range=} valueRange location of the require call | ||
| * @param {boolean | string=} inShorthand true or name | ||
| * @param {string=} context context | ||
@@ -25,0 +25,0 @@ */ |
@@ -121,2 +121,3 @@ /* | ||
| /** @type {string} */ | ||
| let base; | ||
@@ -123,0 +124,0 @@ switch (dep.base) { |
@@ -36,2 +36,3 @@ /* | ||
| : null; | ||
| /** @type {undefined | string} */ | ||
| this._hashUpdate = undefined; | ||
@@ -38,0 +39,0 @@ } |
@@ -29,3 +29,3 @@ /* | ||
| * @param {string} prefix prefix | ||
| * @returns {{prefix: string, context: string}} result | ||
| * @returns {{ prefix: string, context: string }} result | ||
| */ | ||
@@ -46,6 +46,12 @@ const splitContextFromPrefix = (prefix) => { | ||
| /** @typedef {Partial<Omit<ContextDependencyOptions, "resource">>} PartialContextDependencyOptions */ | ||
| /** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: Range, ...args: EXPECTED_ANY[]): ContextDependency }} ContextDependencyConstructor */ | ||
| /** @typedef {{ new (options: ContextDependencyOptions, range: Range, valueRange: Range, ...args: EXPECTED_ANY[]): ContextDependency }} ContextDependencyConstructor */ | ||
| /** | ||
| * @param {ContextDependencyConstructor} Dep the Dependency class | ||
| * @template T | ||
| * @typedef {T extends new (options: ContextDependencyOptions, range: Range, valueRange: Range, ...remains: infer R) => EXPECTED_ANY ? R : []} GetAdditionalDepArgs | ||
| */ | ||
| /** | ||
| * @template {ContextDependencyConstructor} T | ||
| * @param {T} Dep the Dependency class | ||
| * @param {Range} range source range | ||
@@ -57,3 +63,3 @@ * @param {BasicEvaluatedExpression} param context param | ||
| * @param {JavascriptParser} parser the parser | ||
| * @param {...EXPECTED_ANY} depArgs depArgs | ||
| * @param {GetAdditionalDepArgs<T>} depArgs depArgs | ||
| * @returns {ContextDependency} the created Dependency | ||
@@ -222,2 +228,3 @@ */ | ||
| dep.loc = /** @type {DependencyLocation} */ (expr.loc); | ||
| /** @type {Replaces} */ | ||
| const replaces = []; | ||
@@ -224,0 +231,0 @@ if (prefixRange) { |
@@ -85,2 +85,3 @@ /* | ||
| if (!this.referencedExports) return Dependency.EXPORTS_OBJECT_REFERENCED; | ||
| /** @type {ReferencedExports} */ | ||
| const refs = []; | ||
@@ -87,0 +88,0 @@ for (const referencedExport of this.referencedExports) { |
@@ -18,2 +18,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "CriticalDependencyWarning"; | ||
@@ -20,0 +21,0 @@ this.message = `Critical dependency: ${message}`; |
@@ -63,3 +63,3 @@ /* | ||
| if (/\[(fullhash|hash)\]/.test(localIdentName)) { | ||
| if (/\[(?:fullhash|hash)\]/.test(localIdentName)) { | ||
| const hashSalt = generator.options.localIdentHashSalt; | ||
@@ -117,4 +117,4 @@ const hashDigest = | ||
| return id | ||
| .replace(/^([.-]|[^a-zA-Z0-9_-])+/, "") | ||
| .replace(/[^a-zA-Z0-9_-]+/g, "_"); | ||
| .replace(/^([.-]|[^a-z0-9_-])+/i, "") | ||
| .replace(/[^a-z0-9_-]+/gi, "_"); | ||
| }, | ||
@@ -140,3 +140,3 @@ filename: relativeResourcePath, | ||
| // Protect the first character from unsupported values | ||
| return localIdent.replace(/^((-?[0-9])|--)/, "_$1"); | ||
| return localIdent.replace(/^((-?\d)|--)/, "_$1"); | ||
| }; | ||
@@ -176,2 +176,3 @@ | ||
| this.exportType = exportType; | ||
| /** @type {undefined | string} */ | ||
| this._hashUpdate = undefined; | ||
@@ -178,0 +179,0 @@ } |
@@ -39,2 +39,3 @@ /* | ||
| this.isReference = isReference; | ||
| /** @type {undefined | string} */ | ||
| this._hashUpdate = undefined; | ||
@@ -41,0 +42,0 @@ } |
@@ -19,2 +19,3 @@ /* | ||
| /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */ | ||
| /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
@@ -177,5 +178,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| const codeGen = codeGenerationResults.get(module, runtime); | ||
| const data = | ||
| /** @type {NonNullable<CodeGenerationResult["data"]>} */ | ||
| (codeGen.data); | ||
| const data = codeGen.data; | ||
| if (!data) return "data:,"; | ||
@@ -182,0 +181,0 @@ const url = data.get("url"); |
@@ -16,3 +16,4 @@ /* | ||
| /** @typedef {{ name: string, value?: string }[]} ArrayImportSpecifiers */ | ||
| /** @typedef {Map<string, Set<string>>} ImportSpecifiers */ | ||
| /** @typedef {Set<string>} ImportSpecifier */ | ||
| /** @typedef {Map<string, ImportSpecifier>} ImportSpecifiers */ | ||
@@ -42,2 +43,3 @@ /** | ||
| if (!specifiers) { | ||
| /** @type {ImportSpecifier} */ | ||
| specifiers = new Set(); | ||
@@ -82,2 +84,3 @@ this.specifiers.set(name, specifiers); | ||
| getContent({ runtimeRequirements }) { | ||
| /** @type {string[]} */ | ||
| const namedImports = []; | ||
@@ -84,0 +87,0 @@ |
@@ -35,11 +35,2 @@ /* | ||
| /** | ||
| * @returns {string} hash update | ||
| */ | ||
| _createHashUpdate() { | ||
| return `${this.importedModule}${JSON.stringify(this.specifiers)}${ | ||
| this.default || "null" | ||
| }`; | ||
| } | ||
| /** | ||
| * @param {ObjectSerializerContext} context context | ||
@@ -46,0 +37,0 @@ */ |
@@ -13,5 +13,7 @@ /* | ||
| /** @typedef {{ fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined }} FunctionExpressionResult */ | ||
| /** | ||
| * @param {Expression | SpreadElement} expr expressions | ||
| * @returns {{ fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information | ||
| * @returns {FunctionExpressionResult | undefined} function expression with additional information | ||
| */ | ||
@@ -18,0 +20,0 @@ module.exports = (expr) => { |
@@ -117,4 +117,7 @@ /* | ||
| const getHarmonyImportDependencies = (dependency) => { | ||
| /** @type {HarmonyImportDependency[]} */ | ||
| const result = []; | ||
| /** @type {HarmonyImportDependency | null} */ | ||
| let deferDependency = null; | ||
| /** @type {HarmonyImportDependency | null} */ | ||
| let noDeferredDependency = null; | ||
@@ -121,0 +124,0 @@ |
@@ -106,2 +106,3 @@ /* | ||
| /** @type {boolean | undefined | null} */ | ||
| let value; | ||
@@ -108,0 +109,0 @@ |
@@ -24,2 +24,3 @@ /* | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("./HarmonyExportInitFragment").ExportMap} ExportMap */ | ||
@@ -124,2 +125,3 @@ class HarmonyExportExpressionDependency extends NullDependency { | ||
| if (declarationId) { | ||
| /** @type {string} */ | ||
| let name; | ||
@@ -144,2 +146,3 @@ if (typeof declarationId === "string") { | ||
| if (used) { | ||
| /** @type {ExportMap} */ | ||
| const map = new Map(); | ||
@@ -170,2 +173,3 @@ map.set(used, `/* export default binding */ ${name}`); | ||
| runtimeRequirements.add(RuntimeGlobals.exports); | ||
| /** @type {ExportMap} */ | ||
| const map = new Map(); | ||
@@ -172,0 +176,0 @@ map.set(used, name); |
@@ -61,2 +61,3 @@ /* | ||
| /** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */ | ||
| /** @typedef {import("./HarmonyExportInitFragment").ExportMap} ExportMap */ | ||
| /** @typedef {import("../dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */ | ||
@@ -268,2 +269,3 @@ | ||
| if (name) { | ||
| /** @type {ExportMode} */ | ||
| let mode; | ||
@@ -469,3 +471,3 @@ const exportInfo = exportsInfo.getReadOnlyExportInfo(name); | ||
| * @param {Module} importedModule the imported module (optional) | ||
| * @returns {{exports?: Exports, checked?: Checked, ignoredExports: IgnoredExports, hidden?: Hidden}} information | ||
| * @returns {{ exports?: Exports, checked?: Checked, ignoredExports: IgnoredExports, hidden?: Hidden }} information | ||
| */ | ||
@@ -486,4 +488,6 @@ getStarReexports( | ||
| /** @type {IgnoredExports} */ | ||
| const ignoredExports = new Set(["default", ...this.activeExports]); | ||
| /** @type {Hidden | undefined} */ | ||
| let hiddenExports; | ||
@@ -1307,2 +1311,3 @@ const otherStarExports = | ||
| /** @type {ExportMap} */ | ||
| const map = new Map(); | ||
@@ -1333,2 +1338,3 @@ map.set(key, `/* ${comment} */ ${returnValue}`); | ||
| /** @type {ExportMap} */ | ||
| const map = new Map(); | ||
@@ -1374,2 +1380,3 @@ map.set( | ||
| /** @type {ExportMap} */ | ||
| const map = new Map(); | ||
@@ -1376,0 +1383,0 @@ const moduleId = JSON.stringify(chunkGraph.getModuleId(module)); |
@@ -15,2 +15,3 @@ /* | ||
| /** @typedef {import("../Generator").GenerateContext} GenerateContext */ | ||
| /** @typedef {import("../ExportsInfo").UsedName} UsedName */ | ||
@@ -37,3 +38,8 @@ /** | ||
| /** @typedef {Map<UsedName, string>} ExportMap */ | ||
| /** @typedef {Set<string>} UnusedExports */ | ||
| /** @type {ExportMap} */ | ||
| const EMPTY_MAP = new Map(); | ||
| /** @type {UnusedExports} */ | ||
| const EMPTY_SET = new Set(); | ||
@@ -47,4 +53,4 @@ | ||
| * @param {string} exportsArgument the exports identifier | ||
| * @param {Map<string, string>} exportMap mapping from used name to exposed variable name | ||
| * @param {Set<string>} unusedExports list of unused export names | ||
| * @param {ExportMap} exportMap mapping from used name to exposed variable name | ||
| * @param {UnusedExports} unusedExports list of unused export names | ||
| */ | ||
@@ -57,4 +63,7 @@ constructor( | ||
| super(undefined, InitFragment.STAGE_HARMONY_EXPORTS, 1, "harmony-exports"); | ||
| /** @type {string} */ | ||
| this.exportsArgument = exportsArgument; | ||
| /** @type {ExportMap} */ | ||
| this.exportMap = exportMap; | ||
| /** @type {UnusedExports} */ | ||
| this.unusedExports = unusedExports; | ||
@@ -68,4 +77,6 @@ } | ||
| mergeAll(fragments) { | ||
| /** @type {undefined | ExportMap} */ | ||
| let exportMap; | ||
| let exportMapOwned = false; | ||
| /** @type {undefined | UnusedExports} */ | ||
| let unusedExports; | ||
@@ -116,2 +127,3 @@ let unusedExportsOwned = false; | ||
| merge(other) { | ||
| /** @type {ExportMap} */ | ||
| let exportMap; | ||
@@ -128,2 +140,3 @@ if (this.exportMap.size === 0) { | ||
| } | ||
| /** @type {UnusedExports} */ | ||
| let unusedExports; | ||
@@ -163,2 +176,3 @@ if (this.unusedExports.size === 0) { | ||
| : ""; | ||
| /** @type {string[]} */ | ||
| const definitions = []; | ||
@@ -171,3 +185,3 @@ const orderedExportMap = [...this.exportMap].sort(([a], [b]) => | ||
| `\n/* harmony export */ ${propertyName( | ||
| key | ||
| /** @type {string} */ (key) | ||
| )}: ${runtimeTemplate.returningFunction(value)}` | ||
@@ -174,0 +188,0 @@ ); |
@@ -20,2 +20,4 @@ /* | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("./HarmonyExportInitFragment").UnusedExports} UnusedExports */ | ||
| /** @typedef {import("./HarmonyExportInitFragment").ExportMap} ExportMap */ | ||
@@ -108,2 +110,3 @@ class HarmonyExportSpecifierDependency extends NullDependency { | ||
| if (!used) { | ||
| /** @type {UnusedExports} */ | ||
| const set = new Set(); | ||
@@ -117,2 +120,3 @@ set.add(dep.name || "namespace"); | ||
| /** @type {ExportMap} */ | ||
| const map = new Map(); | ||
@@ -119,0 +123,0 @@ map.set(used, `/* binding */ ${dep.id}`); |
@@ -15,2 +15,3 @@ /* | ||
| const InnerGraph = require("../optimize/InnerGraph"); | ||
| const AppendOnlyStackedSet = require("../util/AppendOnlyStackedSet"); | ||
| const ConstDependency = require("./ConstDependency"); | ||
@@ -40,5 +41,14 @@ const HarmonyAcceptDependency = require("./HarmonyAcceptDependency"); | ||
| /** @typedef {import("./HarmonyImportDependency").Ids} Ids */ | ||
| /** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */ | ||
| /** @typedef {import("./ImportPhase").ImportPhaseType} ImportPhaseType */ | ||
| /** | ||
| * @typedef {object} HarmonySpecifierGuards | ||
| * @property {AppendOnlyStackedSet<string> | undefined} guards | ||
| */ | ||
| /** @typedef {Map<string, Set<string>>} Guards Map of import root to guarded member keys */ | ||
| const harmonySpecifierTag = Symbol("harmony import"); | ||
| const harmonySpecifierGuardTag = Symbol("harmony import guard"); | ||
@@ -58,2 +68,14 @@ /** | ||
| /** @type {(members: Members) => string} */ | ||
| const getMembersKey = (members) => members.join("."); | ||
| /** | ||
| * Strip the root binding name if needed | ||
| * @param {HarmonySettings} settings settings | ||
| * @param {Ids} ids ids | ||
| * @returns {Ids} ids for presence check | ||
| */ | ||
| const getIdsForPresence = (settings, ids) => | ||
| settings.ids.length ? ids.slice(1) : ids; | ||
| module.exports = class HarmonyImportDependencyParserPlugin { | ||
@@ -78,7 +100,24 @@ /** | ||
| * @param {JavascriptParser} parser the parser | ||
| * @param {Ids} ids ids | ||
| * @returns {ExportPresenceMode} exportPresenceMode | ||
| */ | ||
| getExportPresenceMode(parser, ids) { | ||
| const harmonySettings = /** @type {HarmonySettings=} */ ( | ||
| parser.currentTagData | ||
| ); | ||
| if (!harmonySettings) return this.exportPresenceMode; | ||
| const data = /** @type {HarmonySpecifierGuards=} */ ( | ||
| parser.getTagData(harmonySettings.name, harmonySpecifierGuardTag) | ||
| ); | ||
| return data && data.guards && data.guards.has(getMembersKey(ids)) | ||
| ? false | ||
| : this.exportPresenceMode; | ||
| } | ||
| /** | ||
| * @param {JavascriptParser} parser the parser | ||
| * @returns {void} | ||
| */ | ||
| apply(parser) { | ||
| const { exportPresenceMode } = this; | ||
| const getImportPhase = createGetImportPhase(this.options.deferImport); | ||
@@ -235,2 +274,3 @@ | ||
| const settings = /** @type {HarmonySettings} */ (parser.currentTagData); | ||
| const dep = new HarmonyImportSpecifierDependency( | ||
@@ -243,3 +283,6 @@ settings.source, | ||
| (expr.range), | ||
| exportPresenceMode, | ||
| this.getExportPresenceMode( | ||
| parser, | ||
| getIdsForPresence(settings, settings.ids) | ||
| ), | ||
| settings.phase, | ||
@@ -294,3 +337,6 @@ settings.attributes, | ||
| (expr.range), | ||
| exportPresenceMode, | ||
| this.getExportPresenceMode( | ||
| parser, | ||
| getIdsForPresence(settings, ids) | ||
| ), | ||
| settings.phase, | ||
@@ -345,3 +391,6 @@ settings.attributes, | ||
| /** @type {Range} */ (expr.range), | ||
| exportPresenceMode, | ||
| this.getExportPresenceMode( | ||
| parser, | ||
| getIdsForPresence(settings, ids) | ||
| ), | ||
| settings.phase, | ||
@@ -413,5 +462,217 @@ settings.attributes, | ||
| }); | ||
| /** | ||
| * @param {Expression} expression expression | ||
| * @returns {{ root: string, members: Members } | undefined} info | ||
| */ | ||
| const getHarmonyImportInfo = (expression) => { | ||
| const nameInfo = parser.getNameForExpression(expression); | ||
| if (!nameInfo) return; | ||
| const rootInfo = nameInfo.rootInfo; | ||
| const root = | ||
| typeof rootInfo === "string" | ||
| ? rootInfo | ||
| : rootInfo instanceof VariableInfo | ||
| ? rootInfo.name | ||
| : undefined; | ||
| if (!root) return; | ||
| if (!parser.getTagData(root, harmonySpecifierTag)) return; | ||
| return { root, members: nameInfo.getMembers() }; | ||
| }; | ||
| /** | ||
| * @param {Guards} guards guards | ||
| * @param {string} root root name | ||
| * @param {Members} members members | ||
| */ | ||
| const addToGuards = (guards, root, members) => { | ||
| const membersKey = getMembersKey(members); | ||
| const guardedMembers = guards.get(root); | ||
| if (guardedMembers) { | ||
| guardedMembers.add(membersKey); | ||
| return; | ||
| } | ||
| guards.set( | ||
| root, | ||
| // Adding `foo.bar` implies guarding `foo` as well | ||
| membersKey === "" ? new Set([""]) : new Set([membersKey, ""]) | ||
| ); | ||
| }; | ||
| /** | ||
| * @param {Expression} expression expression | ||
| * @param {Guards} guards guards | ||
| * @param {boolean} needTruthy need to be truthy | ||
| */ | ||
| const collect = (expression, guards, needTruthy) => { | ||
| // !foo | ||
| if ( | ||
| expression.type === "UnaryExpression" && | ||
| expression.operator === "!" | ||
| ) { | ||
| collect(expression.argument, guards, !needTruthy); | ||
| return; | ||
| } else if (expression.type === "LogicalExpression" && needTruthy) { | ||
| // foo && bar | ||
| if (expression.operator === "&&") { | ||
| collect(expression.left, guards, true); | ||
| collect(expression.right, guards, true); | ||
| } | ||
| // falsy || foo | ||
| else if (expression.operator === "||") { | ||
| const leftEvaluation = parser.evaluateExpression(expression.left); | ||
| const leftBool = leftEvaluation.asBool(); | ||
| if (leftBool === false) { | ||
| collect(expression.right, guards, true); | ||
| } | ||
| } | ||
| // nullish ?? foo | ||
| else if (expression.operator === "??") { | ||
| const leftEvaluation = parser.evaluateExpression(expression.left); | ||
| const leftNullish = leftEvaluation.asNullish(); | ||
| if (leftNullish === true) { | ||
| collect(expression.right, guards, true); | ||
| } | ||
| } | ||
| return; | ||
| } | ||
| if (!needTruthy) return; | ||
| /** | ||
| * @param {Expression} targetExpression expression | ||
| * @returns {boolean} is added | ||
| */ | ||
| const addGuardForExpression = (targetExpression) => { | ||
| const info = getHarmonyImportInfo(targetExpression); | ||
| if (!info) return false; | ||
| addToGuards(guards, info.root, info.members); | ||
| return true; | ||
| }; | ||
| /** | ||
| * @param {Expression} left left expression | ||
| * @param {Expression} right right expression | ||
| * @param {(evaluation: ReturnType<JavascriptParser["evaluateExpression"]>) => boolean} matcher matcher | ||
| * @returns {boolean} is added | ||
| */ | ||
| const addGuardForNullishCompare = (left, right, matcher) => { | ||
| const leftEval = parser.evaluateExpression(left); | ||
| if (leftEval && matcher(leftEval)) { | ||
| return addGuardForExpression(right); | ||
| } | ||
| const rightEval = parser.evaluateExpression(right); | ||
| if (rightEval && matcher(rightEval)) { | ||
| return addGuardForExpression(/** @type {Expression} */ (left)); | ||
| } | ||
| return false; | ||
| }; | ||
| if (expression.type === "BinaryExpression") { | ||
| // "bar" in foo | ||
| if (expression.operator === "in") { | ||
| const leftEvaluation = parser.evaluateExpression(expression.left); | ||
| if (leftEvaluation.couldHaveSideEffects()) return; | ||
| const propertyName = leftEvaluation.asString(); | ||
| if (!propertyName) return; | ||
| parser.evaluateExpression(expression.right); | ||
| const info = getHarmonyImportInfo(expression.right); | ||
| if (!info) return; | ||
| if (info.members.length) { | ||
| for (const member of info.members) { | ||
| addToGuards(guards, info.root, [member]); | ||
| } | ||
| } | ||
| addToGuards(guards, info.root, [...info.members, propertyName]); | ||
| return; | ||
| } | ||
| // foo !== undefined | ||
| else if ( | ||
| expression.operator === "!==" && | ||
| addGuardForNullishCompare( | ||
| /** @type {Expression} */ (expression.left), | ||
| expression.right, | ||
| (evaluation) => evaluation.isUndefined() | ||
| ) | ||
| ) { | ||
| return; | ||
| } | ||
| // foo != undefined | ||
| // foo != null | ||
| else if ( | ||
| expression.operator === "!=" && | ||
| addGuardForNullishCompare( | ||
| /** @type {Expression} */ (expression.left), | ||
| expression.right, | ||
| (evaluation) => Boolean(evaluation.asNullish()) | ||
| ) | ||
| ) { | ||
| return; | ||
| } | ||
| } | ||
| addGuardForExpression(expression); | ||
| }; | ||
| /** | ||
| * @param {Guards} guards guards | ||
| * @param {() => void} walk walk callback | ||
| * @returns {void} | ||
| */ | ||
| const withGuards = (guards, walk) => { | ||
| const applyGuards = () => { | ||
| /** @type {(() => void)[]} */ | ||
| const restoreFns = []; | ||
| for (const [rootName, members] of guards) { | ||
| const previous = parser.getVariableInfo(rootName); | ||
| const exist = /** @type {HarmonySpecifierGuards=} */ ( | ||
| parser.getTagData(rootName, harmonySpecifierGuardTag) | ||
| ); | ||
| const mergedGuards = | ||
| exist && exist.guards | ||
| ? exist.guards.createChild() | ||
| : new AppendOnlyStackedSet(); | ||
| for (const memberKey of members) mergedGuards.add(memberKey); | ||
| parser.tagVariable(rootName, harmonySpecifierGuardTag, { | ||
| guards: mergedGuards | ||
| }); | ||
| restoreFns.push(() => { | ||
| parser.setVariable(rootName, previous); | ||
| }); | ||
| } | ||
| return () => { | ||
| for (const restore of restoreFns) { | ||
| restore(); | ||
| } | ||
| }; | ||
| }; | ||
| const restore = applyGuards(); | ||
| try { | ||
| walk(); | ||
| } finally { | ||
| restore(); | ||
| } | ||
| }; | ||
| parser.hooks.collectGuards.tap(PLUGIN_NAME, (expression) => { | ||
| if (parser.scope.isAsmJs) return; | ||
| /** @type {Guards} */ | ||
| const guards = new Map(); | ||
| collect(expression, guards, true); | ||
| if (guards.size === 0) return; | ||
| return (walk) => { | ||
| withGuards(guards, walk); | ||
| }; | ||
| }); | ||
| } | ||
| }; | ||
| module.exports.harmonySpecifierGuardTag = harmonySpecifierGuardTag; | ||
| module.exports.harmonySpecifierTag = harmonySpecifierTag; |
@@ -9,2 +9,3 @@ /* | ||
| const Dependency = require("../Dependency"); | ||
| const InitFragment = require("../InitFragment"); | ||
| const Template = require("../Template"); | ||
@@ -76,6 +77,11 @@ const { | ||
| this.exportPresenceMode = exportPresenceMode; | ||
| /** @type {undefined | boolean} */ | ||
| this.namespaceObjectAsContext = false; | ||
| /** @type {undefined | boolean} */ | ||
| this.call = undefined; | ||
| /** @type {undefined | boolean} */ | ||
| this.directImport = undefined; | ||
| /** @type {undefined | boolean | string} */ | ||
| this.shorthand = undefined; | ||
| /** @type {undefined | boolean} */ | ||
| this.asiSafe = undefined; | ||
@@ -341,7 +347,19 @@ /** @type {UsedByExports | undefined} */ | ||
| const dep = /** @type {HarmonyImportSpecifierDependency} */ (dependency); | ||
| const { moduleGraph, runtime } = templateContext; | ||
| const { moduleGraph, runtime, initFragments } = templateContext; | ||
| const connection = moduleGraph.getConnection(dep); | ||
| // Skip rendering depending when dependency is conditional | ||
| if (connection && !connection.isTargetActive(runtime)) return; | ||
| // Only render declaration for import specifier when the dependency is conditional | ||
| if (connection && !connection.isTargetActive(runtime)) { | ||
| initFragments.push( | ||
| new InitFragment( | ||
| `/* unused harmony import specifier */ var ${dep.name};\n`, | ||
| InitFragment.STAGE_HARMONY_IMPORTS, | ||
| 0, | ||
| `unused import specifier ${dep.name}` | ||
| ) | ||
| ); | ||
| return; | ||
| } | ||
| const ids = dep.getIds(moduleGraph); | ||
@@ -437,2 +455,3 @@ const { | ||
| const connection = moduleGraph.getConnection(dep); | ||
| /** @type {string} */ | ||
| let exportExpr; | ||
@@ -439,0 +458,0 @@ if ( |
@@ -70,2 +70,3 @@ /* | ||
| if (!this.referencedExports) return Dependency.EXPORTS_OBJECT_REFERENCED; | ||
| /** @type {ReferencedExports} */ | ||
| const refs = []; | ||
@@ -72,0 +73,0 @@ for (const referencedExport of this.referencedExports) { |
@@ -87,2 +87,3 @@ /* | ||
| const request = /** @type {string} */ (requestExpr.string); | ||
| /** @type {WebpackError[]} */ | ||
| const errors = []; | ||
@@ -89,0 +90,0 @@ let regExp = /^\.\/.*$/; |
@@ -31,2 +31,3 @@ /* | ||
| /** @typedef {import("estree").MemberExpression} MemberExpression */ | ||
| /** @typedef {import("estree").Identifier} Identifier */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ | ||
@@ -48,14 +49,20 @@ /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @type {WeakMap<Compilation, { stringify: string, env: Record<string, string> }>} */ | ||
| const compilationMetaEnvMap = new WeakMap(); | ||
| /** | ||
| * Collect import.meta.env definitions from DefinePlugin and build JSON string | ||
| * @param {Compilation} compilation the compilation | ||
| * @returns {string} env object as JSON string | ||
| * @returns {{ stringify: string, env: Record<string, string> }} env object as JSON string | ||
| */ | ||
| const collectImportMetaEnvDefinitions = (compilation) => { | ||
| const cached = compilationMetaEnvMap.get(compilation); | ||
| if (cached) { | ||
| return cached; | ||
| } | ||
| const definePluginHooks = DefinePlugin.getCompilationHooks(compilation); | ||
| const definitions = definePluginHooks.definitions.call({}); | ||
| if (!definitions) { | ||
| return "{}"; | ||
| } | ||
| /** @type {Record<string, string>} */ | ||
| const env = {}; | ||
| /** @type {string[]} */ | ||
@@ -68,6 +75,8 @@ const pairs = []; | ||
| pairs.push(`${JSON.stringify(envKey)}:${value}`); | ||
| env[envKey] = /** @type {string} */ (value); | ||
| } | ||
| } | ||
| return `{${pairs.join(",")}}`; | ||
| const result = { stringify: `{${pairs.join(",")}}`, env }; | ||
| compilationMetaEnvMap.set(compilation, result); | ||
| return result; | ||
| }; | ||
@@ -154,6 +163,11 @@ | ||
| */ | ||
| const importMetaUnknownProperty = (members) => | ||
| `${Template.toNormalComment( | ||
| const importMetaUnknownProperty = (members) => { | ||
| if (importMeta === "preserve-unknown") { | ||
| return `import.meta${propertyAccess(members, 0)}`; | ||
| } | ||
| return `${Template.toNormalComment( | ||
| `unsupported import.meta.${members.join(".")}` | ||
| )} undefined${propertyAccess(members, 1)}`; | ||
| }; | ||
| parser.hooks.typeof | ||
@@ -230,2 +244,5 @@ .for("import.meta") | ||
| break; | ||
| case "env": | ||
| str += `env: ${collectImportMetaEnvDefinitions(compilation).stringify},`; | ||
| break; | ||
| default: | ||
@@ -335,8 +352,27 @@ str += `[${JSON.stringify( | ||
| ); | ||
| parser.hooks.expressionMemberChain | ||
| .for("import.meta") | ||
| .tap(PLUGIN_NAME, (expr, members) => { | ||
| if (members[0] === "env" && members[1]) { | ||
| const name = members[1]; | ||
| const { env } = collectImportMetaEnvDefinitions(compilation); | ||
| if (!Object.prototype.hasOwnProperty.call(env, name)) { | ||
| const dep = new ConstDependency( | ||
| "undefined", | ||
| /** @type {Range} */ (expr.range) | ||
| ); | ||
| dep.loc = /** @type {DependencyLocation} */ (expr.loc); | ||
| parser.state.module.addPresentationalDependency(dep); | ||
| return true; | ||
| } | ||
| } | ||
| }); | ||
| parser.hooks.expression | ||
| .for("import.meta.env") | ||
| .tap(PLUGIN_NAME, (expr) => { | ||
| const envCode = collectImportMetaEnvDefinitions(compilation); | ||
| const { stringify } = | ||
| collectImportMetaEnvDefinitions(compilation); | ||
| const dep = new ConstDependency( | ||
| envCode, | ||
| stringify, | ||
| /** @type {Range} */ (expr.range) | ||
@@ -364,2 +400,7 @@ ); | ||
| .tap(PLUGIN_NAME, (expr, members) => { | ||
| // unknown import.meta properties should be determined at runtime | ||
| if (importMeta === "preserve-unknown") { | ||
| return true; | ||
| } | ||
| // keep import.meta.env unknown property | ||
@@ -383,2 +424,3 @@ // don't evaluate import.meta.env.UNKNOWN_PROPERTY -> undefined.UNKNOWN_PROPERTY | ||
| }); | ||
| parser.hooks.evaluate | ||
@@ -385,0 +427,0 @@ .for("MemberExpression") |
@@ -20,3 +20,3 @@ /* | ||
| const ImportEagerDependency = require("./ImportEagerDependency"); | ||
| const { ImportPhaseUtils, createGetImportPhase } = require("./ImportPhase"); | ||
| const { createGetImportPhase } = require("./ImportPhase"); | ||
| const ImportWeakDependency = require("./ImportWeakDependency"); | ||
@@ -266,7 +266,10 @@ | ||
| /** @type {null | string} */ | ||
| let chunkName = null; | ||
| let mode = /** @type {ContextMode} */ (this.options.dynamicImportMode); | ||
| /** @type {null | RegExp} */ | ||
| let include = null; | ||
| /** @type {null | RegExp} */ | ||
| let exclude = null; | ||
| /** @type {RawReferencedExports | null} */ | ||
| /** @type {null | RawReferencedExports} */ | ||
| let exports = null; | ||
@@ -562,11 +565,2 @@ /** @type {RawChunkGroupOptions} */ | ||
| if (ImportPhaseUtils.isDefer(phase)) { | ||
| parser.state.module.addWarning( | ||
| new UnsupportedFeatureWarning( | ||
| "import.defer() is not yet supported for ContextModule (the import path is a dynamic expression).", | ||
| /** @type {DependencyLocation} */ (expr.loc) | ||
| ) | ||
| ); | ||
| } | ||
| const dep = ContextDependencyHelpers.create( | ||
@@ -592,3 +586,4 @@ ImportContextDependency, | ||
| referencedExports: exports, | ||
| attributes: getImportAttributes(expr) | ||
| attributes: getImportAttributes(expr), | ||
| phase | ||
| }, | ||
@@ -595,0 +590,0 @@ parser |
@@ -13,2 +13,3 @@ /* | ||
| /** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */ | ||
| /** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */ | ||
@@ -120,3 +121,5 @@ /** @typedef {import("../Compilation").ExecuteModuleExports} ExecuteModuleExports */ | ||
| } | ||
| /** @type {null | RawSourceMap} */ | ||
| let map; | ||
| /** @type {string | Buffer | undefined} */ | ||
| let source; | ||
@@ -123,0 +126,0 @@ if (moduleSource.sourceAndMap) { |
@@ -33,2 +33,3 @@ /* | ||
| this.allowExportsAccess = allowExportsAccess; | ||
| /** @type {undefined | string} */ | ||
| this._hashUpdate = undefined; | ||
@@ -35,0 +36,0 @@ } |
@@ -30,2 +30,3 @@ /* | ||
| this.range = undefined; | ||
| /** @type {undefined | string} */ | ||
| this._context = undefined; | ||
@@ -32,0 +33,0 @@ } |
@@ -47,2 +47,3 @@ /* | ||
| this.range = range; | ||
| /** @type {undefined | string} */ | ||
| this._hashUpdate = undefined; | ||
@@ -49,0 +50,0 @@ } |
@@ -89,2 +89,3 @@ /* | ||
| /** @type {{ context: string, request: string }[]} */ | ||
| let newItems; | ||
@@ -91,0 +92,0 @@ if (!finalResolveOptions.fullySpecified) { |
@@ -13,2 +13,4 @@ /* | ||
| /** @typedef {import("estree").Expression} Expression */ | ||
| /** @typedef {import("estree").SpreadElement} SpreadElement */ | ||
| /** @typedef {import("../AsyncDependenciesBlock").GroupOptions} GroupOptions */ | ||
@@ -19,2 +21,3 @@ /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("./getFunctionExpression").FunctionExpressionResult} FunctionExpressionResult */ | ||
@@ -32,4 +35,6 @@ const PLUGIN_NAME = "RequireEnsureDependenciesBlockParserPlugin"; | ||
| let chunkName = null; | ||
| let errorExpressionArg = null; | ||
| let errorExpression = null; | ||
| /** @type {undefined | Expression | SpreadElement} */ | ||
| let errorExpressionArg; | ||
| /** @type {undefined | FunctionExpressionResult} */ | ||
| let errorExpression; | ||
| switch (expr.arguments.length) { | ||
@@ -36,0 +41,0 @@ case 4: { |
@@ -27,2 +27,3 @@ /* | ||
| this.runtimeRequirements = new Set(runtimeRequirements); | ||
| /** @type {undefined | string} */ | ||
| this._hashUpdate = undefined; | ||
@@ -29,0 +30,0 @@ } |
@@ -26,2 +26,8 @@ /* | ||
| /** | ||
| * @typedef {object} WorkerDependencyOptions | ||
| * @property {string=} publicPath public path for the worker | ||
| * @property {boolean=} needNewUrl true when need generate `new URL(...)`, otherwise false | ||
| */ | ||
| class WorkerDependency extends ModuleDependency { | ||
@@ -31,5 +37,3 @@ /** | ||
| * @param {Range} range range | ||
| * @param {object} workerDependencyOptions options | ||
| * @param {string=} workerDependencyOptions.publicPath public path for the worker | ||
| * @param {boolean=} workerDependencyOptions.needNewUrl need generate `new URL(...)` | ||
| * @param {WorkerDependencyOptions} workerDependencyOptions options | ||
| */ | ||
@@ -40,4 +44,6 @@ constructor(request, range, workerDependencyOptions) { | ||
| // If options are updated, don't forget to update the hash and serialization functions | ||
| /** @type {WorkerDependencyOptions} */ | ||
| this.options = workerDependencyOptions; | ||
| /** Cache the hash */ | ||
| /** @type {undefined | string} */ | ||
| this._hashUpdate = undefined; | ||
@@ -44,0 +50,0 @@ } |
@@ -390,2 +390,3 @@ /* | ||
| name: entryOptions.name, | ||
| circular: false, | ||
| entryOptions: { | ||
@@ -392,0 +393,0 @@ chunkLoading: this._chunkLoading, |
@@ -51,5 +51,7 @@ /* | ||
| /** @typedef {string} ExportInfoName */ | ||
| /** | ||
| * @typedef {object} ExportSpec | ||
| * @property {string} name the name of the export | ||
| * @property {ExportInfoName} name the name of the export | ||
| * @property {boolean=} canMangle can the export be renamed (defaults to true) | ||
@@ -117,4 +119,7 @@ * @property {boolean=} terminalBinding is the export a terminal binding that should be checked for export star conflicts | ||
| this._locEC = 0; | ||
| /** @type {undefined | number} */ | ||
| this._locI = undefined; | ||
| /** @type {undefined | string} */ | ||
| this._locN = undefined; | ||
| /** @type {undefined | DependencyLocation} */ | ||
| this._loc = undefined; | ||
@@ -121,0 +126,0 @@ } |
@@ -13,7 +13,7 @@ /* | ||
| /** @typedef {import("./DependencyTemplate")} DependencyTemplate */ | ||
| /** @typedef {typeof import("./util/Hash")} Hash */ | ||
| /** @typedef {import("./util/Hash").HashFunction} HashFunction */ | ||
| class DependencyTemplates { | ||
| /** | ||
| * @param {string | Hash} hashFunction the hash function to use | ||
| * @param {HashFunction} hashFunction the hash function to use | ||
| */ | ||
@@ -25,2 +25,3 @@ constructor(hashFunction = DEFAULTS.HASH_FUNCTION) { | ||
| this._hash = "31d6cfe0d16ae931b73c59d7e0c089c0"; | ||
| /** @type {HashFunction} */ | ||
| this._hashFunction = hashFunction; | ||
@@ -27,0 +28,0 @@ } |
+2
-0
@@ -28,2 +28,3 @@ /* | ||
| /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("./Module").Sources} Sources */ | ||
| /** @typedef {import("./RequestShortener")} RequestShortener */ | ||
@@ -97,2 +98,3 @@ /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| codeGeneration(context) { | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -99,0 +101,0 @@ sources.set( |
@@ -112,2 +112,3 @@ /* | ||
| const manifestParameter = this.options.manifest; | ||
| /** @type {undefined | DllReferencePluginOptionsManifest} */ | ||
| let manifest; | ||
@@ -114,0 +115,0 @@ if (typeof manifestParameter === "string") { |
+11
-5
@@ -28,5 +28,5 @@ /* | ||
| // Regex for parsing .env files | ||
| // ported from https://github.com/motdotla/dotenv/blob/master/lib/main.js#L32 | ||
| // ported from https://github.com/motdotla/dotenv/blob/master/lib/main.js#L49 | ||
| const LINE = | ||
| /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm; | ||
| /^\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?$/gm; | ||
@@ -64,5 +64,7 @@ const PLUGIN_NAME = "DotenvPlugin"; | ||
| // Convert line breaks to same format | ||
| lines = lines.replace(/\r\n?/gm, "\n"); | ||
| lines = lines.replace(/\r\n?/g, "\n"); | ||
| /** @type {null | RegExpExecArray} */ | ||
| let match; | ||
| while ((match = LINE.exec(lines)) !== null) { | ||
@@ -117,6 +119,8 @@ const key = match[1]; | ||
| const regex = /(?<!\\)\$\{([^{}]+)\}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g; | ||
| const regex = /(?<!\\)\$\{([^{}]+)\}|(?<!\\)\$([a-z_]\w*)/gi; | ||
| let result = value; | ||
| /** @type {null | RegExpExecArray} */ | ||
| let match; | ||
| /** @type {Set<string>} */ | ||
| const seen = new Set(); // self-referential checker | ||
@@ -139,3 +143,5 @@ | ||
| /** @type {string} */ | ||
| let defaultValue; | ||
| /** @type {undefined | null | string} */ | ||
| let value; | ||
@@ -310,3 +316,3 @@ | ||
| * @param {string} mode mode | ||
| * @returns {Promise<{parsed: Env, fileDependencies: string[], missingDependencies: string[]}>} parsed env variables and dependencies | ||
| * @returns {Promise<{ parsed: Env, fileDependencies: string[], missingDependencies: string[] }>} parsed env variables and dependencies | ||
| */ | ||
@@ -313,0 +319,0 @@ async _getParsed(fs, dir, mode) { |
@@ -47,2 +47,3 @@ /* | ||
| .then((entry) => { | ||
| /** @type {Promise<void>[]} */ | ||
| const promises = []; | ||
@@ -49,0 +50,0 @@ for (const name of Object.keys(entry)) { |
@@ -27,2 +27,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "EnvironmentNotSupportAsyncWarning"; | ||
@@ -29,0 +30,0 @@ this.module = module; |
@@ -14,3 +14,3 @@ /* | ||
| /** | ||
| * Creates an instance of ModuleDependencyError. | ||
| * Creates an instance of BuildCycleError. | ||
| * @param {Module} module the module starting the cycle | ||
@@ -23,3 +23,5 @@ */ | ||
| /** @type {string} */ | ||
| this.name = "BuildCycleError"; | ||
| /** @type {Module} */ | ||
| this.module = module; | ||
@@ -29,2 +31,3 @@ } | ||
| /** @type {typeof BuildCycleError} */ | ||
| module.exports = BuildCycleError; |
@@ -215,2 +215,3 @@ /* | ||
| /** @type {Set<Chunk>} */ | ||
| const loadedChunks = new Set(); | ||
@@ -229,9 +230,10 @@ for (let i = 0; i < entries.length; i++) { | ||
| ); | ||
| /** @type {Set<Chunk>} */ | ||
| const processChunks = new Set(); | ||
| for (const _chunk of chunks) { | ||
| if (loadedChunks.has(_chunk)) { | ||
| for (const chunk of chunks) { | ||
| if (loadedChunks.has(chunk)) { | ||
| continue; | ||
| } | ||
| loadedChunks.add(_chunk); | ||
| processChunks.add(_chunk); | ||
| loadedChunks.add(chunk); | ||
| processChunks.add(chunk); | ||
| } | ||
@@ -238,0 +240,0 @@ const sourceWithDependentChunks = withDependentChunks( |
@@ -39,2 +39,3 @@ /* | ||
| }; | ||
| /** @type {WeakSet<Chunk>} */ | ||
| const onceForChunkSet = new WeakSet(); | ||
@@ -41,0 +42,0 @@ /** |
@@ -63,2 +63,3 @@ /* | ||
| super("import chunk loading", RuntimeModule.STAGE_ATTACH); | ||
| /** @type {ReadOnlyRuntimeRequirements} */ | ||
| this._runtimeRequirements = runtimeRequirements; | ||
@@ -65,0 +66,0 @@ } |
@@ -122,2 +122,3 @@ /* | ||
| let sourceMap; | ||
| /** @type {string | Buffer} */ | ||
| let content; | ||
@@ -168,16 +169,19 @@ if (source.sourceAndMap) { | ||
| sourceMap.sources = moduleFilenames; | ||
| sourceMap.ignoreList = options.ignoreList | ||
| ? sourceMap.sources.reduce( | ||
| /** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ ( | ||
| (acc, sourceName, idx) => { | ||
| const rule = /** @type {Rules} */ (options.ignoreList); | ||
| if (ModuleFilenameHelpers.matchPart(sourceName, rule)) { | ||
| acc.push(idx); | ||
| } | ||
| return acc; | ||
| if (options.ignoreList) { | ||
| const ignoreList = sourceMap.sources.reduce( | ||
| /** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ ( | ||
| (acc, sourceName, idx) => { | ||
| const rule = /** @type {Rules} */ (options.ignoreList); | ||
| if (ModuleFilenameHelpers.matchPart(sourceName, rule)) { | ||
| acc.push(idx); | ||
| } | ||
| ), | ||
| [] | ||
| ) | ||
| : []; | ||
| return acc; | ||
| } | ||
| ), | ||
| [] | ||
| ); | ||
| if (ignoreList.length > 0) { | ||
| sourceMap.ignoreList = ignoreList; | ||
| } | ||
| } | ||
@@ -184,0 +188,0 @@ if (options.noSources) { |
@@ -16,2 +16,3 @@ /* | ||
| /** @typedef {import("./Dependency").RuntimeSpec} RuntimeSpec */ | ||
| /** @typedef {import("./Dependency").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("./Dependency").ExportsSpecExcludeExports} ExportsSpecExcludeExports */ | ||
@@ -29,4 +30,2 @@ /** @typedef {import("./dependencies/HarmonyImportDependency")} HarmonyImportDependency */ | ||
| /** @typedef {string} ExportInfoName */ | ||
| /** @typedef {Map<string, RuntimeUsageStateType>} UsedInRuntime */ | ||
@@ -116,4 +115,7 @@ /** @typedef {{ module: Module, export: ExportInfoName[], deferred: boolean }} TargetItemWithoutConnection */ | ||
| this._exports = new Map(); | ||
| /** @type {ExportInfo} */ | ||
| this._otherExportsInfo = new ExportInfo(null); | ||
| /** @type {ExportInfo} */ | ||
| this._sideEffectsOnlyInfo = new ExportInfo("*side effects only*"); | ||
| /** @type {boolean} */ | ||
| this._exportsAreOrdered = false; | ||
@@ -619,2 +621,3 @@ /** @type {ExportsInfo=} */ | ||
| getRelevantExports(runtime) { | ||
| /** @type {ExportInfo[]} */ | ||
| const list = []; | ||
@@ -662,2 +665,3 @@ for (const exportInfo of this._exports.values()) { | ||
| getUsageKey(runtime) { | ||
| /** @type {(string | number)[]} */ | ||
| const key = []; | ||
@@ -924,3 +928,3 @@ if (this._redirectTo !== undefined) { | ||
| if (initFrom && initFrom._target) { | ||
| this._target = new Map(); | ||
| this._target = /** @type {Target} */ (new Map()); | ||
| for (const [key, value] of initFrom._target) { | ||
@@ -1164,3 +1168,3 @@ this._target.set(key, { | ||
| if (!this._target) { | ||
| this._target = new Map(); | ||
| this._target = /** @type {Target} */ (new Map()); | ||
| this._target.set(key, { | ||
@@ -1167,0 +1171,0 @@ connection, |
@@ -48,2 +48,3 @@ /* | ||
| /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */ | ||
| /** @typedef {import("./Module").CodeGenerationResultData} CodeGenerationResultData */ | ||
| /** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */ | ||
@@ -54,3 +55,5 @@ /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */ | ||
| /** @typedef {import("./Module").Sources} Sources */ | ||
| /** @typedef {import("./ModuleGraph")} ModuleGraph */ | ||
@@ -87,7 +90,11 @@ /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */ | ||
| /** @type {RuntimeRequirements} */ | ||
| const RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]); | ||
| /** @type {RuntimeRequirements} */ | ||
| const RUNTIME_REQUIREMENTS_FOR_SCRIPT = new Set([RuntimeGlobals.loadScript]); | ||
| /** @type {RuntimeRequirements} */ | ||
| const RUNTIME_REQUIREMENTS_FOR_MODULE = new Set([ | ||
| RuntimeGlobals.definePropertyGetters | ||
| ]); | ||
| /** @type {RuntimeRequirements} */ | ||
| const EMPTY_RUNTIME_REQUIREMENTS = new Set(); | ||
@@ -406,2 +413,3 @@ | ||
| if (exportsInfo.otherExportsInfo.getUsed(runtime) === UsageState.Unused) { | ||
| /** @type {string[]} */ | ||
| const properties = []; | ||
@@ -495,2 +503,3 @@ for (const exportInfo of exportsInfo.orderedExports) { | ||
| const useNamespace = imported === true; | ||
| /** @type {undefined | string} */ | ||
| let moduleRemapping; | ||
@@ -986,2 +995,3 @@ if (useNamespace) { | ||
| case "asset": { | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -992,2 +1002,3 @@ sources.set( | ||
| ); | ||
| /** @type {CodeGenerationResultData} */ | ||
| const data = new Map(); | ||
@@ -998,3 +1009,5 @@ data.set("url", { javascript: request }); | ||
| case "css-url": { | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
| /** @type {CodeGenerationResultData} */ | ||
| const data = new Map(); | ||
@@ -1005,2 +1018,3 @@ data.set("url", { "css-url": request }); | ||
| case "css-import": { | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -1068,2 +1082,3 @@ const dependencyMeta = /** @type {CssImportDependencyMeta} */ ( | ||
| /** @type {undefined | CodeGenerationResultData} */ | ||
| let data; | ||
@@ -1075,2 +1090,3 @@ if (sourceData.chunkInitFragments) { | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -1077,0 +1093,0 @@ if (this.useSourceMap || this.useSimpleSourceMap) { |
@@ -13,2 +13,3 @@ /* | ||
| super(); | ||
| /** @type {string} */ | ||
| this.name = "FalseIIFEUmdWarning"; | ||
@@ -15,0 +16,0 @@ this.message = |
@@ -17,2 +17,3 @@ /* | ||
| /** @typedef {import("./ExportsInfo")} ExportsInfo */ | ||
| /** @typedef {import("./ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("./ExportsInfo").RestoreProvidedData} RestoreProvidedData */ | ||
@@ -54,3 +55,5 @@ /** @typedef {import("./Module")} Module */ | ||
| asyncLib.each( | ||
| modules, | ||
| /** @type {import("neo-async").IterableCollection<Module>} */ ( | ||
| /** @type {unknown} */ (modules) | ||
| ), | ||
| (module, callback) => { | ||
@@ -193,7 +196,10 @@ const exportsInfo = moduleGraph.getExportsInfo(module); | ||
| for (const exportNameOrSpec of exports) { | ||
| /** @type {ExportInfoName} */ | ||
| let name; | ||
| let canMangle = globalCanMangle; | ||
| let terminalBinding = globalTerminalBinding; | ||
| /** @type {ExportSpec["exports"]} */ | ||
| let exports; | ||
| let from = globalFrom; | ||
| /** @type {ExportSpec["export"]} */ | ||
| let fromExport; | ||
@@ -276,2 +282,3 @@ let priority = globalPriority; | ||
| const target = exportInfo.getTarget(moduleGraph); | ||
| /** @type {undefined | ExportsInfo} */ | ||
| let targetExportsInfo; | ||
@@ -278,0 +285,0 @@ if (target) { |
@@ -34,2 +34,3 @@ /* | ||
| constructor(global) { | ||
| /** @type {boolean} */ | ||
| this.global = global; | ||
@@ -84,2 +85,3 @@ } | ||
| for (const usedExportInfo of usedExports) { | ||
| /** @type {string[]} */ | ||
| let usedExport; | ||
@@ -172,3 +174,4 @@ let canMangle = true; | ||
| const processModule = (module, runtime, forceSideEffects) => { | ||
| /** @type {Map<Module, ReferencedExports | Map<string, string[] | ReferencedExport>>} */ | ||
| /** @typedef {Map<string, string[] | ReferencedExport>} ExportMaps */ | ||
| /** @type {Map<Module, ReferencedExports | ExportMaps>} */ | ||
| const map = new Map(); | ||
@@ -183,10 +186,8 @@ | ||
| for (const b of block.blocks) { | ||
| if ( | ||
| !this.global && | ||
| b.groupOptions && | ||
| b.groupOptions.entryOptions | ||
| ) { | ||
| if (b.groupOptions && b.groupOptions.entryOptions) { | ||
| processModule( | ||
| b, | ||
| b.groupOptions.entryOptions.runtime || undefined, | ||
| this.global | ||
| ? undefined | ||
| : b.groupOptions.entryOptions.runtime || undefined, | ||
| true | ||
@@ -228,2 +229,3 @@ ); | ||
| } else { | ||
| /** @type {undefined | ExportMaps} */ | ||
| let exportsMap; | ||
@@ -230,0 +232,0 @@ if (Array.isArray(oldReferencedExports)) { |
@@ -13,2 +13,3 @@ /* | ||
| super(message); | ||
| /** @type {string} */ | ||
| this.name = "HarmonyLinkingError"; | ||
@@ -15,0 +16,0 @@ this.hideStack = true; |
@@ -22,3 +22,3 @@ /* | ||
| /** | ||
| * @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>}} options additional options for the backend | ||
| * @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]> }} options additional options for the backend | ||
| * @returns {BackendHandler} backend | ||
@@ -28,2 +28,3 @@ */ | ||
| const logger = compiler.getInfrastructureLogger("LazyCompilationBackend"); | ||
| /** @type {Map<string, number>} */ | ||
| const activeModules = new Map(); | ||
@@ -157,3 +158,3 @@ const prefix = "/lazy-compilation-using-"; | ||
| ).replace(/%(2F|3A|24|26|2B|2C|3B|3D)/g, decodeURIComponent)}`; | ||
| const active = activeModules.get(key) > 0; | ||
| const active = /** @type {number} */ (activeModules.get(key)) > 0; | ||
| return { | ||
@@ -160,0 +161,0 @@ client: `${options.client}?${encodeURIComponent(urlBase + prefix)}`, |
@@ -36,2 +36,4 @@ /* | ||
| /** @typedef {import("../Module").SourceTypes} SourceTypes */ | ||
| /** @typedef {import("../Module").Sources} Sources */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */ | ||
@@ -229,3 +231,5 @@ /** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */ | ||
| codeGeneration({ runtimeTemplate, chunkGraph, moduleGraph }) { | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
| /** @type {RuntimeRequirements} */ | ||
| const runtimeRequirements = new Set(); | ||
@@ -252,2 +256,3 @@ runtimeRequirements.add(RuntimeGlobals.module); | ||
| ]); | ||
| /** @type {string} */ | ||
| let source; | ||
@@ -254,0 +259,0 @@ if (block) { |
@@ -33,2 +33,3 @@ /* | ||
| this.error = error; | ||
| /** @type {string} */ | ||
| this.name = "HookWebpackError"; | ||
@@ -108,2 +109,3 @@ this.hideStack = true; | ||
| const tryRunOrWebpackError = (fn, hook) => { | ||
| /** @type {T} */ | ||
| let r; | ||
@@ -110,0 +112,0 @@ try { |
@@ -78,3 +78,6 @@ /* | ||
| /** @typedef {{ updatedChunkIds: Set<ChunkId>, removedChunkIds: Set<ChunkId>, removedModules: Set<Module>, filename: string, assetInfo: AssetInfo }} HotUpdateMainContentByRuntimeItem */ | ||
| /** @typedef {Set<ChunkId>} ChunkIds */ | ||
| /** @typedef {Set<Module>} ModuleSet */ | ||
| /** @typedef {{ updatedChunkIds: ChunkIds, removedChunkIds: ChunkIds, removedModules: ModuleSet, filename: string, assetInfo: AssetInfo }} HotUpdateMainContentByRuntimeItem */ | ||
| /** @typedef {Map<string, HotUpdateMainContentByRuntimeItem>} HotUpdateMainContentByRuntime */ | ||
@@ -521,2 +524,3 @@ | ||
| const hotUpdateMainContentByRuntime = new Map(); | ||
| /** @type {RuntimeSpec} */ | ||
| let allOldRuntime; | ||
@@ -542,4 +546,7 @@ const chunkRuntime = | ||
| { | ||
| /** @type {ChunkIds} */ | ||
| updatedChunkIds: new Set(), | ||
| /** @type {ChunkIds} */ | ||
| removedChunkIds: new Set(), | ||
| /** @type {ModuleSet} */ | ||
| removedModules: new Set(), | ||
@@ -586,7 +593,13 @@ filename, | ||
| let chunkId; | ||
| /** @type {undefined | Module[]} */ | ||
| let newModules; | ||
| /** @type {undefined | RuntimeModule[]} */ | ||
| let newRuntimeModules; | ||
| /** @type {undefined | RuntimeModule[]} */ | ||
| let newFullHashModules; | ||
| /** @type {undefined | RuntimeModule[]} */ | ||
| let newDependentHashModules; | ||
| /** @type {RuntimeSpec} */ | ||
| let newRuntime; | ||
| /** @type {RuntimeSpec} */ | ||
| let removedFromRuntime; | ||
@@ -782,2 +795,3 @@ const currentChunk = find( | ||
| const completelyRemovedModulesArray = [...completelyRemovedModules]; | ||
| /** @type {Map<string, Omit<HotUpdateMainContentByRuntimeItem, "filename">>} */ | ||
| const hotUpdateMainContentByFilename = new Map(); | ||
@@ -826,3 +840,3 @@ for (const { | ||
| ] of hotUpdateMainContentByFilename) { | ||
| /** @type {{c: ChunkId[], r: ChunkId[], m: ModuleId[], css?: {r: ChunkId[]}}} */ | ||
| /** @type {{ c: ChunkId[], r: ChunkId[], m: ModuleId[], css?: { r: ChunkId[] } }} */ | ||
| const hotUpdateMainJson = { | ||
@@ -829,0 +843,0 @@ c: [...updatedChunkIds], |
@@ -16,2 +16,3 @@ /* | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../ChunkGraph").ModuleComparator} ModuleComparator */ | ||
@@ -60,2 +61,3 @@ /** | ||
| if (options.order) { | ||
| /** @type {ModuleComparator} */ | ||
| let cmpFn; | ||
@@ -62,0 +64,0 @@ switch (options.order) { |
+10
-8
@@ -16,3 +16,3 @@ /* | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {typeof import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/Hash").HashFunction} HashFunction */ | ||
| /** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */ | ||
@@ -24,3 +24,3 @@ /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
| * @param {number} len max length of the hash | ||
| * @param {string | Hash} hashFunction hash function to use | ||
| * @param {HashFunction} hashFunction hash function to use | ||
| * @returns {string} hash | ||
@@ -61,3 +61,3 @@ */ | ||
| const requestToId = (request) => | ||
| request.replace(/^(\.\.?\/)+/, "").replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_"); | ||
| request.replace(/^(\.\.?\/)+/, "").replace(/(^[.-]|[^a-z0-9_-])+/gi, "_"); | ||
@@ -67,3 +67,3 @@ /** | ||
| * @param {string} delimiter separator for string and hash | ||
| * @param {string | Hash} hashFunction hash function to use | ||
| * @param {HashFunction} hashFunction hash function to use | ||
| * @returns {string} string with limited max length to 100 chars | ||
@@ -102,3 +102,3 @@ */ | ||
| * @param {string} context context directory | ||
| * @param {string | Hash} hashFunction hash function to use | ||
| * @param {HashFunction} hashFunction hash function to use | ||
| * @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached | ||
@@ -132,3 +132,3 @@ * @returns {string} long module name | ||
| * @param {string} delimiter delimiter for names | ||
| * @param {string | Hash} hashFunction hash function to use | ||
| * @param {HashFunction} hashFunction hash function to use | ||
| * @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached | ||
@@ -161,3 +161,3 @@ * @returns {string} short chunk name | ||
| * @param {string} delimiter delimiter for names | ||
| * @param {string | Hash} hashFunction hash function to use | ||
| * @param {HashFunction} hashFunction hash function to use | ||
| * @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached | ||
@@ -241,3 +241,3 @@ * @returns {string} short chunk name | ||
| const chunkGraph = compilation.chunkGraph; | ||
| /** @type {Module[]} */ | ||
| const modules = []; | ||
@@ -413,2 +413,3 @@ | ||
| const ident = getName(item); | ||
| /** @type {number} */ | ||
| let id; | ||
@@ -432,2 +433,3 @@ let i = salt; | ||
| let nextId = 0; | ||
| /** @type {(mod: Module) => void} */ | ||
| let assignId; | ||
@@ -434,0 +436,0 @@ if (usedIds.size > 0) { |
@@ -57,6 +57,10 @@ /* | ||
| /** @type {Map<Module, number>} */ | ||
| const occursInInitialChunksMap = new Map(); | ||
| /** @type {Map<Module, number>} */ | ||
| const occursInAllChunksMap = new Map(); | ||
| /** @type {Map<Module, number>} */ | ||
| const initialChunkChunkMap = new Map(); | ||
| /** @type {Map<Module, number>} */ | ||
| const entryCountMap = new Map(); | ||
@@ -119,4 +123,4 @@ for (const m of modulesInOccurrenceOrder) { | ||
| countOccursInEntry(m) + | ||
| initialChunkChunkMap.get(m) + | ||
| entryCountMap.get(m); | ||
| /** @type {number} */ (initialChunkChunkMap.get(m)) + | ||
| /** @type {number} */ (entryCountMap.get(m)); | ||
| occursInInitialChunksMap.set(m, result); | ||
@@ -130,3 +134,3 @@ } | ||
| chunkGraph.getNumberOfModuleChunks(m) + | ||
| entryCountMap.get(m); | ||
| /** @type {number} */ (entryCountMap.get(m)); | ||
| occursInAllChunksMap.set(m, result); | ||
@@ -141,9 +145,13 @@ } | ||
| if (prioritiseInitial) { | ||
| const aEntryOccurs = occursInInitialChunksMap.get(a); | ||
| const bEntryOccurs = occursInInitialChunksMap.get(b); | ||
| const aEntryOccurs = | ||
| /** @type {number} */ | ||
| (occursInInitialChunksMap.get(a)); | ||
| const bEntryOccurs = | ||
| /** @type {number} */ | ||
| (occursInInitialChunksMap.get(b)); | ||
| if (aEntryOccurs > bEntryOccurs) return -1; | ||
| if (aEntryOccurs < bEntryOccurs) return 1; | ||
| } | ||
| const aOccurs = occursInAllChunksMap.get(a); | ||
| const bOccurs = occursInAllChunksMap.get(b); | ||
| const aOccurs = /** @type {number} */ (occursInAllChunksMap.get(a)); | ||
| const bOccurs = /** @type {number} */ (occursInAllChunksMap.get(b)); | ||
| if (aOccurs > bOccurs) return -1; | ||
@@ -150,0 +158,0 @@ if (aOccurs < bOccurs) return 1; |
@@ -16,2 +16,4 @@ /* | ||
| /** @typedef {{ [key: string]: ModuleId }} JSONContent */ | ||
| const plugin = "SyncModuleIdsPlugin"; | ||
@@ -62,3 +64,5 @@ | ||
| } | ||
| /** @type {JSONContent} */ | ||
| const json = JSON.parse(/** @type {Buffer} */ (buffer).toString()); | ||
| /** @type {Map<string, string | number | null>} */ | ||
| data = new Map(); | ||
@@ -76,3 +80,3 @@ for (const key of Object.keys(json)) { | ||
| if (!data || !dataChanged) return callback(); | ||
| /** @type {{[key: string]: ModuleId}} */ | ||
| /** @type {JSONContent} */ | ||
| const json = {}; | ||
@@ -79,0 +83,0 @@ const sorted = [...data].sort(([a], [b]) => (a < b ? -1 : 1)); |
@@ -136,2 +136,3 @@ /* | ||
| const concatSource = new ConcatSource(); | ||
| /** @type {(string | Source)[]} */ | ||
| const endContents = []; | ||
@@ -138,0 +139,0 @@ for (let fragment of keyedFragments.values()) { |
@@ -32,2 +32,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "InvalidDependenciesModuleWarning"; | ||
@@ -34,0 +35,0 @@ this.details = depsList.slice(3).join("\n"); |
@@ -299,2 +299,3 @@ /* | ||
| if (this.isArray()) { | ||
| /** @type {string[]} */ | ||
| const array = []; | ||
@@ -301,0 +302,0 @@ for (const item of /** @type {BasicEvaluatedExpression[]} */ ( |
@@ -11,3 +11,5 @@ /* | ||
| /** @type {WeakMap<Compiler, Set<ChunkLoadingType>>} */ | ||
| /** @typedef {Set<ChunkLoadingType>} ChunkLoadingTypes */ | ||
| /** @type {WeakMap<Compiler, ChunkLoadingTypes>} */ | ||
| const enabledTypes = new WeakMap(); | ||
@@ -17,3 +19,3 @@ | ||
| * @param {Compiler} compiler compiler | ||
| * @returns {Set<ChunkLoadingType>} enabled types | ||
| * @returns {ChunkLoadingTypes} enabled types | ||
| */ | ||
@@ -23,2 +25,3 @@ const getEnabledTypes = (compiler) => { | ||
| if (set === undefined) { | ||
| /** @type {ChunkLoadingTypes} */ | ||
| set = new Set(); | ||
@@ -25,0 +28,0 @@ enabledTypes.set(compiler, set); |
@@ -35,3 +35,3 @@ /* | ||
| const StringXor = require("../util/StringXor"); | ||
| const { compareModulesByIdOrIdentifier } = require("../util/comparators"); | ||
| const { compareModulesByFullName } = require("../util/comparators"); | ||
| const { | ||
@@ -63,2 +63,3 @@ RESERVED_NAMES, | ||
| /** @typedef {import("../Compilation").ExecuteModuleObject} ExecuteModuleObject */ | ||
| /** @typedef {import("../Compilation").WebpackRequire} WebpackRequire */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
@@ -69,2 +70,3 @@ /** @typedef {import("../DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("../Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
@@ -76,2 +78,4 @@ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/concatenate").ScopeSet} ScopeSet */ | ||
| /** @typedef {import("../util/concatenate").UsedNamesInScopeInfo} UsedNamesInScopeInfo */ | ||
@@ -285,3 +289,3 @@ /** | ||
| this.options = options; | ||
| /** @type {WeakMap<Source, { source: Source, needModule:boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined, renderShorthand: boolean }>} */ | ||
| /** @type {WeakMap<Source, { source: Source, needModule: boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined, renderShorthand: boolean }>} */ | ||
| this._moduleFactoryCache = new WeakMap(); | ||
@@ -362,2 +366,3 @@ } | ||
| /** @type {() => Source} */ | ||
| let render; | ||
@@ -544,2 +549,3 @@ | ||
| /** @type {(this: ExecuteModuleObject["exports"], exports: ExecuteModuleObject["exports"], moduleObject: ExecuteModuleObject, webpackRequire: WebpackRequire) => void} */ | ||
| const fn = vm.runInThisContext( | ||
@@ -562,3 +568,4 @@ `(function(${module.moduleArgument}, ${module.exportsArgument}, ${RuntimeGlobals.require}) {\n${code}\n/**/})`, | ||
| moduleObject.exports, | ||
| context.__webpack_require__ | ||
| /** @type {WebpackRequire} */ | ||
| (context.__webpack_require__) | ||
| ); | ||
@@ -580,2 +587,3 @@ } catch (err) { | ||
| /** @type {(this: null, webpackRequire: WebpackRequire) => void} */ | ||
| const fn = vm.runInThisContext( | ||
@@ -590,3 +598,7 @@ `(function(${RuntimeGlobals.require}) {\n${code}\n/**/})`, | ||
| // eslint-disable-next-line no-useless-call | ||
| fn.call(null, context.__webpack_require__); | ||
| fn.call( | ||
| null, | ||
| /** @type {WebpackRequire} */ | ||
| (context.__webpack_require__) | ||
| ); | ||
| } catch (err) { | ||
@@ -651,2 +663,3 @@ /** @type {Error} */ | ||
| ); | ||
| /** @type {Source} */ | ||
| let moduleSourcePostContainer; | ||
@@ -674,2 +687,3 @@ if (factory) { | ||
| renderInObject === true && runtimeTemplate.supportsMethodShorthand(); | ||
| /** @type {Source} */ | ||
| let source; | ||
@@ -688,2 +702,3 @@ if ( | ||
| const factorySource = new ConcatSource(); | ||
| /** @type {string[]} */ | ||
| const args = []; | ||
@@ -763,9 +778,10 @@ if (needExports || needRequire || needModule) { | ||
| renderChunk(renderContext, hooks) { | ||
| const { chunk, chunkGraph } = renderContext; | ||
| const { chunk, chunkGraph, runtimeTemplate } = renderContext; | ||
| const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType( | ||
| chunk, | ||
| JAVASCRIPT_TYPE, | ||
| compareModulesByIdOrIdentifier(chunkGraph) | ||
| compareModulesByFullName(runtimeTemplate.compilation.compiler) | ||
| ); | ||
| const allModules = modules ? [...modules] : []; | ||
| /** @type {undefined | string} */ | ||
| let strictHeader; | ||
@@ -855,3 +871,3 @@ let allStrict = renderContext.strictMode; | ||
| JAVASCRIPT_TYPE, | ||
| compareModulesByIdOrIdentifier(chunkGraph) | ||
| compareModulesByFullName(runtimeTemplate.compilation.compiler) | ||
| ) || []) | ||
@@ -868,2 +884,3 @@ ]; | ||
| const source = new ConcatSource(); | ||
| /** @type {string} */ | ||
| let prefix; | ||
@@ -1045,2 +1062,3 @@ if (iife) { | ||
| if (renderedModule) { | ||
| /** @type {string} */ | ||
| let footer; | ||
@@ -1229,3 +1247,3 @@ if (iife !== undefined) { | ||
| /** | ||
| * @type {{startup: string[], beforeStartup: string[], header: string[], afterStartup: string[], allowInlineStartup: boolean}} | ||
| * @type {{ startup: string[], beforeStartup: string[], header: string[], afterStartup: string[], allowInlineStartup: boolean }} | ||
| */ | ||
@@ -1355,2 +1373,3 @@ const result = { | ||
| /** @type {undefined | CodeGenerationResultData} */ | ||
| let data; | ||
@@ -1788,3 +1807,5 @@ if (codeGenerationResults.has(entryModule, chunk.runtime)) { | ||
| for (const variable of info.variables) { | ||
| /** @type {UsedNamesInScopeInfo} */ | ||
| const usedNamesInScopeInfo = new Map(); | ||
| /** @type {ScopeSet} */ | ||
| const ignoredScopes = new Set(); | ||
@@ -1791,0 +1812,0 @@ |
@@ -20,4 +20,10 @@ /* | ||
| /** | ||
| * @template T | ||
| * @typedef {import("../util/memoize").FunctionReturning<T>} FunctionReturning | ||
| */ | ||
| /** @typedef {(input: string) => Buffer | JsonValue} ParseFn */ | ||
| /** @type {FunctionReturning<ParseFn>} */ | ||
| const getParseJson = memoize(() => require("json-parse-even-better-errors")); | ||
@@ -24,0 +30,0 @@ |
@@ -58,2 +58,3 @@ /* | ||
| // store used paths to detect issue and output an error. #18200 | ||
| /** @type {Set<string>} */ | ||
| const usedPaths = new Set(); | ||
@@ -60,0 +61,0 @@ asyncLib.each( |
@@ -51,4 +51,7 @@ /* | ||
| constructor({ pluginName, type }) { | ||
| /** @type {AbstractLibraryPluginOptions["pluginName"]} */ | ||
| this._pluginName = pluginName; | ||
| /** @type {AbstractLibraryPluginOptions["type"]} */ | ||
| this._type = type; | ||
| /** @type {WeakMap<LibraryOptions, T>} */ | ||
| this._parseCache = new WeakMap(); | ||
@@ -240,3 +243,3 @@ } | ||
| * @param {LibraryOptions} library normalized library option | ||
| * @returns {T | false} preprocess as needed by overriding | ||
| * @returns {T} preprocess as needed by overriding | ||
| */ | ||
@@ -243,0 +246,0 @@ parseOptions(library) { |
@@ -50,2 +50,3 @@ /* | ||
| }); | ||
| /** @type {AmdLibraryPluginOptions["requireAsWrapper"]} */ | ||
| this.requireAsWrapper = options.requireAsWrapper; | ||
@@ -56,3 +57,3 @@ } | ||
| * @param {LibraryOptions} library normalized library option | ||
| * @returns {T | false} preprocess as needed by overriding | ||
| * @returns {T} preprocess as needed by overriding | ||
| */ | ||
@@ -59,0 +60,0 @@ parseOptions(library) { |
@@ -36,3 +36,3 @@ /* | ||
| const KEYWORD_REGEX = | ||
| /^(await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|super|switch|static|this|throw|try|true|typeof|var|void|while|with|yield)$/; | ||
| /^(?:await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|super|switch|static|this|throw|try|true|typeof|var|void|while|with|yield)$/; | ||
| const IDENTIFIER_REGEX = | ||
@@ -132,5 +132,9 @@ /^[\p{L}\p{Nl}$_][\p{L}\p{Nl}$\p{Mn}\p{Mc}\p{Nd}\p{Pc}]*$/iu; | ||
| }); | ||
| /** @type {AssignLibraryPluginOptions["prefix"]} */ | ||
| this.prefix = options.prefix; | ||
| /** @type {AssignLibraryPluginOptions["declare"]} */ | ||
| this.declare = options.declare; | ||
| /** @type {AssignLibraryPluginOptions["unnamed"]} */ | ||
| this.unnamed = options.unnamed; | ||
| /** @type {AssignLibraryPluginOptions["named"]} */ | ||
| this.named = options.named || "assign"; | ||
@@ -141,3 +145,3 @@ } | ||
| * @param {LibraryOptions} library normalized library option | ||
| * @returns {T | false} preprocess as needed by overriding | ||
| * @returns {T} preprocess as needed by overriding | ||
| */ | ||
@@ -144,0 +148,0 @@ parseOptions(library) { |
@@ -28,2 +28,3 @@ /* | ||
| if (set === undefined) { | ||
| /** @type {LibraryTypes} */ | ||
| set = new Set(); | ||
@@ -30,0 +31,0 @@ enabledTypes.set(compiler, set); |
@@ -54,3 +54,3 @@ /* | ||
| * @param {LibraryOptions} library normalized library option | ||
| * @returns {T | false} preprocess as needed by overriding | ||
| * @returns {T} preprocess as needed by overriding | ||
| */ | ||
@@ -57,0 +57,0 @@ parseOptions(library) { |
@@ -51,3 +51,3 @@ /* | ||
| * @param {LibraryOptions} library normalized library option | ||
| * @returns {T | false} preprocess as needed by overriding | ||
| * @returns {T} preprocess as needed by overriding | ||
| */ | ||
@@ -54,0 +54,0 @@ parseOptions(library) { |
@@ -10,7 +10,9 @@ /* | ||
| const { UsageState } = require("../ExportsInfo"); | ||
| const ExternalModule = require("../ExternalModule"); | ||
| const RuntimeGlobals = require("../RuntimeGlobals"); | ||
| const Template = require("../Template"); | ||
| const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency"); | ||
| const ConcatenatedModule = require("../optimize/ConcatenatedModule"); | ||
| const propertyAccess = require("../util/propertyAccess"); | ||
| const { getEntryRuntime } = require("../util/runtime"); | ||
| const { getEntryRuntime, getRuntimeKey } = require("../util/runtime"); | ||
| const AbstractLibraryPlugin = require("./AbstractLibraryPlugin"); | ||
@@ -24,2 +26,3 @@ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../Module")} Module */ | ||
@@ -30,2 +33,4 @@ /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").ModuleRenderContext} ModuleRenderContext */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
@@ -82,2 +87,3 @@ /** | ||
| /** @type {BuildMeta["exportsSourceByRuntime"]} */ | ||
| const exportsSourceByRuntime = | ||
@@ -87,2 +93,3 @@ buildMeta.exportsSourceByRuntime || | ||
| /** @type {BuildMeta["exportsFinalNameByRuntime"]} */ | ||
| const exportsFinalNameByRuntime = | ||
@@ -93,4 +100,5 @@ buildMeta.exportsFinalNameByRuntime || | ||
| for (const runtime of runtimes) { | ||
| exportsSourceByRuntime.set(runtime, source); | ||
| exportsFinalNameByRuntime.set(runtime, finalName); | ||
| const key = getRuntimeKey(runtime); | ||
| exportsSourceByRuntime.set(key, source); | ||
| exportsFinalNameByRuntime.set(key, finalName); | ||
| } | ||
@@ -125,4 +133,9 @@ | ||
| const exportsInfo = moduleGraph.getExportsInfo(module); | ||
| // If the entry module is commonjs, its exports cannot be mangled | ||
| if (module.buildMeta && module.buildMeta.treatAsCommonJs) { | ||
| if ( | ||
| // If the entry module is commonjs, its exports cannot be mangled | ||
| (module.buildMeta && module.buildMeta.treatAsCommonJs) || | ||
| // The entry module provides unknown exports | ||
| exportsInfo._otherExportsInfo.provided === null | ||
| ) { | ||
| exportsInfo.setUsedInUnknownWay(runtime); | ||
@@ -138,3 +151,3 @@ } else { | ||
| * @param {LibraryOptions} library normalized library option | ||
| * @returns {T | false} preprocess as needed by overriding | ||
| * @returns {T} preprocess as needed by overriding | ||
| */ | ||
@@ -158,2 +171,90 @@ parseOptions(library) { | ||
| * @param {Module} module module | ||
| * @param {ModuleGraph} moduleGraph moduleGraph | ||
| * @param {RuntimeSpec} runtime chunk runtime | ||
| * @param {[string, string][]} exports exports | ||
| * @param {Set<string>} alreadyRenderedExports already rendered exports | ||
| * @returns {ConcatSource} source with null provided exports | ||
| */ | ||
| _analyzeUnknownProvidedExports( | ||
| source, | ||
| module, | ||
| moduleGraph, | ||
| runtime, | ||
| exports, | ||
| alreadyRenderedExports | ||
| ) { | ||
| const result = new ConcatSource(source); | ||
| /** @type {Set<string>} */ | ||
| const moduleRequests = new Set(); | ||
| /** @type {Map<string, string>} */ | ||
| const unknownProvidedExports = new Map(); | ||
| /** | ||
| * @param {Module} module the module | ||
| * @param {boolean} isDynamicReexport if module is dynamic reexported | ||
| */ | ||
| const resolveDynamicStarReexport = (module, isDynamicReexport) => { | ||
| for (const connection of moduleGraph.getOutgoingConnections(module)) { | ||
| const dep = connection.dependency; | ||
| // Only handle star-reexport statement | ||
| if ( | ||
| dep instanceof HarmonyExportImportedSpecifierDependency && | ||
| dep.name === null | ||
| ) { | ||
| const importedModule = connection.resolvedModule; | ||
| const importedModuleExportsInfo = | ||
| moduleGraph.getExportsInfo(importedModule); | ||
| // The imported module provides unknown exports | ||
| // So keep the reexports rendered in the bundle | ||
| if ( | ||
| dep.getMode(moduleGraph, runtime).type === "dynamic-reexport" && | ||
| importedModuleExportsInfo._otherExportsInfo.provided === null | ||
| ) { | ||
| // Handle export * from 'external' | ||
| if (importedModule instanceof ExternalModule) { | ||
| moduleRequests.add(importedModule.userRequest); | ||
| } else { | ||
| resolveDynamicStarReexport(importedModule, true); | ||
| } | ||
| } | ||
| // If importer modules existing `dynamic-reexport` dependency | ||
| // We should keep export statement rendered in the bundle | ||
| else if (isDynamicReexport) { | ||
| for (const exportInfo of importedModuleExportsInfo.orderedExports) { | ||
| if (!exportInfo.provided || exportInfo.name === "default") { | ||
| continue; | ||
| } | ||
| const originalName = exportInfo.name; | ||
| const usedName = exportInfo.getUsedName(originalName, runtime); | ||
| if (!alreadyRenderedExports.has(originalName) && usedName) { | ||
| unknownProvidedExports.set(originalName, usedName); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| resolveDynamicStarReexport(module, false); | ||
| for (const request of moduleRequests) { | ||
| result.add(`export * from "${request}";\n`); | ||
| } | ||
| for (const [origin, used] of unknownProvidedExports) { | ||
| exports.push([ | ||
| origin, | ||
| `${RuntimeGlobals.exports}${propertyAccess([used])}` | ||
| ]); | ||
| } | ||
| return result; | ||
| } | ||
| /** | ||
| * @param {Source} source source | ||
| * @param {Module} module module | ||
| * @param {StartupRenderContext} renderContext render context | ||
@@ -176,5 +277,4 @@ * @param {LibraryContext<T>} libraryContext context | ||
| ) { | ||
| const result = new ConcatSource(source); | ||
| const exportsInfo = options.export | ||
| let result = new ConcatSource(source); | ||
| const exportInfos = options.export | ||
| ? [ | ||
@@ -191,3 +291,5 @@ moduleGraph.getExportInfo( | ||
| module.buildMeta.exportsFinalNameByRuntime && | ||
| module.buildMeta.exportsFinalNameByRuntime.get(chunk.runtime)) || | ||
| module.buildMeta.exportsFinalNameByRuntime.get( | ||
| getRuntimeKey(chunk.runtime) | ||
| )) || | ||
| {}; | ||
@@ -202,2 +304,5 @@ | ||
| const exports = []; | ||
| /** @type {Set<string>} */ | ||
| const alreadyRenderedExports = new Set(); | ||
| const isAsync = moduleGraph.isAsync(module); | ||
@@ -215,3 +320,3 @@ | ||
| outer: for (const exportInfo of exportsInfo) { | ||
| outer: for (const exportInfo of exportInfos) { | ||
| if (!exportInfo.provided) continue; | ||
@@ -289,2 +394,4 @@ | ||
| } | ||
| alreadyRenderedExports.add(originalName); | ||
| } | ||
@@ -300,2 +407,11 @@ | ||
| result = this._analyzeUnknownProvidedExports( | ||
| result, | ||
| module, | ||
| moduleGraph, | ||
| chunk.runtime, | ||
| exports, | ||
| alreadyRenderedExports | ||
| ); | ||
| for (const [exportName, final] of exports) { | ||
@@ -326,5 +442,6 @@ result.add( | ||
| module.buildMeta.exportsSourceByRuntime && | ||
| module.buildMeta.exportsSourceByRuntime.get(chunk.runtime); | ||
| module.buildMeta.exportsSourceByRuntime.get(getRuntimeKey(chunk.runtime)); | ||
| // Re-add the module's exports source when rendered in factory or as an inlined startup module wrapped in an IIFE | ||
| // Re-add the module's exports source when rendered in factory | ||
| // or as an inlined startup module wrapped in an IIFE | ||
| if ((inlinedInIIFE || factory) && exportsSource) { | ||
@@ -331,0 +448,0 @@ return new ConcatSource(exportsSource, source); |
@@ -20,2 +20,3 @@ /* | ||
| /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */ | ||
@@ -55,3 +56,3 @@ /** @typedef {import("../util/Hash")} Hash */ | ||
| * @param {LibraryOptions} library normalized library option | ||
| * @returns {T | false} preprocess as needed by overriding | ||
| * @returns {T} preprocess as needed by overriding | ||
| */ | ||
@@ -133,3 +134,5 @@ parseOptions(library) { | ||
| UsageState.Unused; | ||
| /** @type {string[]} */ | ||
| const instructions = []; | ||
| /** @type {ExportInfoName[]} */ | ||
| const handledNames = []; | ||
@@ -136,0 +139,0 @@ for (const exportInfo of exportsInfo.orderedExports) { |
@@ -86,2 +86,3 @@ /* | ||
| /** @type {UmdLibraryPluginOptions["optionalAmdExternalAsGlobal"]} */ | ||
| this.optionalAmdExternalAsGlobal = options.optionalAmdExternalAsGlobal; | ||
@@ -92,3 +93,3 @@ } | ||
| * @param {LibraryOptions} library normalized library option | ||
| * @returns {T | false} preprocess as needed by overriding | ||
| * @returns {T} preprocess as needed by overriding | ||
| */ | ||
@@ -212,3 +213,2 @@ parseOptions(library) { | ||
| .map((m) => { | ||
| let expr; | ||
| let request = m.request; | ||
@@ -225,3 +225,3 @@ if (typeof request === "object") { | ||
| } | ||
| expr = Array.isArray(request) | ||
| let expr = Array.isArray(request) | ||
| ? `require(${JSON.stringify( | ||
@@ -265,2 +265,3 @@ request[0] | ||
| /** @type {string} */ | ||
| let amdFactory; | ||
@@ -267,0 +268,0 @@ if (optionalExternals.length > 0) { |
@@ -102,2 +102,5 @@ /* | ||
| const logger = (name, type, args) => { | ||
| /** | ||
| * @returns {[string?, ...EXPECTED_ANY]} labeled args | ||
| */ | ||
| const labeledArgs = () => { | ||
@@ -104,0 +107,0 @@ if (Array.isArray(args)) { |
@@ -19,3 +19,3 @@ /* | ||
| /** | ||
| * @param {EXPECTED_ANY[]} args items to be truncated | ||
| * @param {string[]} args items to be truncated | ||
| * @param {number} maxLength maximum length of args including spaces between | ||
@@ -22,0 +22,0 @@ * @returns {string[]} truncated args |
@@ -45,3 +45,5 @@ /* | ||
| if (!last) return ""; | ||
| return last && /^(gz|br|map)$/i.test(last) ? `${split.pop()}.${last}` : last; | ||
| return last && /^(?:gz|br|map)$/i.test(last) | ||
| ? `${split.pop()}.${last}` | ||
| : last; | ||
| }; | ||
@@ -125,2 +127,3 @@ | ||
| for (const [name, entrypoint] of compilation.entrypoints) { | ||
| /** @type {string[]} */ | ||
| const imports = []; | ||
@@ -127,0 +130,0 @@ |
+7
-4
@@ -109,9 +109,11 @@ /* | ||
| /** @typedef {Map<"url", { ["css-url"]: string }>} KnownCodeGenerationResultDataForCssModules */ | ||
| /** @typedef {Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"fullContentHash", string>} KnownCodeGenerationResultDataForAssetModules */ | ||
| /** @typedef {Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"fullContentHash", string> & Map<"url", { javascript: string }>} KnownCodeGenerationResultDataForAssetModules */ | ||
| /** @typedef {Map<"share-init", [{ shareScope: string, initStage: number, init: string }]>} KnownCodeGenerationResultForSharing */ | ||
| /** @typedef {KnownCodeGenerationResultDataForJavascriptModules & KnownCodeGenerationResultDataForCssModules & KnownCodeGenerationResultDataForAssetModules & KnownCodeGenerationResultForSharing & Map<string, EXPECTED_ANY>} CodeGenerationResultData */ | ||
| /** @typedef {Map<SourceType, Source>} Sources */ | ||
| /** | ||
| * @typedef {object} CodeGenerationResult | ||
| * @property {Map<SourceType, Source>} sources the resulting sources for all source types | ||
| * @property {Sources} sources the resulting sources for all source types | ||
| * @property {CodeGenerationResultData=} data the resulting data for all source types | ||
@@ -139,4 +141,4 @@ * @property {ReadOnlyRuntimeRequirements | null} runtimeRequirements the runtime requirements | ||
| * @property {Record<string, string>=} jsIncompatibleExports | ||
| * @property {Map<RuntimeSpec, Record<string, string>>=} exportsFinalNameByRuntime | ||
| * @property {Map<RuntimeSpec, string>=} exportsSourceByRuntime | ||
| * @property {Map<string, Record<string, string>>=} exportsFinalNameByRuntime | ||
| * @property {Map<string, string>=} exportsSourceByRuntime | ||
| */ | ||
@@ -1031,2 +1033,3 @@ | ||
| // Best override this method | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -1033,0 +1036,0 @@ for (const type of this.getSourceTypes()) { |
@@ -20,6 +20,7 @@ /* | ||
| * @param {string | ErrorWithHideStack} err error thrown | ||
| * @param {{from?: string | null}} info additional info | ||
| * @param {{ from?: string | null }} info additional info | ||
| */ | ||
| constructor(err, { from = null } = {}) { | ||
| let message = "Module build failed"; | ||
| /** @type {undefined | string} */ | ||
| let details; | ||
@@ -52,2 +53,3 @@ | ||
| /** @type {string} */ | ||
| this.name = "ModuleBuildError"; | ||
@@ -54,0 +56,0 @@ this.details = details; |
@@ -24,2 +24,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "ModuleDependencyError"; | ||
@@ -26,0 +27,0 @@ this.details = |
@@ -24,2 +24,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "ModuleDependencyWarning"; | ||
@@ -26,0 +27,0 @@ this.details = |
@@ -18,3 +18,3 @@ /* | ||
| * @param {Error} err error thrown | ||
| * @param {{from?: string | null}} info additional info | ||
| * @param {{ from?: string | null }} info additional info | ||
| */ | ||
@@ -34,2 +34,3 @@ constructor(err, { from = null } = {}) { | ||
| /** @type {string} */ | ||
| this.name = "ModuleError"; | ||
@@ -36,0 +37,0 @@ this.error = err; |
@@ -118,3 +118,3 @@ /* | ||
| const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/gi; | ||
| const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/g; | ||
| /** | ||
@@ -161,2 +161,3 @@ * @typedef {object} ModuleFilenameTemplateContext | ||
| let absoluteResourcePath; | ||
| /** @type {ReturnStringCallback} */ | ||
| let hash; | ||
@@ -163,0 +164,0 @@ /** @type {ReturnStringCallback} */ |
@@ -36,2 +36,3 @@ /* | ||
| /** @type {Iterable<ModuleGraphConnection>} */ | ||
| const EMPTY_SET = new Set(); | ||
@@ -46,2 +47,3 @@ | ||
| const getConnectionsByKey = (set, getKey) => { | ||
| /** @type {Map<T, ModuleGraphConnection[]>} */ | ||
| const map = new Map(); | ||
@@ -533,2 +535,3 @@ /** @type {T | 0} */ | ||
| ) { | ||
| /** @type {undefined | ModuleGraphConnection} */ | ||
| let foundConnection; | ||
@@ -535,0 +538,0 @@ for (const connection of mgm._unassignedConnections) { |
@@ -60,3 +60,3 @@ /* | ||
| * @param {boolean=} weak the reference is weak | ||
| * @param {false | null | GetConditionFn | undefined} condition condition for the connection | ||
| * @param {false | null | GetConditionFn=} condition condition for the connection | ||
| */ | ||
@@ -71,10 +71,19 @@ constructor( | ||
| ) { | ||
| /** @type {Module | null} */ | ||
| this.originModule = originModule; | ||
| /** @type {Module | null} */ | ||
| this.resolvedOriginModule = originModule; | ||
| /** @type {Dependency | null} */ | ||
| this.dependency = dependency; | ||
| /** @type {Module} */ | ||
| this.resolvedModule = module; | ||
| /** @type {Module} */ | ||
| this.module = module; | ||
| /** @type {boolean | undefined} */ | ||
| this.weak = weak; | ||
| /** @type {boolean} */ | ||
| this.conditional = Boolean(condition); | ||
| /** @type {boolean} */ | ||
| this._active = condition !== false; | ||
| /** @type {false | null | GetConditionFn | undefined} */ | ||
| this.condition = condition || undefined; | ||
@@ -81,0 +90,0 @@ /** @type {Set<string> | undefined} */ |
@@ -21,2 +21,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "ModuleHashingError"; | ||
@@ -30,2 +31,3 @@ this.error = error; | ||
| /** @type {typeof ModuleHashingError} */ | ||
| module.exports = ModuleHashingError; |
@@ -66,2 +66,3 @@ /* | ||
| // determine exports to print | ||
| /** @type {ExportInfo[]} */ | ||
| const printedExports = []; | ||
@@ -149,3 +150,4 @@ for (const exportInfo of exportsInfo.orderedExports) { | ||
| /** @type {WeakMap<RequestShortener, WeakMap<Module, { header: RawSource | undefined, full: WeakMap<Source, CachedSource> }>>} */ | ||
| /** @typedef {{ header: RawSource | undefined, full: WeakMap<Source, CachedSource> }} CacheEntry */ | ||
| /** @type {WeakMap<RequestShortener, WeakMap<Module, CacheEntry>>} */ | ||
| const caches = new WeakMap(); | ||
@@ -160,2 +162,3 @@ | ||
| constructor(verbose = true) { | ||
| /** @type {boolean} */ | ||
| this._verbose = verbose; | ||
@@ -181,2 +184,3 @@ } | ||
| const { requestShortener } = runtimeTemplate; | ||
| /** @type {undefined | CacheEntry} */ | ||
| let cacheEntry; | ||
@@ -263,2 +267,3 @@ let cache = caches.get(requestShortener); | ||
| const { requestShortener } = runtimeTemplate; | ||
| /** @type {undefined | CacheEntry} */ | ||
| let cacheEntry; | ||
@@ -265,0 +270,0 @@ let cache = caches.get(requestShortener); |
@@ -81,2 +81,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "ModuleNotFoundError"; | ||
@@ -83,0 +84,0 @@ this.details = err.details; |
@@ -11,2 +11,3 @@ /* | ||
| /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("./Dependency").SourcePosition} SourcePosition */ | ||
@@ -27,2 +28,3 @@ /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| let message = `Module parse failed: ${err && err.message}`; | ||
| /** @type {undefined | DependencyLocation} */ | ||
| let loc; | ||
@@ -45,3 +47,4 @@ | ||
| message += | ||
| "\nYou may need an appropriate loader to handle this file type."; | ||
| "\nYou may need an appropriate loader to handle this file type. " + | ||
| "See https://webpack.js.org/concepts/loaders"; | ||
| } else if (loaders.length >= 1) { | ||
@@ -94,2 +97,3 @@ message += `\nFile was processed with these loaders:${loaders | ||
| /** @type {string} */ | ||
| this.name = "ModuleParseError"; | ||
@@ -96,0 +100,0 @@ this.loc = loc; |
@@ -37,3 +37,3 @@ /* | ||
| /** @type {{ start: number, end: number }[] | undefined } */ | ||
| /** @type {{ start: number, end: number }[] | undefined} */ | ||
| this.additionalFactoryTimes = undefined; | ||
@@ -40,0 +40,0 @@ this.additionalFactories = 0; |
@@ -36,2 +36,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "ModuleRestoreError"; | ||
@@ -45,2 +46,3 @@ /** @type {string | undefined} */ | ||
| /** @type {typeof ModuleRestoreError} */ | ||
| module.exports = ModuleRestoreError; |
@@ -64,13 +64,3 @@ /* | ||
| /** | ||
| * @typedef {JAVASCRIPT_TYPE | | ||
| * RUNTIME_TYPE | | ||
| * WEBASSEMBLY_TYPE | | ||
| * ASSET_TYPE | | ||
| * CSS_TYPE | | ||
| * CSS_IMPORT_TYPE | | ||
| * CSS_URL_TYPE | | ||
| * SHARED_INIT_TYPE | | ||
| * REMOTE_GENERATOR_TYPE | | ||
| * CONSUME_SHARED_GENERATOR_TYPE | | ||
| * UNKNOWN_TYPE} AllTypes | ||
| * @typedef {JAVASCRIPT_TYPE | RUNTIME_TYPE | WEBASSEMBLY_TYPE | ASSET_TYPE | CSS_TYPE | CSS_IMPORT_TYPE | CSS_URL_TYPE | SHARED_INIT_TYPE | REMOTE_GENERATOR_TYPE | CONSUME_SHARED_GENERATOR_TYPE | UNKNOWN_TYPE} AllTypes | ||
| */ | ||
@@ -77,0 +67,0 @@ |
@@ -36,2 +36,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "ModuleStoreError"; | ||
@@ -44,2 +45,3 @@ this.details = /** @type {string | undefined} */ (details); | ||
| /** @type {typeof ModuleStoreError} */ | ||
| module.exports = ModuleStoreError; |
@@ -18,3 +18,3 @@ /* | ||
| * @param {Error} warning error thrown | ||
| * @param {{from?: string | null}} info additional info | ||
| * @param {{ from?: string | null }} info additional info | ||
| */ | ||
@@ -34,2 +34,3 @@ constructor(warning, { from = null } = {}) { | ||
| /** @type {string} */ | ||
| this.name = "ModuleWarning"; | ||
@@ -68,2 +69,3 @@ this.warning = warning; | ||
| /** @type {typeof ModuleWarning} */ | ||
| module.exports = ModuleWarning; |
+11
-7
@@ -140,6 +140,7 @@ /* | ||
| }; | ||
| /** @type {Set<string>} */ | ||
| const cacheNames = new Set(); | ||
| for (const compiler of this.compilers) { | ||
| if (compiler.options.cache && "name" in compiler.options.cache) { | ||
| const name = compiler.options.cache.name; | ||
| const name = /** @type {string} */ (compiler.options.cache.name); | ||
| if (cacheNames.has(name)) { | ||
@@ -259,3 +260,3 @@ addWarning( | ||
| validateDependencies(callback) { | ||
| /** @type {Set<{source: Compiler, target: Compiler}>} */ | ||
| /** @type {Set<{ source: Compiler, target: Compiler }>} */ | ||
| const edges = new Set(); | ||
@@ -277,4 +278,4 @@ /** @type {string[]} */ | ||
| /** | ||
| * @param {{source: Compiler, target: Compiler}} e1 edge 1 | ||
| * @param {{source: Compiler, target: Compiler}} e2 edge 2 | ||
| * @param {{ source: Compiler, target: Compiler }} e1 edge 1 | ||
| * @param {{ source: Compiler, target: Compiler }} e2 edge 2 | ||
| * @returns {number} result | ||
@@ -345,2 +346,3 @@ */ | ||
| runWithDependencies(compilers, fn, callback) { | ||
| /** @type {Set<string>} */ | ||
| const fulfilledNames = new Set(); | ||
@@ -357,2 +359,3 @@ let remainingCompilers = compilers; | ||
| const getReadyCompilers = () => { | ||
| /** @type {Compiler[]} */ | ||
| const readyCompilers = []; | ||
@@ -384,3 +387,3 @@ const list = remainingCompilers; | ||
| if (err) return callback(err); | ||
| fulfilledNames.add(compiler.name); | ||
| fulfilledNames.add(/** @type {string} */ (compiler.name)); | ||
| runCompilers(callback); | ||
@@ -390,3 +393,3 @@ }); | ||
| (err, results) => { | ||
| callback(err, results); | ||
| callback(/** @type {Error | null} */ (err), results); | ||
| } | ||
@@ -577,2 +580,3 @@ ); | ||
| ) { | ||
| /** @type {Stats[]} */ | ||
| const stats = []; | ||
@@ -678,3 +682,3 @@ for (const node of nodes) { | ||
| (error) => { | ||
| callback(error); | ||
| callback(/** @type {Error | null} */ (error)); | ||
| } | ||
@@ -681,0 +685,0 @@ ); |
@@ -34,3 +34,3 @@ /* | ||
| (err) => { | ||
| callback(err); | ||
| callback(/** @type {Error | null} */ (err)); | ||
| } | ||
@@ -71,3 +71,3 @@ ); | ||
| this.compiler.running = false; | ||
| callback(err); | ||
| callback(/** @type {Error | null} */ (err)); | ||
| } | ||
@@ -74,0 +74,0 @@ } |
@@ -60,2 +60,3 @@ /* | ||
| }; | ||
| /** @type {WeakSet<Chunk>} */ | ||
| const onceForChunkSet = new WeakSet(); | ||
@@ -62,0 +63,0 @@ /** |
@@ -70,6 +70,7 @@ /* | ||
| /** | ||
| * @template T | ||
| * @param {string} prefix prefix | ||
| * @param {string} colorPrefix color prefix | ||
| * @param {string} colorSuffix color suffix | ||
| * @returns {(...args: EXPECTED_ANY[]) => void} function to write with colors | ||
| * @returns {(...args: T[]) => void} function to write with colors | ||
| */ | ||
@@ -91,2 +92,3 @@ const writeColored = | ||
| /** @type {<T extends unknown[]>(...args: T) => void} */ | ||
| const writeGroupMessage = writeColored( | ||
@@ -98,2 +100,3 @@ "<-> ", | ||
| /** @type {<T extends unknown[]>(...args: T) => void} */ | ||
| const writeGroupCollapsedMessage = writeColored( | ||
@@ -106,8 +109,15 @@ "<+> ", | ||
| return { | ||
| /** @type {LoggerConsole["log"]} */ | ||
| log: writeColored(" ", "\u001B[1m", "\u001B[22m"), | ||
| /** @type {LoggerConsole["debug"]} */ | ||
| debug: writeColored(" ", "", ""), | ||
| /** @type {LoggerConsole["trace"]} */ | ||
| trace: writeColored(" ", "", ""), | ||
| /** @type {LoggerConsole["info"]} */ | ||
| info: writeColored("<i> ", "\u001B[1m\u001B[32m", "\u001B[39m\u001B[22m"), | ||
| /** @type {LoggerConsole["warn"]} */ | ||
| warn: writeColored("<w> ", "\u001B[1m\u001B[33m", "\u001B[39m\u001B[22m"), | ||
| /** @type {LoggerConsole["error"]} */ | ||
| error: writeColored("<e> ", "\u001B[1m\u001B[31m", "\u001B[39m\u001B[22m"), | ||
| /** @type {LoggerConsole["logTime"]} */ | ||
| logTime: writeColored( | ||
@@ -118,2 +128,3 @@ "<t> ", | ||
| ), | ||
| /** @type {LoggerConsole["group"]} */ | ||
| group: (...args) => { | ||
@@ -127,2 +138,3 @@ writeGroupMessage(...args); | ||
| }, | ||
| /** @type {LoggerConsole["groupCollapsed"]} */ | ||
| groupCollapsed: (...args) => { | ||
@@ -132,2 +144,3 @@ writeGroupCollapsedMessage(...args); | ||
| }, | ||
| /** @type {LoggerConsole["groupEnd"]} */ | ||
| groupEnd: () => { | ||
@@ -140,4 +153,7 @@ if (currentCollapsed > 0) { | ||
| }, | ||
| /** @type {LoggerConsole["profile"]} */ | ||
| profile: console.profile && ((name) => console.profile(name)), | ||
| /** @type {LoggerConsole["profileEnd"]} */ | ||
| profileEnd: console.profileEnd && ((name) => console.profileEnd(name)), | ||
| /** @type {LoggerConsole["clear"]} */ | ||
| clear: | ||
@@ -154,2 +170,3 @@ /** @type {() => void} */ | ||
| ), | ||
| /** @type {LoggerConsole["status"]} */ | ||
| status: appendOnly | ||
@@ -156,0 +173,0 @@ ? writeColored("<s> ", "", "") |
@@ -80,2 +80,3 @@ /* | ||
| constructor(type = "node-commonjs") { | ||
| /** @type {ExternalsType} */ | ||
| this.type = type; | ||
@@ -82,0 +83,0 @@ } |
@@ -11,2 +11,3 @@ /* | ||
| /** @typedef {import("watchpack").TimeInfoEntries} TimeInfoEntries */ | ||
| /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */ | ||
@@ -69,3 +70,5 @@ /** @typedef {import("../util/fs").WatchMethod} WatchMethod */ | ||
| const fetchTimeInfo = () => { | ||
| /** @type {TimeInfoEntries} */ | ||
| const fileTimeInfoEntries = new Map(); | ||
| /** @type {TimeInfoEntries} */ | ||
| const contextTimeInfoEntries = new Map(); | ||
@@ -72,0 +75,0 @@ if (this.watcher) { |
@@ -27,2 +27,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "NodeStuffInWebError"; | ||
@@ -29,0 +30,0 @@ this.loc = loc; |
@@ -14,2 +14,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "NoModeWarning"; | ||
@@ -16,0 +17,0 @@ this.message = |
+26
-5
@@ -82,2 +82,3 @@ /* | ||
| /** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("./Module").Sources} Sources */ | ||
| /** @typedef {import("./Module").SourceType} SourceType */ | ||
@@ -127,3 +128,3 @@ /** @typedef {import("./Module").SourceTypes} SourceTypes */ | ||
| const ABSOLUTE_PATH_REGEX = /^([a-zA-Z]:\\|\\\\|\/)/; | ||
| const ABSOLUTE_PATH_REGEX = /^(?:[a-z]:\\|\\\\|\/)/i; | ||
@@ -365,3 +366,3 @@ /** | ||
| /** @type {boolean} */ | ||
| this.binary = /^(asset|webassembly)\b/.test(type); | ||
| this.binary = /^(?:asset|webassembly)\b/.test(type); | ||
| /** @type {NormalModuleCreateData['parser'] | undefined} */ | ||
@@ -409,10 +410,27 @@ this.parser = parser; | ||
| this._sourceTypes = undefined; | ||
| // Cache | ||
| /** | ||
| * @private | ||
| * @type {BuildMeta} | ||
| */ | ||
| this._lastSuccessfulBuildMeta = {}; | ||
| /** | ||
| * @private | ||
| * @type {boolean} | ||
| */ | ||
| this._forceBuild = true; | ||
| /** | ||
| * @private | ||
| * @type {boolean} | ||
| */ | ||
| this._isEvaluatingSideEffects = false; | ||
| /** @type {WeakSet<ModuleGraph> | undefined} */ | ||
| /** | ||
| * @private | ||
| * @type {WeakSet<ModuleGraph> | undefined} | ||
| */ | ||
| this._addedSideEffectsBailout = undefined; | ||
| /** @type {CodeGenerationResultData} */ | ||
| /** | ||
| * @private | ||
| * @type {CodeGenerationResultData} | ||
| */ | ||
| this._codeGeneratorData = new Map(); | ||
@@ -725,2 +743,3 @@ } | ||
| let baseDataPath = "options"; | ||
| /** @type {RegExpExecArray | null} */ | ||
| let match; | ||
@@ -990,2 +1009,3 @@ if (schema.title && (match = /^(.+) (.+)$/.exec(schema.title))) { | ||
| if (this._sourceSizes !== undefined) this._sourceSizes.clear(); | ||
| /** @type {PreparsedAst | null} */ | ||
| this._ast = | ||
@@ -1527,2 +1547,3 @@ typeof extraInfo === "object" && | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -1529,0 +1550,0 @@ for (const type of sourceTypes || chunkGraph.getModuleSourceTypes(this)) { |
@@ -57,2 +57,3 @@ /* | ||
| /** @typedef {import("./rules/RuleSetCompiler").RuleSetRules} RuleSetRules */ | ||
| /** @typedef {import("./rules/RuleSetCompiler").RuleSet} RuleSet */ | ||
| /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ | ||
@@ -108,3 +109,3 @@ /** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */ | ||
| * @property {string} loader loader | ||
| * @property {string|undefined} options options | ||
| * @property {string | undefined} options options | ||
| */ | ||
@@ -200,2 +201,3 @@ | ||
| const parts = type.split("/"); | ||
| /** @type {undefined | T} */ | ||
| let result; | ||
@@ -308,2 +310,3 @@ let current = ""; | ||
| /* eslint-disable jsdoc/type-formatting */ | ||
| /** | ||
@@ -329,2 +332,3 @@ * @typedef {[ | ||
| */ | ||
| /* eslint-enable jsdoc/type-formatting */ | ||
@@ -399,3 +403,5 @@ /** | ||
| }); | ||
| /** @type {ResolverFactory} */ | ||
| this.resolverFactory = resolverFactory; | ||
| /** @type {RuleSet} */ | ||
| this.ruleSet = ruleSetCompiler.compile([ | ||
@@ -409,3 +415,5 @@ { | ||
| ]); | ||
| /** @type {string} */ | ||
| this.context = context || ""; | ||
| /** @type {InputFileSystem} */ | ||
| this.fs = fs; | ||
@@ -672,3 +680,5 @@ this._globalParserOptions = options.parser; | ||
| // handle .webpack[] suffix | ||
| /** @type {string} */ | ||
| let resource; | ||
| /** @type {RegExpExecArray | null} */ | ||
| let match; | ||
@@ -864,3 +874,3 @@ if ( | ||
| const defaultResolve = (context) => { | ||
| if (/^($|\?)/.test(unresolvedResource)) { | ||
| if (/^(?:$|\?)/.test(unresolvedResource)) { | ||
| resourceData = { | ||
@@ -981,4 +991,7 @@ ...cacheParseResource(unresolvedResource), | ||
| const contextInfo = data.contextInfo; | ||
| /** @type {FileSystemDependencies} */ | ||
| const fileDependencies = new LazySet(); | ||
| /** @type {FileSystemDependencies} */ | ||
| const missingDependencies = new LazySet(); | ||
| /** @type {FileSystemDependencies} */ | ||
| const contextDependencies = new LazySet(); | ||
@@ -1198,3 +1211,3 @@ /** @type {ResolveData} */ | ||
| let hint = ""; | ||
| const match = /(\.[^.]+)(\?|$)/.exec(unresolvedResource); | ||
| const match = /\.[^.]+(?:\?|$)/.exec(unresolvedResource); | ||
| if (match) { | ||
@@ -1349,3 +1362,6 @@ const fixedRequest = unresolvedResource.replace( | ||
| (err, value) => { | ||
| callback(err, /** @type {(LoaderItem)[]} */ (value)); | ||
| callback( | ||
| /** @type {Error | null} */ (err), | ||
| /** @type {(LoaderItem)[]} */ (value) | ||
| ); | ||
| } | ||
@@ -1352,0 +1368,0 @@ ); |
@@ -33,2 +33,3 @@ /* | ||
| } | ||
| /** @type {AggressiveMergingPluginOptions} */ | ||
| this.options = options || {}; | ||
@@ -54,3 +55,3 @@ } | ||
| const chunkGraph = compilation.chunkGraph; | ||
| /** @type {{a: Chunk, b: Chunk, improvement: number}[]} */ | ||
| /** @type {{ a: Chunk, b: Chunk, improvement: number }[]} */ | ||
| const combinations = []; | ||
@@ -57,0 +58,0 @@ for (const a of chunks) { |
@@ -53,3 +53,3 @@ /* | ||
| /** @typedef {{ id?: NonNullable<Chunk["id"]>, hash?: NonNullable<Chunk["hash"]>, modules: Module[], size: number }} SplitData */ | ||
| /** @typedef {{ id?: NonNullable<Chunk["id"]>, hash?: NonNullable<Chunk["hash"]>, modules: string[], size: number }} SplitData */ | ||
@@ -118,3 +118,5 @@ /** @type {WeakSet<Chunk>} */ | ||
| // Precompute stuff | ||
| /** @type {Map<string, Module>} */ | ||
| const nameToModuleMap = new Map(); | ||
| /** @type {Map<Module, string>} */ | ||
| const moduleToNameMap = new Map(); | ||
@@ -133,6 +135,6 @@ const makePathsRelative = | ||
| // Check used chunk ids | ||
| /** @typedef {Set<ChunkId>} */ | ||
| /** @type {Set<ChunkId>} */ | ||
| const usedIds = new Set(); | ||
| for (const chunk of chunks) { | ||
| usedIds.add(chunk.id); | ||
| usedIds.add(/** @type {ChunkId} */ (chunk.id)); | ||
| } | ||
@@ -160,4 +162,4 @@ | ||
| // Get module objects from names | ||
| const selectedModules = splitData.modules.map((name) => | ||
| nameToModuleMap.get(name) | ||
| const selectedModules = splitData.modules.map( | ||
| (name) => /** @type {Module} */ (nameToModuleMap.get(name)) | ||
| ); | ||
@@ -247,2 +249,3 @@ | ||
| .filter(isNotAEntryModule(chunkGraph, chunk)); | ||
| /** @type {Module[]} */ | ||
| const selectedModules = []; | ||
@@ -263,3 +266,3 @@ let selectedModulesSize = 0; | ||
| modules: selectedModules | ||
| .map((m) => moduleToNameMap.get(m)) | ||
| .map((m) => /** @type {string} */ (moduleToNameMap.get(m))) | ||
| .sort(), | ||
@@ -280,2 +283,3 @@ size: selectedModulesSize | ||
| // 4. save made splittings to records | ||
| /** @type {Set<SplitData>} */ | ||
| const allSplits = new Set(); | ||
@@ -282,0 +286,0 @@ /** @type {Set<SplitData>} */ |
@@ -45,3 +45,12 @@ /* | ||
| const modulo = 1 / (1 / modulesCount) ** (1 / 31); | ||
| const modulos = Array.from({ length: 31 }, (x, i) => (modulo ** i) | 0); | ||
| /** @type {number[]} */ | ||
| const modulos = Array.from( | ||
| { length: 31 }, | ||
| /** | ||
| * @param {number} x x | ||
| * @param {number} i i | ||
| * @returns {number} result | ||
| */ | ||
| (x, i) => (modulo ** i) | 0 | ||
| ); | ||
@@ -76,2 +85,3 @@ // iterate all modules to generate bit values | ||
| if (chunkAModulesCount === 0) continue; | ||
| /** @type {undefined | Module} */ | ||
| let bestModule; | ||
@@ -78,0 +88,0 @@ for (const module of chunkGraph.getChunkModulesIterable(chunkA)) { |
@@ -38,2 +38,3 @@ /* | ||
| constructor(name) { | ||
| /** @type {string} */ | ||
| this.name = name; | ||
@@ -314,2 +315,3 @@ } | ||
| if (callbacks === undefined) { | ||
| /** @type {Set<UsageCallback>} */ | ||
| callbacks = new Set(); | ||
@@ -358,12 +360,12 @@ usageCallbackMap.set(currentTopLevelSymbol, callbacks); | ||
| const fn = new TopLevelSymbol(name); | ||
| const symbol = new TopLevelSymbol(name); | ||
| parser.tagVariable( | ||
| name, | ||
| topLevelSymbolTag, | ||
| fn, | ||
| symbol, | ||
| JavascriptParser.VariableInfoFlags.Normal | ||
| ); | ||
| return fn; | ||
| return symbol; | ||
| }; | ||
| module.exports.topLevelSymbolTag = topLevelSymbolTag; |
@@ -123,6 +123,6 @@ /* | ||
| const name = statement.id ? statement.id.name : "*default*"; | ||
| const fn = | ||
| const symbol = | ||
| /** @type {TopLevelSymbol} */ | ||
| (InnerGraph.tagTopLevelSymbol(parser, name)); | ||
| statementWithTopLevelSymbol.set(statement, fn); | ||
| statementWithTopLevelSymbol.set(statement, symbol); | ||
| return true; | ||
@@ -144,6 +144,6 @@ } | ||
| const name = statement.id ? statement.id.name : "*default*"; | ||
| const fn = /** @type {TopLevelSymbol} */ ( | ||
| const symbol = /** @type {TopLevelSymbol} */ ( | ||
| InnerGraph.tagTopLevelSymbol(parser, name) | ||
| ); | ||
| classWithTopLevelSymbol.set(statement, fn); | ||
| classWithTopLevelSymbol.set(statement, symbol); | ||
| return true; | ||
@@ -153,3 +153,3 @@ } | ||
| const name = "*default*"; | ||
| const fn = | ||
| const symbol = | ||
| /** @type {TopLevelSymbol} */ | ||
@@ -171,3 +171,3 @@ (InnerGraph.tagTopLevelSymbol(parser, name)); | ||
| (decl), | ||
| fn | ||
| symbol | ||
| ); | ||
@@ -182,3 +182,3 @@ } else if ( | ||
| ) { | ||
| statementWithTopLevelSymbol.set(statement, fn); | ||
| statementWithTopLevelSymbol.set(statement, symbol); | ||
| if ( | ||
@@ -215,6 +215,6 @@ !decl.type.endsWith("FunctionExpression") && | ||
| ) { | ||
| const fn = | ||
| const symbol = | ||
| /** @type {TopLevelSymbol} */ | ||
| (InnerGraph.tagTopLevelSymbol(parser, name)); | ||
| classWithTopLevelSymbol.set(decl.init, fn); | ||
| classWithTopLevelSymbol.set(decl.init, symbol); | ||
| } else if ( | ||
@@ -226,6 +226,6 @@ parser.isPure( | ||
| ) { | ||
| const fn = | ||
| const symbol = | ||
| /** @type {TopLevelSymbol} */ | ||
| (InnerGraph.tagTopLevelSymbol(parser, name)); | ||
| declWithTopLevelSymbol.set(decl, fn); | ||
| declWithTopLevelSymbol.set(decl, symbol); | ||
| if ( | ||
@@ -262,5 +262,5 @@ !decl.init.type.endsWith("FunctionExpression") && | ||
| const fn = statementWithTopLevelSymbol.get(statement); | ||
| if (fn) { | ||
| InnerGraph.setTopLevelSymbol(parser.state, fn); | ||
| const symbol = statementWithTopLevelSymbol.get(statement); | ||
| if (symbol) { | ||
| InnerGraph.setTopLevelSymbol(parser.state, symbol); | ||
| const purePart = statementPurePart.get(statement); | ||
@@ -296,5 +296,5 @@ if (purePart) { | ||
| if (parser.scope.topLevelScope === true) { | ||
| const fn = classWithTopLevelSymbol.get(statement); | ||
| const symbol = classWithTopLevelSymbol.get(statement); | ||
| if ( | ||
| fn && | ||
| symbol && | ||
| parser.isPure( | ||
@@ -307,3 +307,3 @@ expr, | ||
| ) { | ||
| InnerGraph.setTopLevelSymbol(parser.state, fn); | ||
| InnerGraph.setTopLevelSymbol(parser.state, symbol); | ||
| onUsageSuper(expr); | ||
@@ -320,4 +320,4 @@ } | ||
| if (parser.scope.topLevelScope === true) { | ||
| const fn = classWithTopLevelSymbol.get(classDefinition); | ||
| if (fn) { | ||
| const symbol = classWithTopLevelSymbol.get(classDefinition); | ||
| if (symbol) { | ||
| InnerGraph.setTopLevelSymbol(parser.state, undefined); | ||
@@ -334,4 +334,4 @@ } | ||
| if (parser.scope.topLevelScope === true) { | ||
| const fn = classWithTopLevelSymbol.get(classDefinition); | ||
| if (fn) { | ||
| const symbol = classWithTopLevelSymbol.get(classDefinition); | ||
| if (symbol) { | ||
| if ( | ||
@@ -346,3 +346,3 @@ !element.static || | ||
| ) { | ||
| InnerGraph.setTopLevelSymbol(parser.state, fn); | ||
| InnerGraph.setTopLevelSymbol(parser.state, symbol); | ||
| if (element.type !== "MethodDefinition" && element.static) { | ||
@@ -378,6 +378,6 @@ InnerGraph.onUsage(parser.state, (usedByExports) => { | ||
| if (!InnerGraph.isEnabled(parser.state)) return; | ||
| const fn = declWithTopLevelSymbol.get(decl); | ||
| const symbol = declWithTopLevelSymbol.get(decl); | ||
| if (fn) { | ||
| InnerGraph.setTopLevelSymbol(parser.state, fn); | ||
| if (symbol) { | ||
| InnerGraph.setTopLevelSymbol(parser.state, symbol); | ||
| if (pureDeclarators.has(decl)) { | ||
@@ -384,0 +384,0 @@ if ( |
@@ -20,4 +20,10 @@ /* | ||
| /** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */ | ||
| /** @typedef {import("../util/concatenate").UsedNames} UsedNames */ | ||
| /** | ||
| * @template T | ||
| * @typedef {import("../util/comparators").Comparator<T>} Comparator | ||
| */ | ||
| /** | ||
| * @param {ExportsInfo} exportsInfo exports info | ||
@@ -40,2 +46,3 @@ * @returns {boolean} mangle is possible | ||
| // Sort by name | ||
| /** @type {Comparator<ExportInfo>} */ | ||
| const comparator = compareSelect((e) => e.name, compareStringsNumeric); | ||
@@ -50,2 +57,3 @@ /** | ||
| if (!canMangle(exportsInfo)) return; | ||
| /** @type {UsedNames} */ | ||
| const usedNames = new Set(); | ||
@@ -75,7 +83,7 @@ /** @type {ExportInfo[]} */ | ||
| // Never rename 1 char exports | ||
| (name.length === 1 && /^[a-zA-Z0-9_$]/.test(name)) || | ||
| (name.length === 1 && /^[a-z0-9_$]/i.test(name)) || | ||
| // Don't rename 2 char exports in deterministic mode | ||
| (deterministic && | ||
| name.length === 2 && | ||
| /^[a-zA-Z_$][a-zA-Z0-9_$]|^[1-9][0-9]/.test(name)) || | ||
| /^[a-z_$][a-z0-9_$]|^[1-9][0-9]/i.test(name)) || | ||
| // Don't rename exports that are not provided | ||
@@ -126,3 +134,5 @@ (avoidMangleNonProvided && exportInfo.provided !== true) | ||
| } else { | ||
| /** @type {ExportInfo[]} */ | ||
| const usedExports = []; | ||
| /** @type {ExportInfo[]} */ | ||
| const unusedExports = []; | ||
@@ -141,2 +151,3 @@ for (const exportInfo of mangleableExports) { | ||
| for (const exportInfo of list) { | ||
| /** @type {string} */ | ||
| let name; | ||
@@ -159,2 +170,3 @@ do { | ||
| constructor(deterministic) { | ||
| /** @type {boolean} */ | ||
| this._deterministic = deterministic; | ||
@@ -161,0 +173,0 @@ } |
@@ -14,2 +14,3 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
@@ -52,2 +53,3 @@ const validate = createSchemaValidation( | ||
| // remember already tested chunks for performance | ||
| /** @type {Set<Chunk>} */ | ||
| const notDuplicates = new Set(); | ||
@@ -58,2 +60,3 @@ | ||
| // track a Set of all chunk that could be duplicates | ||
| /** @type {Set<Chunk> | undefined} */ | ||
| let possibleDuplicates; | ||
@@ -60,0 +63,0 @@ for (const module of chunkGraph.getChunkModulesIterable(chunk)) { |
@@ -32,2 +32,3 @@ /* | ||
| validate(options); | ||
| /** @type {MinChunkSizePluginOptions} */ | ||
| this.options = options; | ||
@@ -57,2 +58,3 @@ } | ||
| /** @type {Map<Chunk, number>} */ | ||
| const chunkSizesMap = new Map(); | ||
@@ -63,2 +65,3 @@ /** @type {[Chunk, Chunk][]} */ | ||
| const smallChunks = []; | ||
| /** @type {Chunk[]} */ | ||
| const visitedChunks = []; | ||
@@ -89,4 +92,4 @@ for (const a of chunks) { | ||
| // extend combination pairs with size and integrated size | ||
| const a = chunkSizesMap.get(pair[0]); | ||
| const b = chunkSizesMap.get(pair[1]); | ||
| const a = /** @type {number} */ (chunkSizesMap.get(pair[0])); | ||
| const b = /** @type {number} */ (chunkSizesMap.get(pair[1])); | ||
| const ab = chunkGraph.getIntegratedChunksSize( | ||
@@ -93,0 +96,0 @@ pair[0], |
@@ -31,2 +31,4 @@ /* | ||
| /** @typedef {Module | ((requestShortener: RequestShortener) => string)} Problem */ | ||
| /** | ||
@@ -108,3 +110,3 @@ * @typedef {object} Statistics | ||
| * @param {Module} module the module | ||
| * @param {Module | ((requestShortener: RequestShortener) => string)} problem the problem | ||
| * @param {Problem} problem the problem | ||
| * @returns {(requestShortener: RequestShortener) => string} the reason | ||
@@ -148,3 +150,5 @@ */ | ||
| const { chunkGraph, moduleGraph } = compilation; | ||
| /** @type {Module[]} */ | ||
| const relevantModules = []; | ||
| /** @type {Set<Module>} */ | ||
| const possibleInners = new Set(); | ||
@@ -271,3 +275,5 @@ const context = { | ||
| logger.time("find modules to concatenate"); | ||
| /** @type {ConcatConfiguration[]} */ | ||
| const concatConfigurations = []; | ||
| /** @type {Set<Module>} */ | ||
| const usedAsInner = new Set(); | ||
@@ -280,2 +286,3 @@ for (const currentRoot of relevantModules) { | ||
| /** @type {RuntimeSpec} */ | ||
| let chunkRuntime; | ||
@@ -303,2 +310,3 @@ for (const r of chunkGraph.getModuleRuntimes(currentRoot)) { | ||
| // cache failures to add modules | ||
| /** @type {Map<Module, Problem>} */ | ||
| const failureCache = new Map(); | ||
@@ -320,2 +328,3 @@ | ||
| for (const imp of candidates) { | ||
| /** @type {Set<Module>} */ | ||
| const impCandidates = new Set(); | ||
@@ -383,2 +392,3 @@ const problem = this._tryToAdd( | ||
| logger.timeEnd("sort concat configurations"); | ||
| /** @type {Set<Module>} */ | ||
| const usedModules = new Set(); | ||
@@ -526,2 +536,3 @@ | ||
| const moduleGraph = compilation.moduleGraph; | ||
| /** @type {Set<Module>} */ | ||
| const set = new Set(); | ||
@@ -567,7 +578,7 @@ for (const dep of module.dependencies) { | ||
| * @param {Set<Module>} candidates list of potential candidates (will be added to) | ||
| * @param {Map<Module, Module | ((requestShortener: RequestShortener) => string)>} failureCache cache for problematic modules to be more performant | ||
| * @param {Map<Module, Problem>} failureCache cache for problematic modules to be more performant | ||
| * @param {ChunkGraph} chunkGraph the chunk graph | ||
| * @param {boolean} avoidMutateOnFailure avoid mutating the config when adding fails | ||
| * @param {Statistics} statistics gathering metrics | ||
| * @returns {null | Module | ((requestShortener: RequestShortener) => string)} the problematic module | ||
| * @returns {null | Problem} the problematic module | ||
| */ | ||
@@ -659,2 +670,3 @@ _tryToAdd( | ||
| const problem = (requestShortener) => { | ||
| /** @type {Set<string>} */ | ||
| const importingExplanations = new Set( | ||
@@ -688,2 +700,3 @@ activeNonModulesConnections | ||
| // We don't care for connections from other runtimes | ||
| /** @type {RuntimeSpec} */ | ||
| let originRuntime; | ||
@@ -837,2 +850,3 @@ for (const r of chunkGraph.getModuleRuntimes(originModule)) { | ||
| /** @type {undefined | number} */ | ||
| let backup; | ||
@@ -880,3 +894,2 @@ if (avoidMutateOnFailure) { | ||
| /** @typedef {Module | ((requestShortener: RequestShortener) => string)} Problem */ | ||
| /** @typedef {Map<Module, Problem>} Warnings */ | ||
@@ -890,3 +903,5 @@ | ||
| constructor(rootModule, runtime) { | ||
| /** @type {Module} */ | ||
| this.rootModule = rootModule; | ||
| /** @type {RuntimeSpec} */ | ||
| this.runtime = runtime; | ||
@@ -893,0 +908,0 @@ /** @type {Set<Module>} */ |
@@ -23,2 +23,8 @@ /* | ||
| /** | ||
| * @template T | ||
| * @typedef {import("../util/comparators").Comparator<T>} Comparator | ||
| */ | ||
| /** @type {Hashes} */ | ||
| const EMPTY_SET = new Set(); | ||
@@ -51,2 +57,3 @@ | ||
| // instead of looping over all assets. | ||
| /** @type {Buffer[]} */ | ||
| const result = []; | ||
@@ -70,2 +77,3 @@ outer: for (const value of input) { | ||
| /** @type {WeakMap<Source, CachedSource>} */ | ||
| const cachedSourceMap = new WeakMap(); | ||
@@ -88,4 +96,2 @@ | ||
| /** @typedef {Set<string>} OwnHashes */ | ||
| /** @typedef {Set<string>} ReferencedHashes */ | ||
| /** @typedef {Set<string>} Hashes */ | ||
@@ -101,6 +107,6 @@ | ||
| * @property {string} content | ||
| * @property {OwnHashes | undefined} ownHashes | ||
| * @property {Hashes | undefined} ownHashes | ||
| * @property {Promise<void> | undefined} contentComputePromise | ||
| * @property {Promise<void> | undefined} contentComputeWithoutOwnPromise | ||
| * @property {ReferencedHashes | undefined} referencedHashes | ||
| * @property {Hashes | undefined} referencedHashes | ||
| * @property {Hashes} hashes | ||
@@ -228,3 +234,5 @@ */ | ||
| await cacheAnalyse.providePromise(name, etag, () => { | ||
| /** @type {Hashes} */ | ||
| const referencedHashes = new Set(); | ||
| /** @type {Hashes} */ | ||
| const ownHashes = new Set(); | ||
@@ -247,3 +255,3 @@ const inContent = content.match(hashRegExp); | ||
| * @param {string} hash the hash | ||
| * @returns {undefined | ReferencedHashes} the referenced hashes | ||
| * @returns {undefined | Hashes} the referenced hashes | ||
| */ | ||
@@ -254,5 +262,3 @@ const getDependencies = (hash) => { | ||
| const referencingAssets = assetsWithInfo.filter((asset) => | ||
| /** @type {ReferencedHashes} */ (asset.referencedHashes).has( | ||
| hash | ||
| ) | ||
| /** @type {Hashes} */ (asset.referencedHashes).has(hash) | ||
| ); | ||
@@ -275,12 +281,11 @@ const err = new WebpackError(`RealContentHashPlugin | ||
| } | ||
| /** @type {Hashes} */ | ||
| const hashes = new Set(); | ||
| for (const { referencedHashes, ownHashes } of assets) { | ||
| if (!(/** @type {OwnHashes} */ (ownHashes).has(hash))) { | ||
| for (const hash of /** @type {OwnHashes} */ (ownHashes)) { | ||
| if (!(/** @type {Hashes} */ (ownHashes).has(hash))) { | ||
| for (const hash of /** @type {Hashes} */ (ownHashes)) { | ||
| hashes.add(hash); | ||
| } | ||
| } | ||
| for (const hash of /** @type {ReferencedHashes} */ ( | ||
| referencedHashes | ||
| )) { | ||
| for (const hash of /** @type {Hashes} */ (referencedHashes)) { | ||
| hashes.add(hash); | ||
@@ -302,3 +307,3 @@ } | ||
| }; | ||
| /** @type {Set<string>} */ | ||
| /** @type {Hashes} */ | ||
| const hashesInOrder = new Set(); | ||
@@ -342,3 +347,3 @@ for (const hash of hashToAssets.keys()) { | ||
| Array.from( | ||
| /** @type {ReferencedHashes} */ (asset.referencedHashes), | ||
| /** @type {Hashes} */ (asset.referencedHashes), | ||
| (hash) => hashToNewHash.get(hash) | ||
@@ -355,6 +360,6 @@ ).join("|") | ||
| if ( | ||
| /** @type {OwnHashes} */ (asset.ownHashes).size > 0 || | ||
| [ | ||
| .../** @type {ReferencedHashes} */ (asset.referencedHashes) | ||
| ].some((hash) => hashToNewHash.get(hash) !== hash) | ||
| /** @type {Hashes} */ (asset.ownHashes).size > 0 || | ||
| [.../** @type {Hashes} */ (asset.referencedHashes)].some( | ||
| (hash) => hashToNewHash.get(hash) !== hash | ||
| ) | ||
| ) { | ||
@@ -387,6 +392,6 @@ const identifier = asset.name; | ||
| if ( | ||
| /** @type {OwnHashes} */ (asset.ownHashes).size > 0 || | ||
| [ | ||
| .../** @type {ReferencedHashes} */ (asset.referencedHashes) | ||
| ].some((hash) => hashToNewHash.get(hash) !== hash) | ||
| /** @type {Hashes} */ (asset.ownHashes).size > 0 || | ||
| [.../** @type {Hashes} */ (asset.referencedHashes)].some( | ||
| (hash) => hashToNewHash.get(hash) !== hash | ||
| ) | ||
| ) { | ||
@@ -403,3 +408,3 @@ const identifier = `${asset.name}|without-own`; | ||
| if ( | ||
| /** @type {OwnHashes} */ | ||
| /** @type {Hashes} */ | ||
| (asset.ownHashes).has(hash) | ||
@@ -418,2 +423,3 @@ ) { | ||
| }; | ||
| /** @type {Comparator<AssetInfoForRealContentHash>} */ | ||
| const comparator = compareSelect((a) => a.name, compareStrings); | ||
@@ -427,3 +433,3 @@ for (const oldHash of hashesInOrder) { | ||
| assets.map((asset) => | ||
| /** @type {OwnHashes} */ (asset.ownHashes).has(oldHash) | ||
| /** @type {Hashes} */ (asset.ownHashes).has(oldHash) | ||
| ? computeNewContentWithoutOwn(asset) | ||
@@ -434,3 +440,3 @@ : computeNewContent(asset) | ||
| const assetsContent = mapAndDeduplicateBuffers(assets, (asset) => { | ||
| if (/** @type {OwnHashes} */ (asset.ownHashes).has(oldHash)) { | ||
| if (/** @type {Hashes} */ (asset.ownHashes).has(oldHash)) { | ||
| return asset.newSourceWithoutOwn | ||
@@ -467,3 +473,5 @@ ? asset.newSourceWithoutOwn.buffer() | ||
| const infoUpdate = {}; | ||
| const hash = /** @type {string} */ (asset.info.contenthash); | ||
| const hash = | ||
| /** @type {Exclude<AssetInfo["contenthash"], undefined>} */ | ||
| (asset.info.contenthash); | ||
| infoUpdate.contenthash = Array.isArray(hash) | ||
@@ -470,0 +478,0 @@ ? hash.map( |
@@ -36,3 +36,3 @@ /* | ||
| * @param {Module[]} ordinalModules the modules in the order they were added to the mask (LSB is index 0) | ||
| * @returns {Generator<Module>} the modules represented by the mask | ||
| * @returns {Generator<Module, undefined, undefined>} the modules represented by the mask | ||
| */ | ||
@@ -78,6 +78,9 @@ function* getModulesFromMask(mask, ordinalModules) { | ||
| const chunkGraph = compilation.chunkGraph; | ||
| /** @type {Set<ChunkGroup>} */ | ||
| const queue = new Set(); | ||
| /** @type {WeakMap<ChunkGroup, bigint | undefined>} */ | ||
| const availableModulesMap = new WeakMap(); | ||
| let nextModuleMask = ONE_BIGINT; | ||
| /** @type {WeakMap<Module, bigint>} */ | ||
| const maskByModule = new WeakMap(); | ||
@@ -104,2 +107,3 @@ /** @type {Module[]} */ | ||
| // Initialize masks by chunk and by chunk group for quicker comparisons | ||
| /** @type {WeakMap<Chunk, bigint>} */ | ||
| const chunkMasks = new WeakMap(); | ||
@@ -115,2 +119,3 @@ for (const chunk of chunks) { | ||
| /** @type {WeakMap<ChunkGroup, bigint>} */ | ||
| const chunkGroupMasks = new WeakMap(); | ||
@@ -150,3 +155,4 @@ for (const chunkGroup of chunkGroups) { | ||
| const parentMask = | ||
| availableModulesInParent | chunkGroupMasks.get(parent); | ||
| availableModulesInParent | | ||
| /** @type {bigint} */ (chunkGroupMasks.get(parent)); | ||
| // If we know the available modules in parent: process these | ||
@@ -189,3 +195,6 @@ if (availableModulesMask === undefined) { | ||
| const availableModulesMask = intersectMasks(availableModulesSets); | ||
| const availableModulesMask = intersectMasks( | ||
| /** @type {bigint[]} */ | ||
| (availableModulesSets) | ||
| ); | ||
| const toRemoveMask = chunkMask & availableModulesMask; | ||
@@ -192,0 +201,0 @@ if (toRemoveMask !== ZERO_BIGINT) { |
@@ -71,2 +71,3 @@ /* | ||
| constructor(analyseSource = true) { | ||
| /** @type {boolean} */ | ||
| this._analyseSource = analyseSource; | ||
@@ -281,2 +282,3 @@ } | ||
| /** @type {Set<Module>} */ | ||
| const optimizedModules = new Set(); | ||
@@ -296,2 +298,3 @@ | ||
| const dep = connection.dependency; | ||
| /** @type {boolean} */ | ||
| let isReexport; | ||
@@ -298,0 +301,0 @@ if ( |
@@ -39,2 +39,3 @@ /* | ||
| /** @typedef {import("../util/deterministicGrouping").Options<Module>} DeterministicGroupingOptionsForModule */ | ||
| /** @typedef {import("../util/deterministicGrouping").Sizes} Sizes */ | ||
@@ -224,5 +225,6 @@ /** | ||
| const mapObject = (obj, fn) => { | ||
| /** @type {T} */ | ||
| const newObj = Object.create(null); | ||
| for (const key of Object.keys(obj)) { | ||
| newObj[key] = fn( | ||
| newObj[/** @type {keyof T} */ (key)] = fn( | ||
| obj[/** @type {keyof T} */ (key)], | ||
@@ -483,2 +485,3 @@ /** @type {keyof T} */ | ||
| } else if (typeof option === "function") { | ||
| /** @type {WeakMap<OptimizationSplitChunksCacheGroup, CacheGroupSource>} */ | ||
| const cache = new WeakMap(); | ||
@@ -874,3 +877,3 @@ handlers.push((module, context, results) => { | ||
| /** | ||
| * @param {Iterable<Chunk>} chunks list of chunks | ||
| * @param {Iterable<Chunk, undefined, undefined>} chunks list of chunks | ||
| * @returns {bigint | Chunk} key of the chunks | ||
@@ -928,2 +931,3 @@ */ | ||
| const exportsInfo = moduleGraph.getExportsInfo(module); | ||
| /** @type {Map<string, Chunk[]>} */ | ||
| const groupedByUsedExports = new Map(); | ||
@@ -1090,3 +1094,4 @@ for (const chunk of chunkGraph.getModuleChunksIterable(module)) { | ||
| /** @type {WeakMap<ChunkSet | Chunk, WeakMap<ChunkFilterFn, SelectedChunksResult>>} */ | ||
| /** @typedef {WeakMap<ChunkFilterFn, SelectedChunksResult>} ChunkMap */ | ||
| /** @type {WeakMap<ChunkSet | Chunk, ChunkMap>} */ | ||
| const selectedChunksCacheByChunksSet = new WeakMap(); | ||
@@ -1104,2 +1109,3 @@ | ||
| if (entry === undefined) { | ||
| /** @type {ChunkMap} */ | ||
| entry = new WeakMap(); | ||
@@ -1402,3 +1408,5 @@ selectedChunksCacheByChunksSet.set(chunks, entry); | ||
| // Find best matching entry | ||
| /** @type {undefined | string} */ | ||
| let bestEntryKey; | ||
| /** @type {undefined | ChunksInfoItem} */ | ||
| let bestEntry; | ||
@@ -1482,2 +1490,3 @@ for (const pair of chunksInfoMap) { | ||
| /** @type {Set<Chunk>} */ | ||
| const usedChunks = new Set(item.chunks); | ||
@@ -1545,2 +1554,3 @@ | ||
| const [chunk] = usedChunks; | ||
| /** @type {SplitChunksSizes} */ | ||
| const chunkSizes = Object.create(null); | ||
@@ -1776,2 +1786,3 @@ for (const module of chunkGraph.getChunkModulesIterable(chunk)) { | ||
| getSize(module) { | ||
| /** @type {Sizes} */ | ||
| const size = Object.create(null); | ||
@@ -1778,0 +1789,0 @@ for (const key of module.getSourceTypes()) { |
@@ -9,2 +9,3 @@ /* | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./config/normalization").WebpackOptionsInterception} WebpackOptionsInterception */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
@@ -16,5 +17,6 @@ | ||
| * @param {Compiler} compiler compiler object | ||
| * @param {WebpackOptionsInterception=} interception intercepted options | ||
| * @returns {WebpackOptions} options object | ||
| */ | ||
| process(options, compiler) { | ||
| process(options, compiler, interception) { | ||
| return options; | ||
@@ -21,0 +23,0 @@ } |
@@ -13,3 +13,3 @@ /* | ||
| module.exports = class AssetsOverSizeLimitWarning extends WebpackError { | ||
| class AssetsOverSizeLimitWarning extends WebpackError { | ||
| /** | ||
@@ -30,5 +30,9 @@ * @param {AssetDetails[]} assetsOverSizeLimit the assets | ||
| /** @type {string} */ | ||
| this.name = "AssetsOverSizeLimitWarning"; | ||
| this.assets = assetsOverSizeLimit; | ||
| } | ||
| }; | ||
| } | ||
| /** @type {typeof AssetsOverSizeLimitWarning} */ | ||
| module.exports = AssetsOverSizeLimitWarning; |
@@ -13,3 +13,3 @@ /* | ||
| module.exports = class EntrypointsOverSizeLimitWarning extends WebpackError { | ||
| class EntrypointsOverSizeLimitWarning extends WebpackError { | ||
| /** | ||
@@ -33,5 +33,9 @@ * @param {EntrypointDetails[]} entrypoints the entrypoints | ||
| /** @type {string} */ | ||
| this.name = "EntrypointsOverSizeLimitWarning"; | ||
| this.entrypoints = entrypoints; | ||
| } | ||
| }; | ||
| } | ||
| /** @type {typeof EntrypointsOverSizeLimitWarning} */ | ||
| module.exports = EntrypointsOverSizeLimitWarning; |
@@ -18,4 +18,5 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "NoAsyncChunksWarning"; | ||
| } | ||
| }; |
@@ -238,2 +238,3 @@ /* | ||
| let doneEntries = 0; | ||
| /** @type {Set<string>} */ | ||
| const activeModules = new Set(); | ||
@@ -258,2 +259,3 @@ let lastUpdate = 0; | ||
| Math.max(lastDependenciesCount || 1, dependenciesCount); | ||
| /** @type {number} */ | ||
| let percentageFactor; | ||
@@ -290,2 +292,3 @@ | ||
| } else { | ||
| /** @type {string[]} */ | ||
| const statItems = []; | ||
@@ -486,2 +489,3 @@ if (showEntries) { | ||
| if (typeof __webpack_require__ !== "function") { | ||
| /** @type {Set<string>} */ | ||
| const requiredLoaders = new Set(); | ||
@@ -488,0 +492,0 @@ NormalModule.getCompilationHooks(compilation).beforeLoaders.tap( |
+2
-0
@@ -27,2 +27,3 @@ /* | ||
| /** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */ | ||
| /** @typedef {import("./Module").Sources} Sources */ | ||
| /** @typedef {import("./ModuleGraph")} ModuleGraph */ | ||
@@ -126,2 +127,3 @@ /** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */ | ||
| codeGeneration(context) { | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -128,0 +130,0 @@ if (this.useSourceMap || this.useSimpleSourceMap) { |
@@ -27,3 +27,5 @@ /* | ||
| constructor(ruleProperty, effectType) { | ||
| /** @type {BasicEffectRuleKeys} */ | ||
| this.ruleProperty = ruleProperty; | ||
| /** @type {string | BasicEffectRuleKeys} */ | ||
| this.effectType = effectType || ruleProperty; | ||
@@ -30,0 +32,0 @@ } |
@@ -30,4 +30,7 @@ /* | ||
| constructor(ruleProperty, dataProperty, invert) { | ||
| /** @type {BasicMatcherRuleKeys} */ | ||
| this.ruleProperty = ruleProperty; | ||
| /** @type {string | BasicMatcherRuleKeys} */ | ||
| this.dataProperty = dataProperty || ruleProperty; | ||
| /** @type {boolean} */ | ||
| this.invert = invert || false; | ||
@@ -34,0 +37,0 @@ } |
@@ -21,2 +21,3 @@ /* | ||
| /** @typedef {KeysOfTypes<RuleSetRule, { [k: string]: RuleSetConditionOrConditions }>} ObjectMatcherRuleKeys */ | ||
| /** @typedef {keyof EffectData} DataProperty */ | ||
@@ -28,8 +29,11 @@ const PLUGIN_NAME = "ObjectMatcherRulePlugin"; | ||
| * @param {ObjectMatcherRuleKeys} ruleProperty the rule property | ||
| * @param {keyof EffectData=} dataProperty the data property | ||
| * @param {DataProperty=} dataProperty the data property | ||
| * @param {RuleConditionFunction=} additionalConditionFunction need to check | ||
| */ | ||
| constructor(ruleProperty, dataProperty, additionalConditionFunction) { | ||
| /** @type {ObjectMatcherRuleKeys} */ | ||
| this.ruleProperty = ruleProperty; | ||
| /** @type {DataProperty | ObjectMatcherRuleKeys} */ | ||
| this.dataProperty = dataProperty || ruleProperty; | ||
| /** @type {RuleConditionFunction | undefined} */ | ||
| this.additionalConditionFunction = additionalConditionFunction; | ||
@@ -36,0 +40,0 @@ } |
@@ -119,2 +119,3 @@ /* | ||
| compile(ruleSet) { | ||
| /** @type {References} */ | ||
| const refs = new Map(); | ||
@@ -331,2 +332,3 @@ const rules = this.compileRules("ruleSet", ruleSet, refs); | ||
| /** @type {Condition[]} */ | ||
| const conditions = []; | ||
@@ -333,0 +335,0 @@ for (const key of Object.keys(condition)) { |
@@ -19,2 +19,3 @@ /* | ||
| super("async module"); | ||
| /** @type {boolean} */ | ||
| this._deferInterop = deferInterop; | ||
@@ -21,0 +22,0 @@ } |
@@ -16,2 +16,3 @@ /* | ||
| super("chunkName"); | ||
| /** @type {string} */ | ||
| this.chunkName = chunkName; | ||
@@ -18,0 +19,0 @@ } |
@@ -17,2 +17,3 @@ /* | ||
| super("compat", RuntimeModule.STAGE_ATTACH); | ||
| /** @type {boolean} */ | ||
| this.fullHash = true; | ||
@@ -19,0 +20,0 @@ } |
@@ -20,2 +20,3 @@ /* | ||
| super("ensure chunk"); | ||
| /** @type {ReadOnlyRuntimeRequirements} */ | ||
| this.runtimeRequirements = runtimeRequirements; | ||
@@ -22,0 +23,0 @@ } |
@@ -29,6 +29,10 @@ /* | ||
| super(`get ${name} chunk filename`); | ||
| /** @type {string} */ | ||
| this.contentType = contentType; | ||
| /** @type {string} */ | ||
| this.global = global; | ||
| this.getFilenameForChunk = getFilenameForChunk; | ||
| /** @type {boolean} */ | ||
| this.allChunks = allChunks; | ||
| /** @type {boolean} */ | ||
| this.dependentHash = true; | ||
@@ -35,0 +39,0 @@ } |
@@ -22,3 +22,5 @@ /* | ||
| super(`get ${name} filename`); | ||
| /** @type {string} */ | ||
| this.global = global; | ||
| /** @type {string} */ | ||
| this.filename = filename; | ||
@@ -25,0 +27,0 @@ } |
@@ -20,2 +20,3 @@ /* | ||
| super("trusted types policy"); | ||
| /** @type {ReadOnlyRuntimeRequirements} */ | ||
| this.runtimeRequirements = runtimeRequirements; | ||
@@ -22,0 +23,0 @@ } |
@@ -50,3 +50,5 @@ /* | ||
| super("load script"); | ||
| /** @type {boolean | undefined} */ | ||
| this._withCreateScriptUrl = withCreateScriptUrl; | ||
| /** @type {boolean | undefined} */ | ||
| this._withFetchPriority = withFetchPriority; | ||
@@ -53,0 +55,0 @@ } |
@@ -20,7 +20,8 @@ /* | ||
| function getMakeDeferredNamespaceModeFromExportsType(exportsType) { | ||
| if (exportsType === "namespace") return `/* ${exportsType} */ 0`; | ||
| if (exportsType === "default-only") return `/* ${exportsType} */ 1`; | ||
| // number is from createFakeNamespaceObject mode ^ 1 | ||
| if (exportsType === "namespace") return `/* ${exportsType} */ 8`; | ||
| if (exportsType === "default-only") return `/* ${exportsType} */ 0`; | ||
| if (exportsType === "default-with-named") return `/* ${exportsType} */ 2`; | ||
| if (exportsType === "dynamic") return `/* ${exportsType} */ 3`; | ||
| return ""; | ||
| if (exportsType === "dynamic") return `/* ${exportsType} */ 6`; | ||
| throw new Error(`Unknown exports type: ${exportsType}`); | ||
| } | ||
@@ -56,2 +57,3 @@ | ||
| super("make optimized deferred namespace object"); | ||
| /** @type {boolean} */ | ||
| this.hasAsyncRuntime = hasAsyncRuntime; | ||
@@ -71,6 +73,2 @@ } | ||
| Template.indent([ | ||
| "// mode: 0 => namespace (esm)", | ||
| "// mode: 1 => default-only (esm strict cjs)", | ||
| "// mode: 2 => default-with-named (esm-cjs compat)", | ||
| "// mode: 3 => dynamic (if exports has __esModule, then esm, otherwise default-with-named)", | ||
| "var r = this;", | ||
@@ -89,3 +87,3 @@ hasAsync ? "var isAsync = asyncDeps && asyncDeps.length;" : "", | ||
| // we can also do this if exportsType is "dynamic" and there is a "__esModule" property on it. | ||
| 'if(mode == 0 || (mode == 3 && exports.__esModule)) Object.defineProperty(this, "a", { value: exports });', | ||
| 'if(mode & 8 || (mode & 4 && exports.__esModule)) Object.defineProperty(this, "a", { value: exports });', | ||
| "return exports;" | ||
@@ -127,7 +125,2 @@ ]), | ||
| return `${fn} = ${runtimeTemplate.basicFunction("moduleId, mode", [ | ||
| "// mode: 0 => namespace (esm)", | ||
| "// mode: 1 => default-only (esm strict cjs)", | ||
| "// mode: 2 => default-with-named (esm-cjs compat)", | ||
| "// mode: 3 => dynamic (if exports has __esModule, then esm, otherwise default-with-named)", | ||
| "", | ||
| "var cachedModule = __webpack_module_cache__[moduleId];", | ||
@@ -140,6 +133,4 @@ "if (cachedModule && cachedModule.error === undefined) {", | ||
| : "", | ||
| "if (mode == 0) return exports;", | ||
| `if (mode == 1) return ${RuntimeGlobals.createFakeNamespaceObject}(exports);`, | ||
| `if (mode == 2) return ${RuntimeGlobals.createFakeNamespaceObject}(exports, 2);`, | ||
| `if (mode == 3) return ${RuntimeGlobals.createFakeNamespaceObject}(exports, 6);` // 2 | 4 | ||
| "if (mode & 8) return exports;", | ||
| `return ${RuntimeGlobals.createFakeNamespaceObject}(exports, mode);` | ||
| ]), | ||
@@ -154,3 +145,3 @@ "}", | ||
| "init = null;", | ||
| "if (mode == 0 || mode == 3 && ns.__esModule && typeof ns === 'object') {", | ||
| "if (mode & 8 || mode & 4 && ns.__esModule && typeof ns === 'object') {", | ||
| Template.indent([ | ||
@@ -165,14 +156,6 @@ "delete handler.defineProperty;", | ||
| ]), | ||
| "} else if (mode == 1) {", | ||
| "} else {", | ||
| Template.indent([ | ||
| `ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns);` | ||
| `ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns, mode);` | ||
| ]), | ||
| "} else if (mode == 2) {", | ||
| Template.indent([ | ||
| `ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns, 2);` | ||
| ]), | ||
| "} else if (mode == 3) {", | ||
| Template.indent([ | ||
| `ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns, 6);` | ||
| ]), | ||
| "}" | ||
@@ -222,4 +205,4 @@ ])};`, | ||
| Template.indent([ | ||
| 'case "__esModule": return { value: true, configurable: !!mode };', | ||
| 'case Symbol.toStringTag: return { value: "Deferred Module", configurable: !!mode };', | ||
| 'case "__esModule": return { value: true, configurable: !(mode & 8) };', | ||
| 'case Symbol.toStringTag: return { value: "Deferred Module", configurable: !(mode & 8) };', | ||
| 'case "then": return undefined;' | ||
@@ -230,3 +213,3 @@ ]), | ||
| "var desc = Reflect.getOwnPropertyDescriptor(ns, name);", | ||
| 'if (mode == 2 && name == "default" && !desc) {', | ||
| 'if (mode & 2 && name == "default" && !desc) {', | ||
| Template.indent("desc = { value: ns, configurable: true };"), | ||
@@ -233,0 +216,0 @@ "}", |
@@ -19,2 +19,3 @@ /* | ||
| super("publicPath", RuntimeModule.STAGE_BASIC); | ||
| /** @type {PublicPath} */ | ||
| this.publicPath = publicPath; | ||
@@ -21,0 +22,0 @@ } |
@@ -28,3 +28,5 @@ /* | ||
| constructor(options) { | ||
| /** @type {ChunkLoadingType} */ | ||
| this.chunkLoading = options.chunkLoading; | ||
| /** @type {boolean} */ | ||
| this.asyncChunkLoading = | ||
@@ -31,0 +33,0 @@ typeof options.asyncChunkLoading === "boolean" |
@@ -22,2 +22,3 @@ /* | ||
| super("startup chunk dependencies", RuntimeModule.STAGE_TRIGGER); | ||
| /** @type {boolean} */ | ||
| this.asyncChunkLoading = asyncChunkLoading; | ||
@@ -24,0 +25,0 @@ } |
@@ -18,2 +18,3 @@ /* | ||
| super("startup entrypoint"); | ||
| /** @type {boolean} */ | ||
| this.asyncChunkLoading = asyncChunkLoading; | ||
@@ -20,0 +21,0 @@ } |
+10
-0
@@ -20,2 +20,4 @@ /* | ||
| /** @typedef {import("./Generator").SourceTypes} SourceTypes */ | ||
| /** @typedef {import("./Module").BuildMeta} BuildMeta */ | ||
| /** @typedef {import("./Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("./Module").BuildCallback} BuildCallback */ | ||
@@ -26,2 +28,3 @@ /** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */ | ||
| /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("./Module").Sources} Sources */ | ||
| /** @typedef {import("./RequestShortener")} RequestShortener */ | ||
@@ -39,5 +42,9 @@ /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| super(WEBPACK_MODULE_TYPE_RUNTIME); | ||
| /** @type {string} */ | ||
| this.name = name; | ||
| /** @type {number} */ | ||
| this.stage = stage; | ||
| /** @type {BuildMeta} */ | ||
| this.buildMeta = {}; | ||
| /** @type {BuildInfo} */ | ||
| this.buildInfo = {}; | ||
@@ -50,3 +57,5 @@ /** @type {Compilation | undefined} */ | ||
| this.chunkGraph = undefined; | ||
| /** @type {boolean} */ | ||
| this.fullHash = false; | ||
| /** @type {boolean} */ | ||
| this.dependentHash = false; | ||
@@ -141,2 +150,3 @@ /** @type {string | undefined | null} */ | ||
| codeGeneration(context) { | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -143,0 +153,0 @@ const generatedCode = this.getGeneratedCode(); |
@@ -114,2 +114,4 @@ /* | ||
| const FULLHASH_REGEXP = /\[(?:full)?hash(?::\d+)?\]/; | ||
| const PLUGIN_NAME = "RuntimePlugin"; | ||
@@ -270,3 +272,3 @@ | ||
| typeof publicPath !== "string" || | ||
| /\[(full)?hash\]/.test(publicPath) | ||
| /\[(?:full)?hash\]/.test(publicPath) | ||
| ) { | ||
@@ -319,5 +321,3 @@ module.fullHash = true; | ||
| typeof compilation.outputOptions.chunkFilename === "string" && | ||
| /\[(full)?hash(:\d+)?\]/.test( | ||
| compilation.outputOptions.chunkFilename | ||
| ) | ||
| FULLHASH_REGEXP.test(compilation.outputOptions.chunkFilename) | ||
| ) { | ||
@@ -348,5 +348,3 @@ set.add(RuntimeGlobals.getFullHash); | ||
| typeof compilation.outputOptions.cssChunkFilename === "string" && | ||
| /\[(full)?hash(:\d+)?\]/.test( | ||
| compilation.outputOptions.cssChunkFilename | ||
| ) | ||
| FULLHASH_REGEXP.test(compilation.outputOptions.cssChunkFilename) | ||
| ) { | ||
@@ -381,3 +379,3 @@ set.add(RuntimeGlobals.getFullHash); | ||
| if ( | ||
| /\[(full)?hash(:\d+)?\]/.test( | ||
| FULLHASH_REGEXP.test( | ||
| compilation.outputOptions.hotUpdateChunkFilename | ||
@@ -404,3 +402,3 @@ ) | ||
| if ( | ||
| /\[(full)?hash(:\d+)?\]/.test( | ||
| FULLHASH_REGEXP.test( | ||
| compilation.outputOptions.hotUpdateMainFilename | ||
@@ -407,0 +405,0 @@ ) |
@@ -87,3 +87,3 @@ /* | ||
| // expression in parentheses | ||
| /^([_\p{L}][_0-9\p{L}]*)?\(.*\)$/iu.test(trimmed) | ||
| /^(?:[_\p{L}][_0-9\p{L}]*)?\(.*\)$/iu.test(trimmed) | ||
| ) { | ||
@@ -360,2 +360,3 @@ return trimmed; | ||
| comment({ request, chunkName, chunkReason, message, exportName }) { | ||
| /** @type {string} */ | ||
| let content; | ||
@@ -683,2 +684,3 @@ if (this.outputOptions.pathinfo) { | ||
| /** @type {string} */ | ||
| let appending; | ||
@@ -717,3 +719,6 @@ let idExpr = JSON.stringify(chunkGraph.getModuleId(module)); | ||
| runtimeRequirements.add(RuntimeGlobals.makeDeferredNamespaceObject); | ||
| const mode = getMakeDeferredNamespaceModeFromExportsType(exportsType); | ||
| let mode = getMakeDeferredNamespaceModeFromExportsType(exportsType); | ||
| if (mode) mode = `${mode} | 16`; | ||
| const asyncDeps = Array.from( | ||
@@ -859,10 +864,10 @@ getOutgoingAsyncModules(chunkGraph.moduleGraph, module), | ||
| * @param {Module} options.module the module | ||
| * @param {Module} options.originModule module in which the statement is emitted | ||
| * @param {ModuleGraph} options.moduleGraph the module graph | ||
| * @param {ChunkGraph} options.chunkGraph the chunk graph | ||
| * @param {string} options.request the request that should be printed as comment | ||
| * @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements | ||
| * @param {string} options.importVar name of the import variable | ||
| * @param {Module} options.originModule module in which the statement is emitted | ||
| * @param {string=} options.request the request that should be printed as comment | ||
| * @param {boolean=} options.weak true, if this is a weak dependency | ||
| * @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements | ||
| * @param {ModuleDependency} options.dependency module dependency | ||
| * @param {ModuleDependency=} options.dependency module dependency | ||
| * @returns {[string, string]} the import statement and the compat statement | ||
@@ -926,2 +931,4 @@ */ | ||
| runtimeRequirements.add(RuntimeGlobals.require); | ||
| /** @type {string} */ | ||
| let importContent; | ||
@@ -970,3 +977,3 @@ | ||
| * @param {boolean | undefined} options.asiSafe true, if location is safe for ASI, a bracket can be emitted | ||
| * @param {boolean} options.isCall true, if expression will be called | ||
| * @param {boolean | undefined} options.isCall true, if expression will be called | ||
| * @param {boolean | null} options.callContext when false, call context will not be preserved | ||
@@ -973,0 +980,0 @@ * @param {boolean} options.defaultInterop when true and accessing the default exports, interop code will be generated |
@@ -39,8 +39,16 @@ /* | ||
| /** @typedef {(url: URL, requestOptions: RequestOptions, callback: (incomingMessage: IncomingMessage) => void) => EventEmitter} Fetch */ | ||
| /** | ||
| * @typedef {object} EventsMap | ||
| * @property {[Error]} error | ||
| */ | ||
| /** | ||
| * @param {typeof import("http") | typeof import("https")} request request | ||
| * @param {string | URL | undefined} proxy proxy | ||
| * @returns {(url: URL, requestOptions: RequestOptions, callback: (incomingMessage: IncomingMessage) => void) => EventEmitter} fn | ||
| * @returns {Fetch} fn | ||
| */ | ||
| const proxyFetch = (request, proxy) => (url, options, callback) => { | ||
| /** @type {EventEmitter<EventsMap>} */ | ||
| const eventEmitter = new EventEmitter(); | ||
@@ -108,5 +116,3 @@ | ||
| const toSafePath = (str) => | ||
| str | ||
| .replace(/^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$/g, "") | ||
| .replace(/[^a-zA-Z0-9._-]+/g, "_"); | ||
| str.replace(/^[^a-z0-9]+|[^a-z0-9]+$/gi, "").replace(/[^a-z0-9._-]+/gi, "_"); | ||
@@ -459,2 +465,5 @@ /** | ||
| this._proxy || process.env.http_proxy || process.env.HTTP_PROXY; | ||
| /** | ||
| * @type {{ scheme: "http" | "https", fetch: Fetch }[]} | ||
| */ | ||
| const schemes = [ | ||
@@ -666,2 +675,3 @@ { | ||
| const validateRedirectLocation = (location, base) => { | ||
| /** @type {URL} */ | ||
| let nextUrl; | ||
@@ -714,2 +724,3 @@ try { | ||
| // Validate redirect target before following | ||
| /** @type {string} */ | ||
| let absolute; | ||
@@ -853,2 +864,3 @@ try { | ||
| ) { | ||
| /** @type {string} */ | ||
| let absolute; | ||
@@ -900,5 +912,11 @@ try { | ||
| stream.on("data", (chunk) => { | ||
| bufferArr.push(chunk); | ||
| }); | ||
| stream.on( | ||
| "data", | ||
| /** | ||
| * @param {Buffer} chunk chunk | ||
| */ | ||
| (chunk) => { | ||
| bufferArr.push(chunk); | ||
| } | ||
| ); | ||
@@ -963,2 +981,3 @@ stream.on("end", () => { | ||
| const isAllowed = (uri) => { | ||
| /** @type {URL} */ | ||
| let parsedUri; | ||
@@ -974,2 +993,3 @@ try { | ||
| if (typeof allowed === "string") { | ||
| /** @type {URL} */ | ||
| let parsedAllowed; | ||
@@ -976,0 +996,0 @@ try { |
@@ -61,2 +61,4 @@ /* | ||
| /** @typedef {{ [key: string]: VirtualModuleConfig }} NormalizedModules */ | ||
| /** | ||
@@ -66,3 +68,3 @@ * Normalizes all virtual modules with the given scheme | ||
| * @param {string} scheme The URL scheme to use | ||
| * @returns {{ [key: string]: VirtualModuleConfig }} The normalized virtual modules | ||
| * @returns {NormalizedModules} The normalized virtual modules | ||
| */ | ||
@@ -73,3 +75,3 @@ function normalizeModules(virtualConfigs, scheme) { | ||
| return pre; | ||
| }, /** @type {{ [key: string]: VirtualModuleConfig }} */ ({})); | ||
| }, /** @type {NormalizedModules} */ ({})); | ||
| } | ||
@@ -111,3 +113,5 @@ | ||
| constructor(modules, scheme) { | ||
| /** @type {string} */ | ||
| this.scheme = scheme || DEFAULT_SCHEME; | ||
| /** @type {NormalizedModules} */ | ||
| this.modules = normalizeModules(modules, this.scheme); | ||
@@ -142,2 +146,3 @@ } | ||
| resourceData.resource = path; | ||
| resourceData.context = compiler.context; | ||
@@ -144,0 +149,0 @@ if (virtualConfig.version) { |
@@ -316,2 +316,3 @@ /* | ||
| for (const item of serializedData) { | ||
| /** @type {undefined | number} */ | ||
| let last; | ||
@@ -494,4 +495,6 @@ if (typeof item === "function") { | ||
| let lastByte = thing === true ? 1 : 0; | ||
| /** @type {number[]} */ | ||
| const bytes = []; | ||
| let count = 1; | ||
| /** @type {undefined | number} */ | ||
| let n; | ||
@@ -546,2 +549,3 @@ for (n = 1; n < 0xffffffff && i + n < data.length; n++) { | ||
| if (thing === null) { | ||
| /** @type {number} */ | ||
| let n; | ||
@@ -548,0 +552,0 @@ for (n = 1; n < 0x100000104 && i + n < data.length; n++) { |
@@ -24,3 +24,3 @@ /* | ||
| /** @typedef {typeof import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/Hash").HashFunction} HashFunction */ | ||
| /** @typedef {import("../util/fs").IStats} IStats */ | ||
@@ -53,3 +53,3 @@ /** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */ | ||
| * @param {Buffer[]} buffers buffers | ||
| * @param {string | Hash} hashFunction hash function to use | ||
| * @param {HashFunction} hashFunction hash function to use | ||
| * @returns {string} hash | ||
@@ -106,3 +106,3 @@ */ | ||
| * @param {(name: string | false, buffers: Buffer[], size: number) => Promise<void>} writeFile writes a file | ||
| * @param {string | Hash} hashFunction hash function to use | ||
| * @param {HashFunction=} hashFunction hash function to use | ||
| * @returns {Promise<SerializeResult>} resulting file pointer and promise | ||
@@ -342,2 +342,3 @@ */ | ||
| const sectionCount = readUInt32LE(); | ||
| /** @type {number[]} */ | ||
| const lengths = []; | ||
@@ -440,7 +441,9 @@ let lastLengthPositive = false; | ||
| * @param {IntermediateFileSystem} fs filesystem | ||
| * @param {string | Hash} hashFunction hash function to use | ||
| * @param {HashFunction} hashFunction hash function to use | ||
| */ | ||
| constructor(fs, hashFunction = DEFAULTS.HASH_FUNCTION) { | ||
| super(); | ||
| /** @type {IntermediateFileSystem} */ | ||
| this.fs = fs; | ||
| /** @type {HashFunction} */ | ||
| this._hashFunction = hashFunction; | ||
@@ -462,2 +465,3 @@ } | ||
| // because serialize may read existing files (when deserializing) | ||
| /** @type {Set<string>} */ | ||
| const allWrittenFiles = new Set(); | ||
@@ -481,2 +485,3 @@ /** | ||
| let stream = this.fs.createWriteStream(`${file}_`); | ||
| /** @type {undefined | import("zlib").Gzip | import("zlib").BrotliCompress} */ | ||
| let compression; | ||
@@ -483,0 +488,0 @@ if (file.endsWith(".gz")) { |
@@ -21,3 +21,3 @@ /* | ||
| /** @typedef {import("../logging/Logger").Logger} Logger */ | ||
| /** @typedef {typeof import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/Hash").HashFunction} HashFunction */ | ||
| /** @typedef {import("./SerializerMiddleware").LazyOptions} LazyOptions */ | ||
@@ -115,3 +115,3 @@ /** @typedef {import("./types").ComplexSerializableType} ComplexSerializableType */ | ||
| * @param {Buffer} buffer buffer | ||
| * @param {string | Hash} hashFunction hash function to use | ||
| * @param {HashFunction} hashFunction hash function to use | ||
| * @returns {string} hash | ||
@@ -212,2 +212,4 @@ */ | ||
| /** @typedef {(context: ObjectSerializerContext | ObjectDeserializerContext) => void} ExtendContext */ | ||
| /** | ||
@@ -218,8 +220,10 @@ * @extends {SerializerMiddleware<DeserializedType, SerializedType, Context>} | ||
| /** | ||
| * @param {(context: ObjectSerializerContext | ObjectDeserializerContext) => void} extendContext context extensions | ||
| * @param {string | Hash} hashFunction hash function to use | ||
| * @param {ExtendContext} extendContext context extensions | ||
| * @param {HashFunction} hashFunction hash function to use | ||
| */ | ||
| constructor(extendContext, hashFunction = DEFAULTS.HASH_FUNCTION) { | ||
| super(); | ||
| /** @type {ExtendContext} */ | ||
| this.extendContext = extendContext; | ||
| /** @type {HashFunction} */ | ||
| this._hashFunction = hashFunction; | ||
@@ -283,3 +287,3 @@ } | ||
| /** | ||
| * @param {Constructor} object for serialization | ||
| * @param {EXPECTED_ANY} object for serialization | ||
| * @returns {SerializerConfigWithSerializer} Serializer config | ||
@@ -289,2 +293,3 @@ */ | ||
| const proto = Object.getPrototypeOf(object); | ||
| /** @type {null | Constructor} */ | ||
| let c; | ||
@@ -304,3 +309,7 @@ if (proto === null) { | ||
| if (!config) throw new Error(`No serializer registered for ${c.name}`); | ||
| if (!config) { | ||
| throw new Error( | ||
| `No serializer registered for ${/** @type {Constructor} */ (c).name}` | ||
| ); | ||
| } | ||
| if (config === NOT_SERIALIZABLE) throw NOT_SERIALIZABLE; | ||
@@ -355,2 +364,3 @@ | ||
| }; | ||
| /** @type {Map<number, Buffer | [Buffer, Buffer] | Map<string, Buffer>>} */ | ||
| let bufferDedupeMap = new Map(); | ||
@@ -377,2 +387,3 @@ /** | ||
| const hash = toHash(entry, this._hashFunction); | ||
| /** @type {Map<string, Buffer>} */ | ||
| const newMap = new Map(); | ||
@@ -396,4 +407,6 @@ newMap.set(hash, entry); | ||
| } | ||
| /** @type {Map<string, Buffer>} */ | ||
| const newMap = new Map(); | ||
| const hash = toHash(buf, this._hashFunction); | ||
| /** @type {undefined | Buffer} */ | ||
| let found; | ||
@@ -421,3 +434,5 @@ for (const item of entry) { | ||
| let currentPosTypeLookup = 0; | ||
| /** @type {Map<ComplexSerializableType, number>} */ | ||
| let objectTypeLookup = new Map(); | ||
| /** @type {Set<ComplexSerializableType>} */ | ||
| const cycleStack = new Set(); | ||
@@ -455,8 +470,14 @@ /** | ||
| } | ||
| if (item.constructor === Map) return `Map { ${item.size} items }`; | ||
| if (item.constructor === Map) { | ||
| return `Map { ${/** @type {Map<EXPECTED_ANY, EXPECTED_ANY>} */ (item).size} items }`; | ||
| } | ||
| if (item.constructor === Array) { | ||
| return `Array { ${item.length} items }`; | ||
| return `Array { ${/** @type {EXPECTED_ANY[]} */ (item).length} items }`; | ||
| } | ||
| if (item.constructor === Set) return `Set { ${item.size} items }`; | ||
| if (item.constructor === RegExp) return item.toString(); | ||
| if (item.constructor === Set) { | ||
| return `Set { ${/** @type {Set<EXPECTED_ANY>} */ (item).size} items }`; | ||
| } | ||
| if (item.constructor === RegExp) { | ||
| return /** @type {RegExp} */ (item).toString(); | ||
| } | ||
| return `${item.constructor.name}`; | ||
@@ -479,3 +500,3 @@ } | ||
| }; | ||
| /** @type {WeakSet<Error>} */ | ||
| /** @type {undefined | WeakSet<Error>} */ | ||
| let hasDebugInfoAttached; | ||
@@ -739,2 +760,3 @@ /** @type {ObjectSerializerContext} */ | ||
| const request = nextItem; | ||
| /** @type {undefined | ObjectSerializer} */ | ||
| let serializer; | ||
@@ -805,2 +827,3 @@ | ||
| // in the good case | ||
| /** @type {undefined | [Constructor | null, SerializerConfig]} */ | ||
| let serializerEntry; | ||
@@ -807,0 +830,0 @@ for (const entry of serializers) { |
@@ -23,3 +23,5 @@ /* | ||
| constructor() { | ||
| /** @type {undefined | keyof T[]} */ | ||
| this.keys = undefined; | ||
| /** @type {undefined | Map<keyof T, ObjectStructure<T>>} */ | ||
| this.children = undefined; | ||
@@ -26,0 +28,0 @@ } |
@@ -20,2 +20,5 @@ /* | ||
| /** @type {WeakMap<ModuleGraph, WeakMap<ConsumeSharedModule, Module | null>>} */ | ||
| const fallbackModuleCache = new WeakMap(); | ||
| /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
@@ -31,3 +34,6 @@ /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../Module").Sources} Sources */ | ||
| /** @typedef {import("../Module").SourceTypes} SourceTypes */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../Module").ExportsType} ExportsType */ | ||
| /** @typedef {import("../RequestShortener")} RequestShortener */ | ||
@@ -159,2 +165,53 @@ /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** | ||
| * @param {ModuleGraph} moduleGraph the module graph | ||
| * @returns {Module | null} fallback module | ||
| */ | ||
| _getFallbackModule(moduleGraph) { | ||
| let moduleCache = fallbackModuleCache.get(moduleGraph); | ||
| if (!moduleCache) { | ||
| moduleCache = new WeakMap(); | ||
| fallbackModuleCache.set(moduleGraph, moduleCache); | ||
| } | ||
| const cached = moduleCache.get(this); | ||
| if (cached !== undefined) { | ||
| return cached; | ||
| } | ||
| /** @type {undefined | null | Module} */ | ||
| let fallbackModule = null; | ||
| if (this.options.import) { | ||
| if (this.options.eager) { | ||
| const dep = this.dependencies[0]; | ||
| if (dep) { | ||
| fallbackModule = moduleGraph.getModule(dep); | ||
| } | ||
| } else { | ||
| const block = this.blocks[0]; | ||
| if (block && block.dependencies.length > 0) { | ||
| fallbackModule = moduleGraph.getModule(block.dependencies[0]); | ||
| } | ||
| } | ||
| } | ||
| moduleCache.set(this, fallbackModule); | ||
| return fallbackModule; | ||
| } | ||
| /** | ||
| * @param {ModuleGraph} moduleGraph the module graph | ||
| * @param {boolean | undefined} strict the importing module is strict | ||
| * @returns {ExportsType} export type | ||
| * "namespace": Exports is already a namespace object. namespace = exports. | ||
| * "dynamic": Check at runtime if __esModule is set. When set: namespace = { ...exports, default: exports }. When not set: namespace = { default: exports }. | ||
| * "default-only": Provide a namespace object with only default export. namespace = { default: exports } | ||
| * "default-with-named": Provide a namespace object with named and default export. namespace = { ...exports, default: exports } | ||
| */ | ||
| getExportsType(moduleGraph, strict) { | ||
| const fallbackModule = this._getFallbackModule(moduleGraph); | ||
| if (!fallbackModule) return "dynamic"; | ||
| return fallbackModule.getExportsType(moduleGraph, strict); | ||
| } | ||
| /** | ||
| * @param {string=} type the source type for which the size should be estimated | ||
@@ -192,2 +249,3 @@ * @returns {number} the estimated size of the module (must be non-zero) | ||
| } = this.options; | ||
| /** @type {undefined | string} */ | ||
| let fallbackCode; | ||
@@ -226,2 +284,3 @@ if (request) { | ||
| /** @type {string} */ | ||
| let fn; | ||
@@ -240,2 +299,3 @@ | ||
| const code = runtimeTemplate.returningFunction(`${fn}(${args.join(", ")})`); | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
@@ -242,0 +302,0 @@ sources.set("consume-shared", new RawSource(code)); |
@@ -29,2 +29,3 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Compilation").FileSystemDependencies} FileSystemDependencies */ | ||
| /** @typedef {import("../ResolverFactory").ResolveOptionsWithDependencyType} ResolveOptionsWithDependencyType */ | ||
@@ -163,3 +164,3 @@ /** @typedef {import("../util/semver").SemVerRange} SemVerRange */ | ||
| config.import && | ||
| /^(\.\.?(\/|$)|\/|[A-Za-z]:|\\\\)/.test(config.import); | ||
| /^(?:\.\.?(?:\/|$)|\/|[A-Z]:|\\\\)/i.test(config.import); | ||
| return Promise.all([ | ||
@@ -175,3 +176,3 @@ new Promise( | ||
| } | ||
| /** @typedef {ResolveContext} */ | ||
| /** @type {ResolveContext & { fileDependencies: FileSystemDependencies, contextDependencies: FileSystemDependencies, missingDependencies: FileSystemDependencies }} */ | ||
| const resolveContext = { | ||
@@ -221,3 +222,3 @@ fileDependencies: new LazySet(), | ||
| if (packageName === undefined) { | ||
| if (/^(\/|[A-Za-z]:|\\\\)/.test(request)) { | ||
| if (/^(?:\/|[A-Z]:|\\\\)/i.test(request)) { | ||
| // For relative or absolute requests we don't automatically use a packageName. | ||
@@ -228,3 +229,3 @@ // If wished one can specify one with the packageName option. | ||
| } | ||
| const match = /^((?:@[^\\/]+[\\/])?[^\\/]+)/.exec(request); | ||
| const match = /^(?:@[^\\/]+[\\/])?[^\\/]+/.exec(request); | ||
| if (!match) { | ||
@@ -231,0 +232,0 @@ requiredVersionWarning( |
@@ -25,3 +25,5 @@ /* | ||
| /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../Module").Sources} Sources */ | ||
| /** @typedef {import("../Module").SourceTypes} SourceTypes */ | ||
| /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */ | ||
| /** @typedef {import("../RequestShortener")} RequestShortener */ | ||
@@ -151,3 +153,5 @@ /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| }${this._eager ? ", 1" : ""});`; | ||
| /** @type {Sources} */ | ||
| const sources = new Map(); | ||
| /** @type {CodeGenerationResultData} */ | ||
| const data = new Map(); | ||
@@ -154,0 +158,0 @@ data.set("share-init", [ |
@@ -48,25 +48,24 @@ /* | ||
| this._provides = /** @type {[string, ProvideOptions][]} */ ( | ||
| parseOptions( | ||
| options.provides, | ||
| (item) => { | ||
| if (Array.isArray(item)) { | ||
| throw new Error("Unexpected array of provides"); | ||
| } | ||
| /** @type {ProvideOptions} */ | ||
| const result = { | ||
| shareKey: item, | ||
| version: undefined, | ||
| shareScope: options.shareScope || "default", | ||
| eager: false | ||
| }; | ||
| return result; | ||
| }, | ||
| (item) => ({ | ||
| shareKey: item.shareKey, | ||
| version: item.version, | ||
| shareScope: item.shareScope || options.shareScope || "default", | ||
| eager: Boolean(item.eager) | ||
| }) | ||
| ) | ||
| /** @type {[string, ProvideOptions][]} */ | ||
| this._provides = parseOptions( | ||
| options.provides, | ||
| (item) => { | ||
| if (Array.isArray(item)) { | ||
| throw new Error("Unexpected array of provides"); | ||
| } | ||
| /** @type {ProvideOptions} */ | ||
| const result = { | ||
| shareKey: item, | ||
| version: undefined, | ||
| shareScope: options.shareScope || "default", | ||
| eager: false | ||
| }; | ||
| return result; | ||
| }, | ||
| (item) => ({ | ||
| shareKey: /** @type {string} */ (item.shareKey), | ||
| version: item.version, | ||
| shareScope: item.shareScope || options.shareScope || "default", | ||
| eager: Boolean(item.eager) | ||
| }) | ||
| ); | ||
@@ -99,3 +98,3 @@ this._provides.sort(([a], [b]) => { | ||
| for (const [request, config] of this._provides) { | ||
| if (/^(\/|[A-Za-z]:\\|\\\\|\.\.?(\/|$))/.test(request)) { | ||
| if (/^(?:\/|[A-Z]:\\|\\\\|\.\.?(?:\/|$))/i.test(request)) { | ||
| // relative request | ||
@@ -106,3 +105,3 @@ resolvedProvideMap.set(request, { | ||
| }); | ||
| } else if (/^(\/|[A-Za-z]:\\|\\\\)/.test(request)) { | ||
| } else if (/^(?:\/|[A-Z]:\\|\\\\)/i.test(request)) { | ||
| // absolute path | ||
@@ -109,0 +108,0 @@ resolvedProvideMap.set(request, { |
@@ -57,3 +57,3 @@ /* | ||
| configs.map(([request, config]) => { | ||
| if (/^\.\.?(\/|$)/.test(request)) { | ||
| if (/^\.\.?(?:\/|$)/.test(request)) { | ||
| // relative request | ||
@@ -81,3 +81,3 @@ return new Promise((resolve) => { | ||
| }); | ||
| } else if (/^(\/|[A-Za-z]:\\|\\\\)/.test(request)) { | ||
| } else if (/^(?:\/|[a-z]:\\|\\\\)/i.test(request)) { | ||
| // absolute path | ||
@@ -84,0 +84,0 @@ resolved.set(request, config); |
@@ -18,10 +18,10 @@ /* | ||
| // Short url with specific protocol. eg: github:foo/bar | ||
| const RE_GIT_URL_SHORT = /^(github|gitlab|bitbucket|gist):\/?[^/.]+\/?/i; | ||
| const RE_GIT_URL_SHORT = /^(?:github|gitlab|bitbucket|gist):\/?[^/.]+\/?/i; | ||
| // Currently supported protocols | ||
| const RE_PROTOCOL = | ||
| /^((git\+)?(ssh|https?|file)|git|github|gitlab|bitbucket|gist):$/i; | ||
| /^(?:(?:git\+)?(?:ssh|https?|file)|git|github|gitlab|bitbucket|gist):$/i; | ||
| // Has custom protocol | ||
| const RE_CUSTOM_PROTOCOL = /^((git\+)?(ssh|https?|file)|git):\/\//i; | ||
| const RE_CUSTOM_PROTOCOL = /^(?:(?:git\+)?(?:ssh|https?|file)|git):\/\//i; | ||
@@ -32,3 +32,3 @@ // Valid hash format for npm / yarn ... | ||
| // Simple hostname validate | ||
| const RE_HOSTNAME = /^(?:[^/.]+(\.[^/]+)+|localhost)$/; | ||
| const RE_HOSTNAME = /^(?:[^/.]+(?:\.[^/]+)+|localhost)$/; | ||
@@ -40,6 +40,6 @@ // For hostname with colon. eg: ssh://user@github.com:foo/bar | ||
| // Reg for url without protocol | ||
| const RE_NO_PROTOCOL = /^([^/@#:.]+(?:\.[^/@#:.]+)+)/; | ||
| const RE_NO_PROTOCOL = /^[^/@#:.]+(?:\.[^/@#:.]+)+/; | ||
| // RegExp for version string | ||
| const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/; | ||
| const VERSION_PATTERN_REGEXP = /^(?:[\d^=v<>~]|[*xX]$)/; | ||
@@ -254,3 +254,5 @@ // Specific protocol for short url without normal hostname | ||
| /** @type {undefined | URL} */ | ||
| let parsed; | ||
| try { | ||
@@ -257,0 +259,0 @@ parsed = new URL(gitUrl); |
@@ -54,5 +54,5 @@ /* | ||
| const METACHARACTERS_REGEXP = /[-[\]\\/{}()*+?.^$|]/g; | ||
| const CONTENT_HASH_DETECT_REGEXP = /\[contenthash(:\w+)?\]/; | ||
| const CONTENT_HASH_DETECT_REGEXP = /\[contenthash(?::\w+)?\]/; | ||
| const CSS_AND_JS_MODULE_EXTENSIONS_REGEXP = /\.((c|m)?js|css)($|\?)/i; | ||
| const CSS_EXTENSION_DETECT_REGEXP = /\.css($|\?)/i; | ||
| const CSS_EXTENSION_DETECT_REGEXP = /\.css(?:$|\?)/i; | ||
| const MAP_URL_COMMENT_REGEXP = /\[map\]/g; | ||
@@ -97,4 +97,5 @@ const URL_COMMENT_REGEXP = /\[url\]/g; | ||
| ) => { | ||
| /** @type {string | Buffer} */ | ||
| let source; | ||
| /** @type {RawSourceMap} */ | ||
| /** @type {null | RawSourceMap} */ | ||
| let sourceMap; | ||
@@ -106,6 +107,6 @@ /** | ||
| const sourceAndMap = asset.sourceAndMap(options); | ||
| sourceMap = /** @type {RawSourceMap} */ (sourceAndMap.map); | ||
| sourceMap = sourceAndMap.map; | ||
| source = sourceAndMap.source; | ||
| } else { | ||
| sourceMap = /** @type {RawSourceMap} */ (asset.map(options)); | ||
| sourceMap = asset.map(options); | ||
| source = asset.source(); | ||
@@ -179,2 +180,3 @@ } | ||
| /** @type {(filename: string) => boolean} */ | ||
| const matchObject = ModuleFilenameHelpers.matchObject.bind( | ||
@@ -317,3 +319,3 @@ undefined, | ||
| typeof module === "string" && | ||
| /^(data|https?):/.test(module) | ||
| /^(?:data|https?):/.test(module) | ||
| ) { | ||
@@ -424,3 +426,5 @@ moduleToSourceNameMapping.set(module, module); | ||
| (task, callback) => { | ||
| /** @type {Record<string, Source>} */ | ||
| const assets = Object.create(null); | ||
| /** @type {Record<string, AssetInfo | undefined>} */ | ||
| const assetsInfo = Object.create(null); | ||
@@ -443,20 +447,23 @@ const file = task.file; | ||
| sourceMap.sources = /** @type {string[]} */ (moduleFilenames); | ||
| sourceMap.ignoreList = options.ignoreList | ||
| ? sourceMap.sources.reduce( | ||
| /** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ ( | ||
| (acc, sourceName, idx) => { | ||
| const rule = /** @type {Rules} */ ( | ||
| options.ignoreList | ||
| ); | ||
| if ( | ||
| ModuleFilenameHelpers.matchPart(sourceName, rule) | ||
| ) { | ||
| acc.push(idx); | ||
| } | ||
| return acc; | ||
| if (options.ignoreList) { | ||
| const ignoreList = sourceMap.sources.reduce( | ||
| /** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ ( | ||
| (acc, sourceName, idx) => { | ||
| const rule = /** @type {Rules} */ ( | ||
| options.ignoreList | ||
| ); | ||
| if ( | ||
| ModuleFilenameHelpers.matchPart(sourceName, rule) | ||
| ) { | ||
| acc.push(idx); | ||
| } | ||
| ), | ||
| [] | ||
| ) | ||
| : []; | ||
| return acc; | ||
| } | ||
| ), | ||
| [] | ||
| ); | ||
| if (ignoreList.length > 0) { | ||
| sourceMap.ignoreList = ignoreList; | ||
| } | ||
| } | ||
@@ -463,0 +470,0 @@ if (options.noSources) { |
@@ -248,2 +248,3 @@ /* | ||
| : versionMessage || nameMessage || "webpack"; | ||
| /** @type {string} */ | ||
| let statusMessage; | ||
@@ -591,4 +592,3 @@ if (errorsMessage && warningsMessage) { | ||
| /** | ||
| * @typedef {Printers<KnownStatsModuleIssuer, "moduleIssuer"> & | ||
| * Printers<KnownStatsModuleIssuer["profile"], "moduleIssuer.profile", "moduleIssuer">} ModuleIssuerPrinters | ||
| * @typedef {Printers<KnownStatsModuleIssuer, "moduleIssuer"> & Printers<KnownStatsModuleIssuer["profile"], "moduleIssuer.profile", "moduleIssuer">} ModuleIssuerPrinters | ||
| */ | ||
@@ -603,4 +603,3 @@ | ||
| /** | ||
| * @typedef {Printers<KnownStatsModuleReason, "moduleReason"> & | ||
| * { ["moduleReason.filteredChildren"]?: SimplePrinter<number, "moduleReason"> }} ModuleReasonsPrinters | ||
| * @typedef {Printers<KnownStatsModuleReason, "moduleReason"> & { ["moduleReason.filteredChildren"]?: SimplePrinter<number, "moduleReason"> }} ModuleReasonsPrinters | ||
| */ | ||
@@ -805,3 +804,3 @@ | ||
| moduleName.includes("!") | ||
| ? `${bold(moduleName.replace(/^(\s|\S)*!/, ""))} (${moduleName})` | ||
| ? `${bold(moduleName.replace(/^([\s\S])*!/, ""))} (${moduleName})` | ||
| : `${bold(moduleName)}`, | ||
@@ -1200,2 +1199,3 @@ "error.loc": (loc, { green }) => green(loc), | ||
| const joinInBrackets = (items) => { | ||
| /** @type {string[]} */ | ||
| const res = []; | ||
@@ -1304,2 +1304,3 @@ let mode = 0; | ||
| compilation: (items) => { | ||
| /** @type {string[]} */ | ||
| const result = []; | ||
@@ -1306,0 +1307,0 @@ let lastNeedMore = false; |
@@ -164,3 +164,3 @@ /* | ||
| * @template {HM extends HookMap<infer H> ? H : never} H | ||
| * @template {H extends import("tapable").Hook<any, infer R> ? R : never} R | ||
| * @template {H extends import("tapable").Hook<EXPECTED_ANY, infer R> ? R : never} R | ||
| * @param {HM} hookMap hook map | ||
@@ -201,3 +201,3 @@ * @param {Caches<H>} cache cache | ||
| * @template {T extends HookMap<infer H> ? H : never} H | ||
| * @template {H extends import("tapable").Hook<any, infer R> ? R : never} R | ||
| * @template {H extends import("tapable").Hook<EXPECTED_ANY, infer R> ? R : never} R | ||
| * @param {T} hookMap hook map | ||
@@ -204,0 +204,0 @@ * @param {Caches<H>} cache cache |
+10
-5
@@ -39,6 +39,6 @@ /* | ||
| const LINE_SEPARATOR_REGEX = /\r?\n/g; | ||
| const IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-zA-Z$_])/; | ||
| const IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-zA-Z0-9$]+/g; | ||
| const IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-z$_])/i; | ||
| const IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-z0-9$]+/gi; | ||
| const COMMENT_END_REGEX = /\*\//g; | ||
| const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g; | ||
| const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-z0-9_!§$()=\-^°]+/gi; | ||
| const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g; | ||
@@ -87,6 +87,10 @@ | ||
| /** | ||
| * @typedef {object} Stringable | ||
| * @property {() => string} toString | ||
| */ | ||
| class Template { | ||
| /** | ||
| * @template {EXPECTED_FUNCTION} T | ||
| * @param {T} fn a runtime function (.runtime.js) "template" | ||
| * @param {Stringable} fn a runtime function (.runtime.js) "template" | ||
| * @returns {string} the updated and normalized function string | ||
@@ -364,2 +368,3 @@ */ | ||
| const codeGenerationResults = renderContext.codeGenerationResults; | ||
| /** @type {undefined | Source} */ | ||
| let runtimeSource; | ||
@@ -366,0 +371,0 @@ if (codeGenerationResults) { |
@@ -21,3 +21,3 @@ /* | ||
| const REGEXP = /\[\\*([\w:]+)\\*\]/gi; | ||
| const REGEXP = /\[\\*([\w:]+)\\*\]/g; | ||
@@ -36,3 +36,3 @@ /** @type {PathData["prepareId"]} */ | ||
| return id.replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_"); | ||
| return id.replace(/(^[.-]|[^a-z0-9_-])+/gi, "_"); | ||
| }; | ||
@@ -57,2 +57,3 @@ | ||
| const fn = (match, arg, input) => { | ||
| /** @type {string} */ | ||
| let result; | ||
@@ -113,2 +114,3 @@ const length = arg && Number.parseInt(arg, 10); | ||
| /** @type {Map<string, (...args: EXPECTED_ANY[]) => EXPECTED_ANY>} */ | ||
| const deprecationCache = new Map(); | ||
@@ -115,0 +117,0 @@ const deprecatedFunction = (() => () => {})(); |
@@ -23,2 +23,3 @@ /* | ||
| this.file = resource; | ||
| /** @type {string} */ | ||
| this.name = "UnhandledSchemeError"; | ||
@@ -25,0 +26,0 @@ } |
@@ -21,2 +21,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "UnsupportedFeatureWarning"; | ||
@@ -23,0 +24,0 @@ this.loc = loc; |
@@ -57,5 +57,3 @@ /* | ||
| /** | ||
| * @type {WeakMap<NewExpressionNode, BasicEvaluatedExpression | undefined>} | ||
| */ | ||
| /** @type {WeakMap<NewExpressionNode, BasicEvaluatedExpression | undefined>} */ | ||
| const getEvaluatedExprCache = new WeakMap(); | ||
@@ -171,2 +169,3 @@ | ||
| /** @type {string | undefined} */ | ||
| let request; | ||
@@ -195,3 +194,5 @@ | ||
| // context URL | ||
| /** @type {undefined | RegExp} */ | ||
| let include; | ||
| /** @type {undefined | RegExp} */ | ||
| let exclude; | ||
@@ -198,0 +199,0 @@ |
@@ -68,2 +68,7 @@ /* | ||
| /** | ||
| * @template T | ||
| * @typedef {(items: T[], start: number, compareFn?: number | ((item: T, needle: number) => number), l?: number, h?: number) => number} Search | ||
| */ | ||
| /** | ||
| * This helper functions generate code for two binary search functions: | ||
@@ -78,3 +83,3 @@ * A(): Performs a binary search on an array using the comparison operator specified. | ||
| * @param {boolean=} earlyOut Whether the search should return as soon as a match is found. | ||
| * @returns {(items: T[], start: number, compareFn?: number | ((item: T, needle: number) => number), l?: number, h?: number) => number} The compiled binary search function. | ||
| * @returns {Search<T>} The compiled binary search function. | ||
| */ | ||
@@ -111,2 +116,10 @@ const compileBoundsSearch = (predicate, reversed, suffix, earlyOut) => { | ||
| const fns = { | ||
| ge: compileBoundsSearch(">=", false, "GE"), | ||
| gt: compileBoundsSearch(">", false, "GT"), | ||
| lt: compileBoundsSearch("<", true, "LT"), | ||
| le: compileBoundsSearch("<=", true, "LE"), | ||
| eq: compileBoundsSearch("-", true, "EQ", true) | ||
| }; | ||
| /** | ||
@@ -126,8 +139,2 @@ * These functions are used to perform binary searches on arrays. | ||
| */ | ||
| module.exports = { | ||
| ge: compileBoundsSearch(">=", false, "GE"), | ||
| gt: compileBoundsSearch(">", false, "GT"), | ||
| lt: compileBoundsSearch("<", true, "LT"), | ||
| le: compileBoundsSearch("<=", true, "LE"), | ||
| eq: compileBoundsSearch("-", true, "EQ", true) | ||
| }; | ||
| module.exports = fns; |
@@ -26,3 +26,3 @@ /* | ||
| * @param {Dependency} dependency dependency | ||
| * @returns {{trimmedIds: string[], trimmedRange: Range}} computed trimmed ids and cumulative range of those ids | ||
| * @returns {{ trimmedIds: string[], trimmedRange: Range }} computed trimmed ids and cumulative range of those ids | ||
| */ | ||
@@ -29,0 +29,0 @@ module.exports.getTrimmedIdsAndRange = ( |
@@ -10,3 +10,4 @@ /* | ||
| const mergeCache = new WeakMap(); | ||
| /** @type {WeakMap<EXPECTED_OBJECT, Map<string, Map<string | number | boolean, EXPECTED_OBJECT>>>} */ | ||
| /** @typedef {Map<string, Map<string | number | boolean, EXPECTED_OBJECT>>} InnerPropertyCache */ | ||
| /** @type {WeakMap<EXPECTED_OBJECT, InnerPropertyCache>} */ | ||
| const setPropertyCache = new WeakMap(); | ||
@@ -410,2 +411,3 @@ const DELETE = Symbol("DELETE"); | ||
| // need to merge first and second byValues | ||
| /** @type {Map<string, T & O>} */ | ||
| const newByValues = new Map(firstEntry.byValues); | ||
@@ -449,3 +451,5 @@ for (const [key, value] of /** @type {ByValues} */ ( | ||
| } | ||
| /** @type {O[keyof O] | T[keyof T] | (T[keyof T] & O[keyof O]) | (T[keyof T] | undefined)[] | (O[keyof O] | undefined)[] | (O[keyof O] | T[keyof T] | undefined)[] | undefined} */ | ||
| let newBase; | ||
| /** @type {Map<string, (T & O) | O[keyof O] | (O[keyof O] | undefined)[] | ((T & O) | undefined)[] | (T & O & O[keyof O]) | ((T & O) | O[keyof O] | undefined)[] | undefined>} */ | ||
| const intermediateByValues = new Map(firstEntry.byValues); | ||
@@ -491,2 +495,3 @@ for (const [key, value] of intermediateByValues) { | ||
| } | ||
| /** @type {Map<string, (T & O) | O[keyof O] | (O[keyof O] | undefined)[] | (T & O & O[keyof O]) | ((T & O) | undefined)[] | ((T & O) | O[keyof O] | undefined)[] | undefined>} */ | ||
| const newByValues = new Map(intermediateByValues); | ||
@@ -493,0 +498,0 @@ for (const [key, value] of /** @type {ByValues} */ ( |
@@ -8,2 +8,3 @@ /* | ||
| const { getFullModuleName } = require("../ids/IdHelpers"); | ||
| const { compareRuntime } = require("./runtime"); | ||
@@ -17,2 +18,3 @@ | ||
| /** @typedef {import("../ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
@@ -322,2 +324,15 @@ /** @typedef {import("../Dependency")} Dependency */ | ||
| /** | ||
| * Compare modules by their full name. This differs from comparing by identifier in that the values have been normalized to be relative to the compiler context. | ||
| * @param {{ context: string, root: object }} compiler the compiler, used for context and cache | ||
| * @param {Module} a module | ||
| * @param {Module} b module | ||
| * @returns {-1 | 0 | 1} compare result | ||
| */ | ||
| const compareModulesByFullName = (compiler, a, b) => { | ||
| const aName = getFullModuleName(a, compiler.context, compiler.root); | ||
| const bName = getFullModuleName(b, compiler.context, compiler.root); | ||
| return compareIds(aName, bName); | ||
| }; | ||
| /** | ||
| * @param {ChunkGraph} chunkGraph the chunk graph | ||
@@ -525,3 +540,3 @@ * @param {Chunk} a chunk | ||
| ) => { | ||
| /** @type {{dep: Dependency, main: number, sub: number}[]} */ | ||
| /** @type {{ dep: Dependency, main: number, sub: number }[]} */ | ||
| const withSourceOrder = []; | ||
@@ -597,2 +612,7 @@ /** @type {number[]} */ | ||
| /** @type {ParameterizedComparator<Compiler, Module>} */ | ||
| module.exports.compareModulesByFullName = createCachedParameterizedComparator( | ||
| compareModulesByFullName | ||
| ); | ||
| /** @type {ParameterizedComparator<ChunkGraph, Module>} */ | ||
@@ -599,0 +619,0 @@ module.exports.compareModulesById = |
@@ -255,6 +255,6 @@ /* | ||
| if (finishedItems.length === 0 && items.size === 2) { | ||
| /** @type {Iterator<string>} */ | ||
| /** @type {SetIterator<string>} */ | ||
| const it = items[Symbol.iterator](); | ||
| const a = it.next().value; | ||
| const b = it.next().value; | ||
| const a = /** @type {string} */ (it.next().value); | ||
| const b = /** @type {string} */ (it.next().value); | ||
| if (a.length > 0 && b.length > 0 && a.slice(-1) === b.slice(-1)) { | ||
@@ -261,0 +261,0 @@ return `${itemsToRegexp([a.slice(0, -1), b.slice(0, -1)])}${quoteMeta( |
@@ -113,3 +113,3 @@ /* | ||
| extraInfo = extraInfo.replace( | ||
| /\.+\/|(\/index)?\.([a-zA-Z0-9]{1,4})($|\s|\?)|\s*\+\s*\d+\s*modules/g, | ||
| /\.+\/|(?:\/index)?\.[a-zA-Z0-9]{1,4}(?:$|\s|\?)|\s*\+\s*\d+\s*modules/g, | ||
| "" | ||
@@ -203,5 +203,6 @@ ); | ||
| /** @typedef {{ usedNames: UsedNames, alreadyCheckedScopes: ScopeSet }} ScopeInfo */ | ||
| /** @typedef {Map<string, ScopeInfo>} UsedNamesInScopeInfo */ | ||
| /** | ||
| * @param {Map<string, ScopeInfo>} usedNamesInScopeInfo used names in scope info | ||
| * @param {UsedNamesInScopeInfo} usedNamesInScopeInfo used names in scope info | ||
| * @param {string} module module identifier | ||
@@ -208,0 +209,0 @@ * @param {string} id export id |
@@ -23,3 +23,3 @@ /* | ||
| if (isLastCharLower && /[\p{Lu}]/u.test(character)) { | ||
| if (isLastCharLower && /\p{Lu}/u.test(character)) { | ||
| result = `${result.slice(0, i)}-${result.slice(i)}`; | ||
@@ -33,3 +33,3 @@ isLastCharLower = false; | ||
| isLastLastCharUpper && | ||
| /[\p{Ll}]/u.test(character) | ||
| /\p{Ll}/u.test(character) | ||
| ) { | ||
@@ -89,2 +89,3 @@ result = `${result.slice(0, i - 1)}-${result.slice(i - 1)}`; | ||
| module.exports.cssExportConvention = (input, convention) => { | ||
| /** @type {Set<string>} */ | ||
| const set = new Set(); | ||
@@ -91,0 +92,0 @@ if (typeof convention === "function") { |
@@ -103,2 +103,3 @@ /* | ||
| const sumSize = (nodes) => { | ||
| /** @type {Sizes} */ | ||
| const sum = Object.create(null); | ||
@@ -149,3 +150,3 @@ for (const node of nodes) { | ||
| const getTooSmallTypes = (size, minSize) => { | ||
| /** @typedef {Types} */ | ||
| /** @type {Types} */ | ||
| const types = new Set(); | ||
@@ -228,5 +229,9 @@ for (const key of Object.keys(size)) { | ||
| popNodes(filter) { | ||
| /** @type {Node<T>[]} */ | ||
| const newNodes = []; | ||
| /** @type {Similarities} */ | ||
| const newSimilarities = []; | ||
| /** @type {Node<T>[]} */ | ||
| const resultNodes = []; | ||
| /** @type {undefined | Node<T>} */ | ||
| let lastNode; | ||
@@ -266,2 +271,3 @@ for (let i = 0; i < this.nodes.length; i++) { | ||
| const similarities = []; | ||
| /** @type {undefined | Node<T>} */ | ||
| let last; | ||
@@ -406,2 +412,3 @@ for (const node of nodes) { | ||
| let left = 1; | ||
| /** @type {Sizes} */ | ||
| const leftSize = Object.create(null); | ||
@@ -414,2 +421,3 @@ addSizeTo(leftSize, group.nodes[0].size); | ||
| let right = group.nodes.length - 2; | ||
| /** @type {Sizes} */ | ||
| const rightSize = Object.create(null); | ||
@@ -434,2 +442,3 @@ addSizeTo(rightSize, group.nodes[group.nodes.length - 1].size); | ||
| // We try to remove some problematic nodes to "fix" that | ||
| /** @type {Sizes} */ | ||
| let prevSize; | ||
@@ -500,2 +509,3 @@ if (right < group.nodes.length - left) { | ||
| // and queue them up | ||
| /** @type {Node<T>[]} */ | ||
| const rightNodes = [group.nodes[right + 1]]; | ||
@@ -512,2 +522,3 @@ /** @type {Similarities} */ | ||
| /** @type {Node<T>[]} */ | ||
| const leftNodes = [group.nodes[0]]; | ||
@@ -535,2 +546,3 @@ /** @type {Similarities} */ | ||
| // give every group a name | ||
| /** @type {Set<string>} */ | ||
| const usedNames = new Set(); | ||
@@ -537,0 +549,0 @@ for (let i = 0; i < result.length; i++) { |
@@ -13,14 +13,8 @@ /* | ||
| /** @typedef {import("./fs").InputFileSystem} InputFileSystem */ | ||
| /** | ||
| * @typedef {(input: string | Buffer<ArrayBufferLike>, resourcePath: string, fs: InputFileSystem) => Promise<{source: string | Buffer<ArrayBufferLike>, sourceMap: string | RawSourceMap | undefined, fileDependencies: string[]}>} SourceMapExtractorFunction | ||
| */ | ||
| /** @typedef {string | Buffer<ArrayBufferLike>} StringOrBuffer */ | ||
| /** @typedef {(input: StringOrBuffer, resourcePath: string, fs: InputFileSystem) => Promise<{ source: StringOrBuffer, sourceMap: string | RawSourceMap | undefined, fileDependencies: string[] }>} SourceMapExtractorFunction */ | ||
| /** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */ | ||
| /** @typedef {(resourcePath: string) => Promise<StringOrBuffer>} ReadResource */ | ||
| /** | ||
| * @typedef {(resourcePath: string) => Promise<string | Buffer<ArrayBufferLike>>} ReadResource | ||
| */ | ||
| /** | ||
| * @typedef {object} SourceMappingURL | ||
@@ -56,2 +50,3 @@ * @property {string} sourceMappingURL | ||
| const lines = code.split(/^/m); | ||
| /** @type {RegExpMatchArray | null | undefined} */ | ||
| let match; | ||
@@ -109,3 +104,3 @@ | ||
| * @param {string} errorsAccumulator accumulated error messages | ||
| * @returns {Promise<{path: string, data?: string}>} source content promise | ||
| * @returns {Promise<{ path: string, data?: string }>} source content promise | ||
| */ | ||
@@ -117,2 +112,3 @@ async function fetchPathsFromURL( | ||
| ) { | ||
| /** @type {StringOrBuffer} */ | ||
| let result; | ||
@@ -153,3 +149,3 @@ | ||
| * @param {boolean=} skipReading whether to skip reading file content | ||
| * @returns {Promise<{sourceURL: string, sourceContent?: string | Buffer<ArrayBufferLike>}>} source content promise | ||
| * @returns {Promise<{ sourceURL: string, sourceContent?: StringOrBuffer }>} source content promise | ||
| */ | ||
@@ -189,5 +185,7 @@ async function fetchFromURL( | ||
| /** @type {undefined | StringOrBuffer} */ | ||
| let sourceContent; | ||
| if (!skipReading) { | ||
| /** @type {string[]} */ | ||
| const possibleRequests = [sourceURL]; | ||
@@ -212,2 +210,3 @@ | ||
| const sourceURL = getAbsolutePath(context, url, sourceRoot || ""); | ||
| /** @type {undefined | StringOrBuffer} */ | ||
| let sourceContent; | ||
@@ -224,6 +223,6 @@ | ||
| * Extract source map from code content | ||
| * @param {string | Buffer<ArrayBufferLike>} stringOrBuffer The input code content as string or buffer | ||
| * @param {StringOrBuffer} stringOrBuffer The input code content as string or buffer | ||
| * @param {string} resourcePath The path to the resource file | ||
| * @param {ReadResource} readResource The read resource function | ||
| * @returns {Promise<{source: string | Buffer<ArrayBufferLike>, sourceMap: string | RawSourceMap | undefined}>} Promise resolving to extracted source map information | ||
| * @returns {Promise<{ source: StringOrBuffer, sourceMap: string | RawSourceMap | undefined }>} Promise resolving to extracted source map information | ||
| */ | ||
@@ -230,0 +229,0 @@ async function extractSourceMap(stringOrBuffer, resourcePath, readResource) { |
+15
-19
@@ -11,3 +11,5 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").WatchOptions} WatchOptions */ | ||
| /** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */ | ||
| /** @typedef {import("watchpack").Entry} Entry */ | ||
| /** @typedef {import("watchpack").OnlySafeTimeEntry} OnlySafeTimeEntry */ | ||
| /** @typedef {import("watchpack").ExistenceOnlyTimeEntry} ExistenceOnlyTimeEntry */ | ||
@@ -87,3 +89,3 @@ /** | ||
| /** @typedef {Map<string, FileSystemInfoEntry | "ignore">} TimeInfoEntries */ | ||
| /** @typedef {Map<string, Entry | OnlySafeTimeEntry | ExistenceOnlyTimeEntry | null | "ignore">} TimeInfoEntries */ | ||
@@ -206,3 +208,3 @@ /** @typedef {Set<string>} Changes */ | ||
| * @typedef {{ | ||
| * (path: PathLike, options?: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined; } | BufferEncoding | null): string[], | ||
| * (path: PathLike, options?: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | null): string[], | ||
| * (path: PathLike, options: { encoding: "buffer", withFileTypes?: false | undefined, recursive?: boolean | undefined } | "buffer"): Buffer[], | ||
@@ -231,4 +233,4 @@ * (path: PathLike, options?: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | null): string[] | Buffer[], | ||
| * (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats, | ||
| * (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats, | ||
| * (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined, | ||
| * (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats, | ||
| * (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined, | ||
| * }} StatSync | ||
@@ -253,4 +255,4 @@ */ | ||
| * (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats, | ||
| * (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats, | ||
| * (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined, | ||
| * (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats, | ||
| * (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined, | ||
| * }} LStatSync | ||
@@ -264,3 +266,3 @@ */ | ||
| * (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void, | ||
| * (path: PathLike, callback: StringCallback): void; | ||
| * (path: PathLike, callback: StringCallback): void, | ||
| * }} RealPath | ||
@@ -333,3 +335,3 @@ */ | ||
| * (file: PathLike, options: MakeDirectoryOptions & { recursive: true }, callback: StringCallback): void, | ||
| * (file: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false | undefined; }) | null | undefined, callback: NoParamCallback): void, | ||
| * (file: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false | undefined }) | null | undefined, callback: NoParamCallback): void, | ||
| * (file: PathLike, options: Mode | MakeDirectoryOptions | null | undefined, callback: StringCallback): void, | ||
@@ -341,13 +343,6 @@ * (file: PathLike, callback: NoParamCallback): void, | ||
| /** | ||
| * @typedef {{ maxRetries?: number | undefined, recursive?: boolean | undefined, retryDelay?: number | undefined }} RmDirOptions | ||
| * @typedef {{ (file: PathLike, callback: NoParamCallback): void }} Rmdir | ||
| */ | ||
| /** | ||
| * @typedef {{ | ||
| * (file: PathLike, callback: NoParamCallback): void, | ||
| * (file: PathLike, options: RmDirOptions, callback: NoParamCallback): void, | ||
| * }} Rmdir | ||
| */ | ||
| /** | ||
| * @typedef {(pathLike: PathLike, callback: NoParamCallback) => void} Unlink | ||
@@ -416,3 +411,3 @@ */ | ||
| /** | ||
| * @typedef {FSImplementation & { write: (...args: EXPECTED_ANY[]) => EXPECTED_ANY; close?: (...args: EXPECTED_ANY[]) => EXPECTED_ANY }} CreateWriteStreamFSImplementation | ||
| * @typedef {FSImplementation & { write: (...args: EXPECTED_ANY[]) => EXPECTED_ANY, close?: (...args: EXPECTED_ANY[]) => EXPECTED_ANY }} CreateWriteStreamFSImplementation | ||
| */ | ||
@@ -434,3 +429,3 @@ | ||
| * @typedef {{ | ||
| * (file: PathLike, flags: OpenMode | undefined, mode: Mode | undefined | null, callback: NumberCallback): void, | ||
| * (file: PathLike, flags: OpenMode | undefined, mode: Mode | undefined | null, callback: NumberCallback): void, | ||
| * (file: PathLike, flags: OpenMode | undefined, callback: NumberCallback): void, | ||
@@ -626,2 +621,3 @@ * (file: PathLike, callback: NumberCallback): void, | ||
| if (err) return callback(err); | ||
| /** @type {JsonObject} */ | ||
| let data; | ||
@@ -628,0 +624,0 @@ try { |
+1
-0
@@ -9,2 +9,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").HashDigest} Encoding */ | ||
| /** @typedef {string | typeof Hash} HashFunction */ | ||
@@ -11,0 +12,0 @@ class Hash { |
@@ -20,4 +20,7 @@ /* | ||
| super(); | ||
| /** @type {undefined | string} */ | ||
| this.string = undefined; | ||
| /** @type {undefined | Encoding} */ | ||
| this.encoding = undefined; | ||
| /** @type {Hash} */ | ||
| this.hash = hash; | ||
@@ -24,0 +27,0 @@ } |
@@ -18,3 +18,3 @@ /* | ||
| // so access to it can be optimized by v8 | ||
| /** @type {{[key: string]: Map<string, string>}} */ | ||
| /** @type {{ [key: string]: Map<string, string> }} */ | ||
| const digestCaches = {}; | ||
@@ -29,8 +29,13 @@ | ||
| super(); | ||
| /** @type {undefined | string} */ | ||
| this.hashKey = hashKey; | ||
| if (typeof hashOrFactory === "function") { | ||
| /** @type {undefined | HashFactory} */ | ||
| this.hashFactory = hashOrFactory; | ||
| /** @type {undefined | Hash} */ | ||
| this.hash = undefined; | ||
| } else { | ||
| /** @type {undefined | HashFactory} */ | ||
| this.hashFactory = undefined; | ||
| /** @type {undefined | Hash} */ | ||
| this.hash = hashOrFactory; | ||
@@ -108,2 +113,3 @@ } | ||
| digest(encoding) { | ||
| /** @type {undefined | Map<string, string | Buffer>} */ | ||
| let digestCache; | ||
@@ -110,0 +116,0 @@ const buffer = this.buffer; |
@@ -52,2 +52,3 @@ /* | ||
| // Convert to baseX string efficiently using array | ||
| /** @type {string[]} */ | ||
| const digits = []; | ||
@@ -54,0 +55,0 @@ if (value === ZERO) return ENCODE_TABLE[base][0]; |
@@ -16,2 +16,10 @@ /* | ||
| /** | ||
| * @typedef {object} WasmExports | ||
| * @property {WebAssembly.Memory} memory | ||
| * @property {() => void} init | ||
| * @property {(length: number) => void} update | ||
| * @property {(length: number) => void} final | ||
| */ | ||
| class WasmHash extends Hash { | ||
@@ -27,9 +35,15 @@ /** | ||
| const exports = /** @type {EXPECTED_ANY} */ (instance.exports); | ||
| const exports = /** @type {WasmExports} */ (instance.exports); | ||
| exports.init(); | ||
| /** @type {WasmExports} */ | ||
| this.exports = exports; | ||
| /** @type {Buffer} */ | ||
| this.mem = Buffer.from(exports.memory.buffer, 0, 65536); | ||
| /** @type {number} */ | ||
| this.buffered = 0; | ||
| /** @type {WebAssembly.Instance[]} */ | ||
| this.instancesPool = instancesPool; | ||
| /** @type {number} */ | ||
| this.chunkSize = chunkSize; | ||
| /** @type {number} */ | ||
| this.digestSize = digestSize; | ||
@@ -90,2 +104,3 @@ } | ||
| const { exports, buffered, mem, chunkSize } = this; | ||
| /** @type {number} */ | ||
| let endPos; | ||
@@ -92,0 +107,0 @@ if (data.length < 70) { |
@@ -9,3 +9,3 @@ /* | ||
| const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/; | ||
| const WINDOWS_ABS_PATH_REGEXP = /^[a-z]:[\\/]/i; | ||
| const SEGMENTS_SPLIT_REGEXP = /([|!])/; | ||
@@ -169,3 +169,4 @@ const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g; | ||
| const makeCacheableWithContext = (fn) => { | ||
| /** @type {WeakMap<AssociatedObjectForCache, Map<string, Map<string, string>>>} */ | ||
| /** @typedef {Map<string, Map<string, string>>} InnerCache */ | ||
| /** @type {WeakMap<AssociatedObjectForCache, InnerCache>} */ | ||
| const cache = new WeakMap(); | ||
@@ -183,2 +184,3 @@ | ||
| /** @type {undefined | string} */ | ||
| let cachedResult; | ||
@@ -202,2 +204,3 @@ let innerSubCache = innerCache.get(context); | ||
| cachedFn.bindCache = (associatedObjectForCache) => { | ||
| /** @type {undefined | InnerCache} */ | ||
| let innerCache; | ||
@@ -220,2 +223,3 @@ if (associatedObjectForCache) { | ||
| const boundFn = (context, identifier) => { | ||
| /** @type {undefined | string} */ | ||
| let cachedResult; | ||
@@ -242,2 +246,3 @@ let innerSubCache = innerCache.get(context); | ||
| cachedFn.bindContextCache = (context, associatedObjectForCache) => { | ||
| /** @type {undefined | Map<string, string>} */ | ||
| let innerSubCache; | ||
@@ -244,0 +249,0 @@ if (associatedObjectForCache) { |
@@ -14,2 +14,3 @@ /* | ||
| const last = (set) => { | ||
| /** @type {T | undefined} */ | ||
| let last; | ||
@@ -16,0 +17,0 @@ for (const item of set) last = item; |
@@ -59,2 +59,3 @@ /* | ||
| this._map = new Map(); | ||
| /** @type {Set<T>} */ | ||
| this._unsortedItems = new Set(); | ||
@@ -61,0 +62,0 @@ this.size = 0; |
@@ -225,2 +225,3 @@ /* | ||
| const count = read(); | ||
| /** @type {T[]} */ | ||
| const items = []; | ||
@@ -227,0 +228,0 @@ for (let i = 0; i < count; i++) { |
@@ -19,3 +19,3 @@ /* | ||
| module.exports.webpackCommentRegExp = new RegExp( | ||
| /(^|\W)webpack[A-Z]{1,}[A-Za-z]{1,}:/ | ||
| /(^|\W)webpack[A-Z][A-Za-z]+:/ | ||
| ); | ||
@@ -22,0 +22,0 @@ |
@@ -38,2 +38,3 @@ /* | ||
| const parallelism = segments.map(() => 0); | ||
| /** @type {number[]} */ | ||
| const rangeStartIndices = []; | ||
@@ -40,0 +41,0 @@ for (let i = 0; i < this._rangePoints.length; i += 2) { |
@@ -8,3 +8,3 @@ /* | ||
| const SAFE_IDENTIFIER = /^[_a-zA-Z$][_a-zA-Z$0-9]*$/; | ||
| const SAFE_IDENTIFIER = /^[_a-z$][_a-z$0-9]*$/i; | ||
| const RESERVED_IDENTIFIER = new Set([ | ||
@@ -11,0 +11,0 @@ "break", |
@@ -171,2 +171,3 @@ /* | ||
| const len = read(); | ||
| /** @type {number[]} */ | ||
| const startEndBuffer = []; | ||
@@ -173,0 +174,0 @@ for (let i = 0; i < len; i++) { |
+15
-1
@@ -13,3 +13,4 @@ /* | ||
| /** @typedef {string | SortableSet<string> | undefined} RuntimeSpec */ | ||
| /** @typedef {SortableSet<string>} RuntimeSpecSortableSet */ | ||
| /** @typedef {string | RuntimeSpecSortableSet | undefined} RuntimeSpec */ | ||
| /** @typedef {RuntimeSpec | boolean} RuntimeCondition */ | ||
@@ -24,3 +25,5 @@ | ||
| const getEntryRuntime = (compilation, name, options) => { | ||
| /** @type {EntryOptions["dependOn"]} */ | ||
| let dependOn; | ||
| /** @type {EntryOptions["runtime"]} */ | ||
| let runtime; | ||
@@ -199,2 +202,3 @@ if (options) { | ||
| if (typeof b === "string") { | ||
| /** @type {RuntimeSpecSortableSet} */ | ||
| const set = new SortableSet(); | ||
@@ -207,2 +211,3 @@ set.add(a); | ||
| } | ||
| /** @type {RuntimeSpecSortableSet} */ | ||
| const set = new SortableSet(b); | ||
@@ -214,2 +219,3 @@ set.add(a); | ||
| if (a.has(b)) return a; | ||
| /** @type {RuntimeSpecSortableSet} */ | ||
| const set = new SortableSet(a); | ||
@@ -219,2 +225,3 @@ set.add(b); | ||
| } | ||
| /** @type {RuntimeSpecSortableSet} */ | ||
| const set = new SortableSet(a); | ||
@@ -280,5 +287,7 @@ for (const item of b) set.add(item); | ||
| } | ||
| /** @type {RuntimeSpecSortableSet} */ | ||
| return new SortableSet(b); | ||
| } else if (typeof a === "string") { | ||
| if (typeof b === "string") { | ||
| /** @type {RuntimeSpecSortableSet} */ | ||
| const set = new SortableSet(); | ||
@@ -289,2 +298,3 @@ set.add(a); | ||
| } | ||
| /** @type {RuntimeSpecSortableSet} */ | ||
| const set = new SortableSet(b); | ||
@@ -326,2 +336,3 @@ set.add(a); | ||
| } | ||
| /** @type {RuntimeSpecSortableSet} */ | ||
| const set = new SortableSet(); | ||
@@ -366,2 +377,3 @@ for (const item of b) { | ||
| } | ||
| /** @type {RuntimeSpecSortableSet} */ | ||
| const set = new SortableSet(a); | ||
@@ -371,2 +383,3 @@ set.delete(b); | ||
| } | ||
| /** @type {RuntimeSpecSortableSet} */ | ||
| const set = new SortableSet(); | ||
@@ -408,2 +421,3 @@ for (const item of a) { | ||
| let every = true; | ||
| /** @type {RuntimeSpec} */ | ||
| let result; | ||
@@ -410,0 +424,0 @@ for (const r of runtime) { |
@@ -269,2 +269,3 @@ /* | ||
| var start = 0; | ||
| /** @type {RegExpExecArray | null} */ | ||
| var match; | ||
@@ -271,0 +272,0 @@ while ((match = r.exec(str))) { |
@@ -12,3 +12,3 @@ /* | ||
| /** @typedef {import("../serialization/BinaryMiddleware").MEASURE_START_OPERATION_TYPE} MEASURE_START_OPERATION */ | ||
| /** @typedef {typeof import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/Hash").HashFunction} HashFunction */ | ||
| /** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */ | ||
@@ -115,3 +115,3 @@ | ||
| * @param {IntermediateFileSystem} fs filesystem | ||
| * @param {string | Hash} hashFunction hash function to use | ||
| * @param {HashFunction} hashFunction hash function to use | ||
| * @returns {Serializer<D, S, C>} file serializer | ||
@@ -118,0 +118,0 @@ */ |
@@ -91,2 +91,3 @@ /* | ||
| /** @type {T[]} */ | ||
| const sortedArray = [...this].sort(sortFn); | ||
@@ -93,0 +94,0 @@ super.clear(); |
@@ -65,2 +65,3 @@ /* | ||
| const newValue = (this._value = Buffer.allocUnsafe(len)); | ||
| /** @type {number} */ | ||
| let i; | ||
@@ -67,0 +68,0 @@ for (i = 0; i < valueLen; i++) { |
@@ -51,2 +51,3 @@ /* | ||
| /** @type {string} */ | ||
| this.name = "DeprecatedOptionWarning"; | ||
@@ -53,0 +54,0 @@ this.message = |
@@ -15,7 +15,11 @@ /* | ||
| /** @typedef {(wasmModuleSrcPath: string) => string} GenerateBeforeLoadBinaryCode */ | ||
| /** @typedef {(wasmModuleSrcPath: string) => string} GenerateLoadBinaryCode */ | ||
| /** @typedef {() => string} GenerateBeforeInstantiateStreaming */ | ||
| /** | ||
| * @typedef {object} AsyncWasmLoadingRuntimeModuleOptions | ||
| * @property {((wasmModuleSrcPath: string) => string)=} generateBeforeLoadBinaryCode | ||
| * @property {(wasmModuleSrcPath: string) => string} generateLoadBinaryCode | ||
| * @property {(() => string)=} generateBeforeInstantiateStreaming | ||
| * @property {GenerateLoadBinaryCode} generateLoadBinaryCode | ||
| * @property {GenerateBeforeLoadBinaryCode=} generateBeforeLoadBinaryCode | ||
| * @property {GenerateBeforeInstantiateStreaming=} generateBeforeInstantiateStreaming | ||
| * @property {boolean} supportsStreaming | ||
@@ -35,6 +39,10 @@ */ | ||
| super("wasm loading", RuntimeModule.STAGE_NORMAL); | ||
| /** @type {GenerateLoadBinaryCode} */ | ||
| this.generateLoadBinaryCode = generateLoadBinaryCode; | ||
| /** @type {generateBeforeLoadBinaryCode | undefined} */ | ||
| this.generateBeforeLoadBinaryCode = generateBeforeLoadBinaryCode; | ||
| /** @type {generateBeforeInstantiateStreaming | undefined} */ | ||
| this.generateBeforeInstantiateStreaming = | ||
| generateBeforeInstantiateStreaming; | ||
| /** @type {boolean} */ | ||
| this.supportsStreaming = supportsStreaming; | ||
@@ -41,0 +49,0 @@ } |
@@ -29,2 +29,3 @@ /* | ||
| super(); | ||
| /** @type {AsyncWebAssemblyGeneratorOptions} */ | ||
| this.options = options; | ||
@@ -31,0 +32,0 @@ } |
@@ -14,3 +14,3 @@ /* | ||
| const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency"); | ||
| const { compareModulesByIdOrIdentifier } = require("../util/comparators"); | ||
| const { compareModulesByFullName } = require("../util/comparators"); | ||
| const memoize = require("../util/memoize"); | ||
@@ -93,2 +93,3 @@ | ||
| constructor(options) { | ||
| /** @type {AsyncWebAssemblyModulesPluginOptions} */ | ||
| this.options = options; | ||
@@ -144,3 +145,3 @@ } | ||
| chunk, | ||
| compareModulesByIdOrIdentifier(chunkGraph) | ||
| compareModulesByFullName(compiler) | ||
| )) { | ||
@@ -147,0 +148,0 @@ if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) { |
@@ -10,5 +10,9 @@ /* | ||
| module.exports = class UnsupportedWebAssemblyFeatureError extends WebpackError { | ||
| /** @param {string} message Error message */ | ||
| /** | ||
| * @param {string} message Error message | ||
| */ | ||
| constructor(message) { | ||
| super(message); | ||
| /** @type {string} */ | ||
| this.name = "UnsupportedWebAssemblyFeatureError"; | ||
@@ -15,0 +19,0 @@ this.hideStack = true; |
@@ -34,2 +34,3 @@ /* | ||
| const wasmModules = chunk.getAllAsyncChunks(); | ||
| /** @type {Module[]} */ | ||
| const array = []; | ||
@@ -71,2 +72,3 @@ for (const chunk of wasmModules) { | ||
| const waitForInstances = new Map(); | ||
| /** @type {{ module: string, name: string, value: string }[]} */ | ||
| const properties = []; | ||
@@ -141,2 +143,3 @@ const usedWasmDependencies = WebAssemblyUtils.getUsedDependencies( | ||
| /** @type {string[]} */ | ||
| let importObject; | ||
@@ -143,0 +146,0 @@ if (mangle) { |
@@ -105,2 +105,4 @@ /* | ||
| super(message); | ||
| /** @type {string} */ | ||
| this.name = "WebAssemblyInInitialChunkError"; | ||
@@ -107,0 +109,0 @@ this.hideStack = true; |
@@ -63,3 +63,6 @@ /* | ||
| let needExportsCopy = false; | ||
| /** @typedef {{ dependency: ModuleDependency | undefined, importVar: string, index: number, request: string | undefined, names: Set<string>, reexports: string[] }} ImportData */ | ||
| /** @type {Map<Module, ImportData>} */ | ||
| const importedModules = new Map(); | ||
| /** @type {string[]} */ | ||
| const initParams = []; | ||
@@ -70,7 +73,8 @@ let index = 0; | ||
| dep && dep instanceof ModuleDependency ? dep : undefined; | ||
| if (moduleGraph.getModule(dep)) { | ||
| let importData = importedModules.get(moduleGraph.getModule(dep)); | ||
| const mod = moduleGraph.getModule(dep); | ||
| if (mod) { | ||
| let importData = importedModules.get(mod); | ||
| if (importData === undefined) { | ||
| importedModules.set( | ||
| moduleGraph.getModule(dep), | ||
| mod, | ||
| (importData = { | ||
@@ -77,0 +81,0 @@ dependency: moduleDep, |
@@ -16,3 +16,3 @@ /* | ||
| const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency"); | ||
| const { compareModulesByIdOrIdentifier } = require("../util/comparators"); | ||
| const { compareModulesByFullName } = require("../util/comparators"); | ||
| const memoize = require("../util/memoize"); | ||
@@ -93,3 +93,3 @@ const WebAssemblyInInitialChunkError = require("./WebAssemblyInInitialChunkError"); | ||
| chunk, | ||
| compareModulesByIdOrIdentifier(chunkGraph) | ||
| compareModulesByFullName(compiler) | ||
| )) { | ||
@@ -96,0 +96,0 @@ if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) { |
@@ -95,3 +95,4 @@ /* | ||
| /** @type {(ModuleImport | null)[]} */ | ||
| /** @typedef {ModuleImport | null} ImportNode */ | ||
| /** @type {ImportNode[]} */ | ||
| const importedGlobals = []; | ||
@@ -143,2 +144,3 @@ | ||
| /** @type {ImportNode} */ | ||
| let importNode = null; | ||
@@ -145,0 +147,0 @@ |
@@ -23,2 +23,3 @@ /* | ||
| if (set === undefined) { | ||
| /** @type {WasmLoadingTypes} */ | ||
| set = new Set(); | ||
@@ -25,0 +26,0 @@ enabledTypes.set(compiler, set); |
@@ -11,5 +11,5 @@ /* | ||
| /** @typedef {import("watchpack").TimeInfoEntries} TimeInfoEntries */ | ||
| /** @typedef {import("../declarations/plugins/WatchIgnorePlugin").WatchIgnorePluginOptions} WatchIgnorePluginOptions */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./util/fs").TimeInfoEntries} TimeInfoEntries */ | ||
| /** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */ | ||
@@ -16,0 +16,0 @@ /** @typedef {import("./util/fs").WatchMethod} WatchMethod */ |
+5
-0
@@ -18,2 +18,3 @@ /* | ||
| /** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */ | ||
| /** @typedef {import("./util/fs").Watcher} Watcher */ | ||
@@ -35,4 +36,6 @@ /** | ||
| constructor(compiler, watchOptions, handler) { | ||
| /** @type {null | number} */ | ||
| this.startTime = null; | ||
| this.invalid = false; | ||
| /** @type {Callback<Stats>} */ | ||
| this.handler = handler; | ||
@@ -69,3 +72,5 @@ /** @type {ErrorCallback[]} */ | ||
| this._needRecords = true; | ||
| /** @type {undefined | null | Watcher} */ | ||
| this.watcher = undefined; | ||
| /** @type {undefined | null | Watcher} */ | ||
| this.pausedWatcher = undefined; | ||
@@ -72,0 +77,0 @@ /** @type {CollectedFiles | undefined} */ |
@@ -27,2 +27,3 @@ /* | ||
| constructor(options = {}) { | ||
| /** @type {FetchCompileWasmPluginOptions} */ | ||
| this.options = options; | ||
@@ -29,0 +30,0 @@ } |
@@ -38,2 +38,3 @@ /* | ||
| }; | ||
| /** @type {WeakSet<Chunk>} */ | ||
| const onceForChunkSet = new WeakSet(); | ||
@@ -40,0 +41,0 @@ /** |
@@ -59,2 +59,3 @@ /* | ||
| super("jsonp chunk loading", RuntimeModule.STAGE_ATTACH); | ||
| /** @type {ReadOnlyRuntimeRequirements} */ | ||
| this._runtimeRequirements = runtimeRequirements; | ||
@@ -61,0 +62,0 @@ } |
+13
-3
@@ -18,3 +18,6 @@ /* | ||
| } = require("./config/defaults"); | ||
| const { getNormalizedWebpackOptions } = require("./config/normalization"); | ||
| const { | ||
| applyWebpackOptionsInterception, | ||
| getNormalizedWebpackOptions | ||
| } = require("./config/normalization"); | ||
| const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin"); | ||
@@ -26,2 +29,3 @@ const memoize = require("./util/memoize"); | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptionsNormalizedWithDefaults */ | ||
| /** @typedef {import("./config/normalization").WebpackOptionsInterception} WebpackOptionsInterception */ | ||
| /** @typedef {import("./Compiler").WatchOptions} WatchOptions */ | ||
@@ -73,4 +77,9 @@ /** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */ | ||
| const createCompiler = (rawOptions, compilerIndex) => { | ||
| const options = getNormalizedWebpackOptions(rawOptions); | ||
| let options = getNormalizedWebpackOptions(rawOptions); | ||
| applyWebpackOptionsBaseDefaults(options); | ||
| /** @type {WebpackOptionsInterception=} */ | ||
| let interception; | ||
| ({ options, interception } = applyWebpackOptionsInterception(options)); | ||
| const compiler = new Compiler( | ||
@@ -105,3 +114,4 @@ /** @type {string} */ (options.context), | ||
| (options), | ||
| compiler | ||
| compiler, | ||
| interception | ||
| ); | ||
@@ -108,0 +118,0 @@ compiler.hooks.initialize.call(); |
@@ -40,2 +40,5 @@ /* | ||
| /** | ||
| * @returns {string} inspect message | ||
| */ | ||
| [inspect]() { | ||
@@ -78,2 +81,3 @@ return ( | ||
| /** @type {typeof WebpackError} */ | ||
| module.exports = WebpackError; |
@@ -79,2 +79,3 @@ /* | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./config/normalization").WebpackOptionsInterception} WebpackOptionsInterception */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
@@ -94,5 +95,6 @@ /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ | ||
| * @param {Compiler} compiler compiler object | ||
| * @param {WebpackOptionsInterception=} interception intercepted options | ||
| * @returns {WebpackOptions} options object | ||
| */ | ||
| process(options, compiler) { | ||
| process(options, compiler, interception) { | ||
| compiler.outputPath = options.output.path; | ||
@@ -118,7 +120,3 @@ compiler.recordsInputPath = options.recordsInputPath || null; | ||
| new NodeTargetPlugin( | ||
| options.output.module && | ||
| compiler.platform.node === null && | ||
| compiler.platform.web === null | ||
| ? "module-import" | ||
| : "node-commonjs" | ||
| options.output.module ? "module-import" : "node-commonjs" | ||
| ).apply(compiler); | ||
@@ -135,4 +133,4 @@ | ||
| if ( | ||
| /\.css(\?|$)/.test(contextInfo.issuer) && | ||
| /^(\/\/|https?:\/\/|#)/.test(request) | ||
| /\.css(?:\?|$)/.test(contextInfo.issuer) && | ||
| /^(?:\/\/|https?:\/\/|#)/.test(request) | ||
| ) { | ||
@@ -163,3 +161,3 @@ if (dependencyType === "url") { | ||
| new ExternalsPlugin(type, ({ request, dependencyType }, callback) => { | ||
| if (/^(\/\/|https?:\/\/|#|std:|jsr:|npm:)/.test(request)) { | ||
| if (/^(?:\/\/|https?:\/\/|#|std:|jsr:|npm:)/.test(request)) { | ||
| if (dependencyType === "url") { | ||
@@ -174,3 +172,3 @@ return callback(null, `asset ${request}`); | ||
| return callback(null, `css-import ${request}`); | ||
| } else if (/^(\/\/|https?:\/\/|std:|jsr:|npm:)/.test(request)) { | ||
| } else if (/^(?:\/\/|https?:\/\/|std:|jsr:|npm:)/.test(request)) { | ||
| return callback(null, `${type} ${request}`); | ||
@@ -324,33 +322,55 @@ } | ||
| if (options.devtool) { | ||
| if (options.devtool.includes("source-map")) { | ||
| const hidden = options.devtool.includes("hidden"); | ||
| const inline = options.devtool.includes("inline"); | ||
| const evalWrapped = options.devtool.includes("eval"); | ||
| const cheap = options.devtool.includes("cheap"); | ||
| const moduleMaps = options.devtool.includes("module"); | ||
| const noSources = options.devtool.includes("nosources"); | ||
| const debugIds = options.devtool.includes("debugids"); | ||
| const Plugin = evalWrapped | ||
| ? require("./EvalSourceMapDevToolPlugin") | ||
| : require("./SourceMapDevToolPlugin"); | ||
| new Plugin({ | ||
| filename: inline ? null : options.output.sourceMapFilename, | ||
| moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate, | ||
| fallbackModuleFilenameTemplate: | ||
| options.output.devtoolFallbackModuleFilenameTemplate, | ||
| append: hidden ? false : undefined, | ||
| module: moduleMaps ? true : !cheap, | ||
| columns: !cheap, | ||
| noSources, | ||
| namespace: options.output.devtoolNamespace, | ||
| debugIds | ||
| }).apply(compiler); | ||
| } else if (options.devtool.includes("eval")) { | ||
| const EvalDevToolModulePlugin = require("./EvalDevToolModulePlugin"); | ||
| let devtool = | ||
| interception === undefined ? options.devtool : interception.devtool; | ||
| devtool = Array.isArray(devtool) | ||
| ? devtool | ||
| : typeof devtool === "string" | ||
| ? [{ type: "all", use: devtool }] | ||
| : []; | ||
| new EvalDevToolModulePlugin({ | ||
| moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate, | ||
| namespace: options.output.devtoolNamespace | ||
| }).apply(compiler); | ||
| for (const item of devtool) { | ||
| const { type, use } = item; | ||
| if (use) { | ||
| if (use.includes("source-map")) { | ||
| const hidden = use.includes("hidden"); | ||
| const inline = use.includes("inline"); | ||
| const evalWrapped = use.includes("eval"); | ||
| const cheap = use.includes("cheap"); | ||
| const moduleMaps = use.includes("module"); | ||
| const noSources = use.includes("nosources"); | ||
| const debugIds = use.includes("debugids"); | ||
| const Plugin = evalWrapped | ||
| ? require("./EvalSourceMapDevToolPlugin") | ||
| : require("./SourceMapDevToolPlugin"); | ||
| const assetExt = | ||
| type === "javascript" | ||
| ? /\.((c|m)?js)($|\?)/i | ||
| : type === "css" | ||
| ? /\.(css)($|\?)/i | ||
| : /\.((c|m)?js|css)($|\?)/i; | ||
| new Plugin({ | ||
| test: evalWrapped ? undefined : assetExt, | ||
| filename: inline ? null : options.output.sourceMapFilename, | ||
| moduleFilenameTemplate: | ||
| options.output.devtoolModuleFilenameTemplate, | ||
| fallbackModuleFilenameTemplate: | ||
| options.output.devtoolFallbackModuleFilenameTemplate, | ||
| append: hidden ? false : undefined, | ||
| module: moduleMaps ? true : !cheap, | ||
| columns: !cheap, | ||
| noSources, | ||
| namespace: options.output.devtoolNamespace, | ||
| debugIds | ||
| }).apply(compiler); | ||
| } else if (use.includes("eval")) { | ||
| const EvalDevToolModulePlugin = require("./EvalDevToolModulePlugin"); | ||
| new EvalDevToolModulePlugin({ | ||
| moduleFilenameTemplate: | ||
| options.output.devtoolModuleFilenameTemplate, | ||
| namespace: options.output.devtoolNamespace | ||
| }).apply(compiler); | ||
| } | ||
| } | ||
@@ -357,0 +377,0 @@ } |
@@ -43,2 +43,3 @@ /* | ||
| }; | ||
| /** @type {WeakSet<Chunk>} */ | ||
| const onceForChunkSet = new WeakSet(); | ||
@@ -45,0 +46,0 @@ /** |
+20
-28
| { | ||
| "name": "webpack", | ||
| "version": "5.104.1", | ||
| "version": "5.105.0", | ||
| "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", | ||
@@ -45,3 +45,2 @@ "homepage": "https://github.com/webpack/webpack", | ||
| "lint:spellcheck": "cspell --cache --no-must-find-files --quiet \"**/*.*\"", | ||
| "report:types": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html", | ||
| "validate:types": "tsc -p tsconfig.validation.json", | ||
@@ -59,3 +58,3 @@ "fmt": "yarn fmt:base --log-level warn --write", | ||
| "test": "yarn test:base", | ||
| "test:update-snapshots": "yarn test:base -u", | ||
| "test:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage", | ||
| "test:basic": "yarn test:base --testMatch \"<rootDir>/test/*.basictest.js\"", | ||
@@ -66,5 +65,10 @@ "test:basic:deno": "yarn test:base:deno --testMatch \"<rootDir>/test/*.basictest.js\"", | ||
| "test:base:deno": "deno --allow-read --allow-env --allow-sys --allow-ffi --allow-write --allow-run --v8-flags='--max-old-space-size=4096' ./node_modules/jest-cli/bin/jest.js --logHeapUsage", | ||
| "test:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage", | ||
| "cover": "yarn cover:all && yarn cover:report", | ||
| "cover:clean": "rimraf .nyc_output coverage", | ||
| "test:update-snapshots": "yarn test:base -u", | ||
| "report:cover": "nyc report --reporter=lcov --reporter=text -t coverage", | ||
| "report:cover:clean": "rimraf .nyc_output coverage", | ||
| "report:cover:merge": "yarn mkdirp .nyc_output && nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output", | ||
| "types:cover": "node node_modules/tooling/type-coverage", | ||
| "types:cover:report": "rimraf coverage && yarn types:cover && yarn report:cover && open-cli coverage/lcov-report/index.html", | ||
| "cover": "yarn cover:all && yarn report:cover", | ||
| "cover:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage", | ||
| "cover:all": "yarn cover:base --coverage", | ||
@@ -75,7 +79,3 @@ "cover:unit": "yarn cover:base --testMatch \"<rootDir>/test/*.unittest.js\" --coverage", | ||
| "cover:integration:a": "yarn cover:base --testMatch \"<rootDir>/test/*.{basictest,test}.js\" --coverage", | ||
| "cover:integration:b": "yarn cover:base --testMatch \"<rootDir>/test/*.longtest.js\" --coverage", | ||
| "cover:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage", | ||
| "cover:types": "node node_modules/tooling/type-coverage", | ||
| "cover:merge": "yarn mkdirp .nyc_output && nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output", | ||
| "cover:report": "nyc report --reporter=lcov --reporter=text -t coverage" | ||
| "cover:integration:b": "yarn cover:base --testMatch \"<rootDir>/test/*.longtest.js\" --coverage" | ||
| }, | ||
@@ -102,3 +102,3 @@ "lint-staged": { | ||
| "chrome-trace-event": "^1.0.2", | ||
| "enhanced-resolve": "^5.17.4", | ||
| "enhanced-resolve": "^5.19.0", | ||
| "es-module-lexer": "^2.0.0", | ||
@@ -116,3 +116,3 @@ "eslint-scope": "5.1.1", | ||
| "terser-webpack-plugin": "^5.3.16", | ||
| "watchpack": "^2.4.4", | ||
| "watchpack": "^2.5.1", | ||
| "webpack-sources": "^3.3.3" | ||
@@ -124,6 +124,4 @@ }, | ||
| "@changesets/cli": "^2.29.8", | ||
| "@changesets/get-github-info": "^0.7.0", | ||
| "@codspeed/core": "^5.0.1", | ||
| "@eslint/js": "^9.39.0", | ||
| "@eslint/markdown": "^7.4.0", | ||
| "@stylistic/eslint-plugin": "^5.6.0", | ||
| "@types/glob-to-regexp": "^0.4.4", | ||
@@ -133,3 +131,4 @@ "@types/graceful-fs": "^4.1.9", | ||
| "@types/mime-types": "^2.1.4", | ||
| "@types/node": "^24.10.1", | ||
| "@types/neo-async": "^2.6.7", | ||
| "@types/node": "^25.1.0", | ||
| "@types/xxhashjs": "^0.2.4", | ||
@@ -148,13 +147,6 @@ "assemblyscript": "^0.28.9", | ||
| "eslint": "^9.39.2", | ||
| "eslint-config-prettier": "^10.1.1", | ||
| "eslint-config-webpack": "^4.7.3", | ||
| "eslint-plugin-import": "^2.32.0", | ||
| "eslint-plugin-jest": "^29.5.0", | ||
| "eslint-plugin-jsdoc": "^61.5.0", | ||
| "eslint-plugin-n": "^17.23.1", | ||
| "eslint-plugin-prettier": "^5.5.0", | ||
| "eslint-plugin-unicorn": "^62.0.0", | ||
| "eslint-config-webpack": "^4.9.1", | ||
| "file-loader": "^6.0.0", | ||
| "fork-ts-checker-webpack-plugin": "^9.0.2", | ||
| "globals": "^16.0.0", | ||
| "globals": "^17.0.0", | ||
| "hash-wasm": "^4.9.0", | ||
@@ -199,5 +191,5 @@ "husky": "^9.0.11", | ||
| "three": "^0.182.0", | ||
| "tinybench": "^5.0.0", | ||
| "tinybench": "^6.0.0", | ||
| "toml": "^3.0.0", | ||
| "tooling": "webpack/tooling#v1.24.3", | ||
| "tooling": "webpack/tooling#v1.24.4", | ||
| "ts-loader": "^9.5.4", | ||
@@ -204,0 +196,0 @@ "typescript": "^5.9.3", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 4 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 3 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 4 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 3 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
5775664
1.44%79
-9.2%708
0.28%165510
1.37%269
-1.47%55
1.85%Updated
Updated