Socket
Socket
Sign inDemoInstall

webpack

Package Overview
Dependencies
76
Maintainers
4
Versions
832
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.90.3 to 5.91.0

lib/util/conventions.js

6

bin/webpack.js

@@ -122,2 +122,3 @@ #!/usr/bin/env node

/** @type {string | undefined} */
let packageManager;

@@ -175,3 +176,6 @@

runCommand(packageManager, installOptions.concat(cli.package))
runCommand(
/** @type {string} */ (packageManager),
installOptions.concat(cli.package)
)
.then(() => {

@@ -178,0 +182,0 @@ runCli(cli);

12

lib/APIPlugin.js

@@ -28,2 +28,3 @@ /*

/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./Module").BuildInfo} BuildInfo */
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */

@@ -191,3 +192,3 @@ /** @typedef {import("./javascript/JavascriptParser").Range} Range */

(source, module, renderContext) => {
if (module.buildInfo.needCreateRequire) {
if (/** @type {BuildInfo} */ (module.buildInfo).needCreateRequire) {
const chunkInitFragments = [

@@ -219,3 +220,4 @@ new InitFragment(

if (key === "__non_webpack_require__" && this.options.module) {
parser.state.module.buildInfo.needCreateRequire = true;
/** @type {BuildInfo} */
(parser.state.module.buildInfo).needCreateRequire = true;
}

@@ -273,3 +275,4 @@

.tap(PLUGIN_NAME, expr => {
parser.state.module.buildInfo.moduleConcatenationBailout =
/** @type {BuildInfo} */
(parser.state.module.buildInfo).moduleConcatenationBailout =
"__webpack_module__.id";

@@ -289,3 +292,4 @@ const dep = new ConstDependency(

.tap(PLUGIN_NAME, expr => {
parser.state.module.buildInfo.moduleConcatenationBailout =
/** @type {BuildInfo} */
(parser.state.module.buildInfo).moduleConcatenationBailout =
"__webpack_module__";

@@ -292,0 +296,0 @@ const dep = new ConstDependency(

@@ -74,3 +74,5 @@ /*

readableIdentifier(requestShortener) {
return requestShortener.shorten(this.readableIdentifierStr);
return /** @type {string} */ (
requestShortener.shorten(this.readableIdentifierStr)
);
}

@@ -77,0 +79,0 @@

@@ -16,3 +16,3 @@ /*

/**
* @typedef {GenerateContext} Context
* @extends {InitFragment<GenerateContext>}
*/

@@ -47,3 +47,3 @@ class AwaitDependenciesInitFragment extends InitFragment {

* @param {GenerateContext} context context
* @returns {string | Source} the source code that will be included as initialization code
* @returns {string | Source | undefined} the source code that will be included as initialization code
*/

@@ -50,0 +50,0 @@ getContent({ runtimeRequirements }) {

@@ -30,3 +30,3 @@ /*

);
/** @type {{context: string, request: string}[] | null} */
/** @type {{context: string | null, request: string}[] | null} */
let lastModules = null;

@@ -33,0 +33,0 @@ compiler.hooks.afterCompile.tap("AutomaticPrefetchPlugin", compilation => {

@@ -86,2 +86,4 @@ /*

const cache = new WeakMap();
const stage =
this.options.stage || Compilation.PROCESS_ASSETS_STAGE_ADDITIONS;

@@ -92,3 +94,3 @@ compiler.hooks.compilation.tap("BannerPlugin", compilation => {

name: "BannerPlugin",
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
stage
},

@@ -95,0 +97,0 @@ () => {

@@ -61,2 +61,12 @@ /*

/** @typedef {(Module | ConnectionState | ModuleGraphConnection)[]} BlockModulesInTuples */
/** @typedef {(Module | ConnectionState | ModuleGraphConnection[])[]} BlockModulesInFlattenTuples */
/** @typedef {Map<DependenciesBlock, BlockModulesInFlattenTuples>} BlockModulesMap */
/** @typedef {Map<Chunk, bigint>} MaskByChunk */
/** @typedef {Set<DependenciesBlock>} BlocksWithNestedBlocks */
/** @typedef {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} BlockConnections */
/** @typedef {Map<ChunkGroup, ChunkGroupInfo>} ChunkGroupInfoMap */
/** @typedef {Set<ChunkGroup>} AllCreatedChunkGroups */
/** @typedef {Map<Entrypoint, Module[]>} InputEntrypointsAndModules */
const ZERO_BIGINT = BigInt(0);

@@ -92,11 +102,22 @@ const ONE_BIGINT = BigInt(1);

/**
* @param {Module} module module
* @param {ModuleGraph} moduleGraph module graph
* @param {RuntimeSpec} runtime runtime
* @param {BlockModulesMap} blockModulesMap block modules map
*/
const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
/** @type {DependenciesBlock | undefined} */
let blockCache;
/** @type {BlockModulesInTuples | undefined} */
let modules;
/** @type {BlockModulesInTuples[]} */
const arrays = [];
/** @type {DependenciesBlock[]} */
const queue = [module];
while (queue.length > 0) {
const block = queue.pop();
const block = /** @type {DependenciesBlock} */ (queue.pop());
/** @type {Module[]} */
const arr = [];

@@ -125,13 +146,22 @@ arrays.push(arr);

if (index < 0) {
index = block.dependencies.indexOf(d);
index = /** @type {DependenciesBlock} */ (block).dependencies.indexOf(d);
}
if (blockCache !== block) {
modules = blockModulesMap.get((blockCache = block));
modules =
/** @type {BlockModulesInTuples} */
(
blockModulesMap.get(
(blockCache = /** @type {DependenciesBlock} */ (block))
)
);
}
const i = index * 3;
modules[i] = m;
modules[i + 1] = connection.getActiveState(runtime);
modules[i + 2] = connection;
/** @type {BlockModulesInTuples} */
(modules)[i] = m;
/** @type {BlockModulesInTuples} */
(modules)[i + 1] = connection.getActiveState(runtime);
/** @type {BlockModulesInTuples} */
(modules)[i + 2] = connection;
}

@@ -146,4 +176,4 @@

if (m === undefined) continue;
const state = modules[j + 1];
const connection = modules[j + 2];
const state = /** @type {ConnectionState} */ (modules[j + 1]);
const connection = /** @type {ModuleGraphConnection} */ (modules[j + 2]);
if (indexMap === undefined) {

@@ -153,4 +183,5 @@ let i = 0;

if (modules[i] === m) {
const merged = modules[i + 1];
modules[i + 2].push(connection);
const merged = /** @type {ConnectionState} */ (modules[i + 1]);
/** @type {ModuleGraphConnection[]} */
(/** @type {unknown} */ (modules[i + 2])).push(connection);
if (merged === true) continue outer;

@@ -168,3 +199,4 @@ modules[i + 1] = ModuleGraphConnection.addConnectionStates(

length++;
modules[length] = [connection];
/** @type {ModuleGraphConnection[]} */
(/** @type {unknown} */ (modules[length])) = [connection];
length++;

@@ -183,4 +215,5 @@ if (length > 30) {

if (idx !== undefined) {
const merged = modules[idx];
modules[idx + 1].push(connection);
const merged = /** @type {ConnectionState} */ (modules[idx]);
/** @type {ModuleGraphConnection[]} */
(/** @type {unknown} */ (modules[idx + 1])).push(connection);
if (merged === true) continue outer;

@@ -197,3 +230,7 @@ modules[idx] = ModuleGraphConnection.addConnectionStates(

length++;
modules[length] = [connection];
/** @type {ModuleGraphConnection[]} */
(
/** @type {unknown} */
(modules[length])
) = [connection];
length++;

@@ -211,8 +248,8 @@ }

* @param {Compilation} compilation the compilation
* @param {Map<Entrypoint, Module[]>} inputEntrypointsAndModules chunk groups which are processed with the modules
* @param {Map<ChunkGroup, ChunkGroupInfo>} chunkGroupInfoMap mapping from chunk group to available modules
* @param {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} blockConnections connection for blocks
* @param {Set<DependenciesBlock>} blocksWithNestedBlocks flag for blocks that have nested blocks
* @param {Set<ChunkGroup>} allCreatedChunkGroups filled with all chunk groups that are created here
* @param {Map<Chunk, bigint>} maskByChunk module content mask by chunk
* @param {InputEntrypointsAndModules} inputEntrypointsAndModules chunk groups which are processed with the modules
* @param {ChunkGroupInfoMap} chunkGroupInfoMap mapping from chunk group to available modules
* @param {BlockConnections} blockConnections connection for blocks
* @param {BlocksWithNestedBlocks} blocksWithNestedBlocks flag for blocks that have nested blocks
* @param {AllCreatedChunkGroups} allCreatedChunkGroups filled with all chunk groups that are created here
* @param {MaskByChunk} maskByChunk module content mask by chunk
*/

@@ -233,5 +270,3 @@ const visitModules = (

/** @type {RuntimeSpec | false} */
let blockModulesMapRuntime = false;
/** @type {Map<DependenciesBlock, (Module | ConnectionState)[]>} */
/** @type {BlockModulesMap | undefined} */
let blockModulesMap;

@@ -267,11 +302,9 @@

* @param {RuntimeSpec} runtime runtime
* @returns {(Module | ConnectionState | ModuleGraphConnection[])[]} block modules in flatten tuples
* @returns {BlockModulesInFlattenTuples} block modules in flatten tuples
*/
const getBlockModules = (block, runtime) => {
if (blockModulesMapRuntime !== runtime) {
blockModulesMap = blockModulesRuntimeMap.get(runtime);
if (blockModulesMap === undefined) {
blockModulesMap = new Map();
blockModulesRuntimeMap.set(runtime, blockModulesMap);
}
blockModulesMap = blockModulesRuntimeMap.get(runtime);
if (blockModulesMap === undefined) {
blockModulesMap = new Map();
blockModulesRuntimeMap.set(runtime, blockModulesMap);
}

@@ -300,5 +333,7 @@ let blockModules = blockModulesMap.get(block);

extractBlockModules(module, moduleGraph, runtime, blockModulesMap);
blockModules = blockModulesMap.get(block);
blockModules =
/** @type {BlockModulesInFlattenTuples} */
(blockModulesMap.get(block));
logger.timeAggregate("visitModules: prepare");
return /** @type {(Module | ConnectionState)[]} */ (blockModules);
return blockModules;
}

@@ -466,2 +501,3 @@ };

// but only once (blockChunkGroups map)
/** @type {ChunkGroupInfo | undefined} */
let cgi = blockChunkGroups.get(b);

@@ -481,4 +517,4 @@ /** @type {ChunkGroup | undefined} */

module,
b.loc,
b.request
/** @type {DependencyLocation} */ (b.loc),
/** @type {string} */ (b.request)
);

@@ -517,3 +553,7 @@ maskByChunk.set(entrypoint.chunks[0], ZERO_BIGINT);

// TODO merge entryOptions
entrypoint.addOrigin(module, b.loc, b.request);
entrypoint.addOrigin(
module,
/** @type {DependencyLocation} */ (b.loc),
/** @type {string} */ (b.request)
);
chunkGraph.connectBlockAndChunkGroup(b, entrypoint);

@@ -542,3 +582,3 @@ }

} else {
cgi = chunkName && namedChunkGroups.get(chunkName);
cgi = chunkName ? namedChunkGroups.get(chunkName) : undefined;
if (!cgi) {

@@ -548,4 +588,4 @@ c = compilation.addChunkInGroup(

module,
b.loc,
b.request
/** @type {DependencyLocation} */ (b.loc),
/** @type {string} */ (b.request)
);

@@ -581,3 +621,3 @@ maskByChunk.set(c.chunks[0], ZERO_BIGINT);

module,
b.loc
/** @type {DependencyLocation} */ (b.loc)
)

@@ -589,3 +629,7 @@ );

}
c.addOrigin(module, b.loc, b.request);
c.addOrigin(
module,
/** @type {DependencyLocation} */ (b.loc),
/** @type {string} */ (b.request)
);
}

@@ -595,3 +639,3 @@ blockConnections.set(b, []);

blockChunkGroups.set(b, /** @type {ChunkGroupInfo} */ (cgi));
blockByChunkGroups.set(cgi, b);
blockByChunkGroups.set(/** @type {ChunkGroupInfo} */ (cgi), b);
} else if (entryOptions) {

@@ -606,3 +650,4 @@ entrypoint = /** @type {Entrypoint} */ (cgi.chunkGroup);

// to connect it later if needed
blockConnections.get(b).push({
/** @type {BlockChunkGroupConnection[]} */
(blockConnections.get(b)).push({
originChunkGroupInfo: chunkGroupInfo,

@@ -646,3 +691,5 @@ chunkGroup: c

if (blockModules !== undefined) {
const { minAvailableModules } = chunkGroupInfo;
const minAvailableModules =
/** @type {bigint} */
(chunkGroupInfo.minAvailableModules);
// Buffer items because order need to be reversed to get indices correct

@@ -795,3 +842,3 @@ // Traverse all referenced modules

const moduleOrdinal = getModuleOrdinal(module);
let chunkMask = maskByChunk.get(chunk);
let chunkMask = /** @type {bigint} */ (maskByChunk.get(chunk));
chunkMask |= ONE_BIGINT << BigInt(moduleOrdinal);

@@ -863,7 +910,9 @@ maskByChunk.set(chunk, chunkMask);

let resultingAvailableModules = chunkGroupInfo.minAvailableModules;
let resultingAvailableModules = /** @type {bigint} */ (
chunkGroupInfo.minAvailableModules
);
// add the modules from the chunk group to the set
for (const chunk of chunkGroupInfo.chunkGroup.chunks) {
const mask = maskByChunk.get(chunk);
const mask = /** @type {bigint} */ (maskByChunk.get(chunk));
resultingAvailableModules |= mask;

@@ -1013,3 +1062,4 @@ }

if (isOrdinalSetInMask(minAvailableModules, ordinal)) {
info.skippedItems.add(module);
/** @type {NonNullable<ChunkGroupInfo["skippedItems"]>} */
(info.skippedItems).add(module);
continue;

@@ -1107,9 +1157,7 @@ }

/**
* @param {DependenciesBlock} current current
* @param {BlocksWithNestedBlocks} visited visited dependencies blocks
*/
const process = (current, visited) => {
if (visited.has(current)) {
return;
}
visited.add(current);
const blockModules = getBlockModules(current, runtime);

@@ -1128,3 +1176,8 @@ if (blockModules === undefined) {

const refModule = /** @type {Module} */ (blockModules[i]);
if (visited.has(refModule)) {
continue;
}
visited.add(refModule);
if (refModule) {

@@ -1158,5 +1211,5 @@ chunkGroup.setModulePreOrderIndex(refModule, preOrderIndex++);

* @param {Compilation} compilation the compilation
* @param {Set<DependenciesBlock>} blocksWithNestedBlocks flag for blocks that have nested blocks
* @param {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} blockConnections connection for blocks
* @param {Map<Chunk, bigint>} maskByChunk mapping from chunk to module mask
* @param {BlocksWithNestedBlocks} blocksWithNestedBlocks flag for blocks that have nested blocks
* @param {BlockConnections} blockConnections connection for blocks
* @param {MaskByChunk} maskByChunk mapping from chunk to module mask
*/

@@ -1180,3 +1233,3 @@ const connectChunkGroups = (

for (const chunk of chunkGroup.chunks) {
const chunkMask = maskByChunk.get(chunk);
const chunkMask = /** @type {bigint} */ (maskByChunk.get(chunk));
if ((chunkMask & availableModules) !== chunkMask) return false;

@@ -1201,3 +1254,3 @@ }

chunkGroup,
originChunkGroupInfo.resultingAvailableModules
/** @type {bigint} */ (originChunkGroupInfo.resultingAvailableModules)
)

@@ -1248,3 +1301,3 @@ )

* @param {Compilation} compilation the compilation
* @param {Map<Entrypoint, Module[]>} inputEntrypointsAndModules chunk groups which are processed with the modules
* @param {InputEntrypointsAndModules} inputEntrypointsAndModules chunk groups which are processed with the modules
* @returns {void}

@@ -1257,15 +1310,15 @@ */

/** @type {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} */
/** @type {BlockConnections} */
const blockConnections = new Map();
/** @type {Set<ChunkGroup>} */
/** @type {AllCreatedChunkGroups} */
const allCreatedChunkGroups = new Set();
/** @type {Map<ChunkGroup, ChunkGroupInfo>} */
/** @type {ChunkGroupInfoMap} */
const chunkGroupInfoMap = new Map();
/** @type {Set<DependenciesBlock>} */
/** @type {BlocksWithNestedBlocks} */
const blocksWithNestedBlocks = new Set();
/** @type {Map<Chunk, bigint>} */
/** @type {MaskByChunk} */
const maskByChunk = new Map();

@@ -1272,0 +1325,0 @@

@@ -24,3 +24,3 @@ /*

* @callback CallbackCache
* @param {(WebpackError | null)=} err
* @param {WebpackError | null} err
* @param {T=} result

@@ -37,2 +37,7 @@ * @returns {void}

/**
* @param {number} times times
* @param {function(Error=): void} callback callback
* @returns {function(Error=): void} callback
*/
const needCalls = (times, callback) => {

@@ -76,2 +81,3 @@ return err => {

get(identifier, etag, callback) {
/** @type {GotHandler[]} */
const gotHandlers = [];

@@ -78,0 +84,0 @@ this.hooks.get.callAsync(identifier, etag, gotHandlers, (err, result) => {

@@ -50,3 +50,3 @@ /*

* @param {HashableObject} obj object with updateHash method
* @param {string | HashConstructor} hashFunction the hash function to use
* @param {(string | HashConstructor)=} hashFunction the hash function to use
* @returns {LazyHashedEtag} etag

@@ -53,0 +53,0 @@ */

@@ -12,2 +12,3 @@ /*

/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("./PackFileCacheStrategy")} PackFileCacheStrategy */

@@ -18,3 +19,3 @@ const BUILD_DEPENDENCIES_KEY = Symbol();

/**
* @param {TODO} strategy cache strategy
* @param {PackFileCacheStrategy} strategy cache strategy
* @param {number} idleTimeout timeout

@@ -98,3 +99,5 @@ * @param {number} idleTimeoutForInitialStore initial timeout

pendingIdleTasks.set(BUILD_DEPENDENCIES_KEY, () =>
strategy.storeBuildDependencies(dependencies)
Promise.resolve().then(() =>
strategy.storeBuildDependencies(dependencies)
)
);

@@ -233,3 +236,5 @@ }

timeSpendInBuild *= 0.9;
timeSpendInBuild += stats.endTime - stats.startTime;
timeSpendInBuild +=
/** @type {number} */ (stats.endTime) -
/** @type {number} */ (stats.startTime);
});

@@ -236,0 +241,0 @@ }

@@ -22,3 +22,3 @@ /*

apply(compiler) {
/** @type {Map<string, { etag: Etag | null, data: any }>} */
/** @type {Map<string, { etag: Etag | null, data: any } | null>} */
const cache = new Map();

@@ -25,0 +25,0 @@ compiler.cache.hooks.store.tap(

@@ -16,2 +16,6 @@ /*

class MemoryWithGcCachePlugin {
/**
* @param {Object} options Options
* @param {number} options.maxGenerations max generations
*/
constructor({ maxGenerations }) {

@@ -27,5 +31,5 @@ this._maxGenerations = maxGenerations;

const maxGenerations = this._maxGenerations;
/** @type {Map<string, { etag: Etag | null, data: any }>} */
/** @type {Map<string, { etag: Etag | null, data: any } | undefined | null>} */
const cache = new Map();
/** @type {Map<string, { entry: { etag: Etag | null, data: any }, until: number }>} */
/** @type {Map<string, { entry: { etag: Etag | null, data: any } | null, until: number }>} */
const oldCache = new Map();

@@ -32,0 +36,0 @@ let generation = 0;

@@ -31,2 +31,5 @@ /*

/** @typedef {Map<string, string | false>} ResolveResults */
/** @typedef {Set<string>} Items */
/** @typedef {Set<string>} BuildDependencies */
/** @typedef {Map<string, PackItemInfo>} ItemInfo */

@@ -38,3 +41,3 @@ class PackContainer {

* @param {Snapshot} buildSnapshot snapshot of all build dependencies
* @param {Set<string>} buildDependencies list of all unresolved build dependencies captured
* @param {BuildDependencies} buildDependencies list of all unresolved build dependencies captured
* @param {ResolveResults} resolveResults result of the resolved build dependencies

@@ -59,2 +62,5 @@ * @param {Snapshot} resolveBuildDependenciesSnapshot snapshot of the dependencies of the build dependencies resolving

/**
* @param {ObjectSerializerContext} context context
*/
serialize({ write, writeLazy }) {

@@ -66,3 +72,4 @@ write(this.version);

write(this.resolveBuildDependenciesSnapshot);
writeLazy(this.data);
/** @type {NonNullable<ObjectSerializerContext["writeLazy"]>} */
(writeLazy)(this.data);
}

@@ -111,4 +118,8 @@

class Pack {
/**
* @param {Logger} logger a logger
* @param {number} maxAge max age of cache items
*/
constructor(logger, maxAge) {
/** @type {Map<string, PackItemInfo>} */
/** @type {ItemInfo} */
this.itemInfo = new Map();

@@ -118,3 +129,3 @@ /** @type {(string | undefined)[]} */

this.requestsTimeout = undefined;
/** @type {Map<string, PackItemInfo>} */
/** @type {ItemInfo} */
this.freshContent = new Map();

@@ -233,2 +244,8 @@ /** @type {(undefined | PackContent)[]} */

/**
* @private
* @param {Items} items items
* @param {Items} usedItems used items
* @param {number} newLoc new location
*/
_gcAndUpdateLocation(items, usedItems, newLoc) {

@@ -239,3 +256,3 @@ let count = 0;

for (const identifier of items) {
const info = this.itemInfo.get(identifier);
const info = /** @type {PackItemInfo} */ (this.itemInfo.get(identifier));
if (now - info.lastAccess > this.maxAge) {

@@ -274,3 +291,3 @@ this.itemInfo.delete(identifier);

const pack = {
/** @type {Set<string>} */
/** @type {Items} */
items: new Set(),

@@ -384,5 +401,5 @@ /** @type {Map<string, any>} */

// 4. Determine merged items
/** @type {Set<string>} */
/** @type {Items} */
const mergedItems = new Set();
/** @type {Set<string>} */
/** @type {Items} */
const mergedUsedItems = new Set();

@@ -557,2 +574,5 @@ /** @type {(function(Map<string, any>): Promise<void>)[]} */

/**
* @param {ObjectSerializerContext} context context
*/
serialize({ write, writeSeparate }) {

@@ -585,2 +605,5 @@ this._persistFreshContent();

/**
* @param {ObjectDeserializerContext & { logger: Logger }} context context
*/
deserialize({ read, logger }) {

@@ -644,2 +667,5 @@ this.logger = logger;

/**
* @param {ObjectSerializerContext & { snapshot: TODO, rollback: TODO, logger: Logger, profile: boolean | undefined }} context context
*/
serialize({ write, snapshot, rollback, logger, profile }) {

@@ -711,2 +737,5 @@ if (profile) {

/**
* @param {ObjectDeserializerContext & { logger: Logger, profile: boolean | undefined }} context context
*/
deserialize({ read, logger, profile }) {

@@ -777,4 +806,4 @@ if (read()) {

/**
* @param {Set<string>} items keys
* @param {Set<string>} usedItems used keys
* @param {Items} items keys
* @param {Items} usedItems used keys
* @param {PackContentItems | function(): Promise<PackContentItems>} dataOrFn sync or async content

@@ -786,5 +815,5 @@ * @param {Logger=} logger logger for logging

this.items = items;
/** @type {function(): Promise<PackContentItems> | PackContentItems} */
/** @type {(function(): Promise<PackContentItems> | PackContentItems) | undefined} */
this.lazy = typeof dataOrFn === "function" ? dataOrFn : undefined;
/** @type {Map<string, any>} */
/** @type {Map<string, any> | undefined} */
this.content = typeof dataOrFn === "function" ? undefined : dataOrFn.map;

@@ -797,2 +826,6 @@ this.outdated = false;

/**
* @param {string} identifier identifier
* @returns {string | Promise<string>} result
*/
get(identifier) {

@@ -1069,3 +1102,3 @@ this.used.add(identifier);

this.snapshot = snapshot;
/** @type {Set<string>} */
/** @type {BuildDependencies} */
this.buildDependencies = new Set();

@@ -1102,5 +1135,5 @@ /** @type {LazySet<string>} */

let buildSnapshot;
/** @type {Set<string>} */
/** @type {BuildDependencies} */
let buildDependencies;
/** @type {Set<string>} */
/** @type {BuildDependencies} */
let newBuildDependencies;

@@ -1294,3 +1327,3 @@ /** @type {Snapshot} */

/**
* @param {LazySet<string>} dependencies dependencies to store
* @param {LazySet<string> | Iterable<string>} dependencies dependencies to store
*/

@@ -1297,0 +1330,0 @@ storeBuildDependencies(dependencies) {

@@ -11,3 +11,3 @@ /*

/** @typedef {import("enhanced-resolve/lib/Resolver")} Resolver */
/** @typedef {import("enhanced-resolve").Resolver} Resolver */
/** @typedef {import("../CacheFacade").ItemCacheFacade} ItemCacheFacade */

@@ -217,3 +217,6 @@ /** @typedef {import("../Compiler")} Compiler */

(request, resolveContext, callback) => {
if (request._ResolverCachePluginCacheMiss || !fileSystemInfo) {
if (
/** @type {TODO} */ (request)._ResolverCachePluginCacheMiss ||
!fileSystemInfo
) {
return callback();

@@ -230,3 +233,5 @@ }

activeRequest[0].push(callback);
activeRequest[1].push(resolveContext.yield);
activeRequest[1].push(
/** @type {TODO} */ (resolveContext.yield)
);
return;

@@ -309,3 +314,4 @@ }

addAllToSet(
resolveContext.missingDependencies,
/** @type {LazySet<string>} */
(resolveContext.missingDependencies),
snapshot.getMissingIterable()

@@ -316,3 +322,4 @@ );

addAllToSet(
resolveContext.fileDependencies,
/** @type {LazySet<string>} */
(resolveContext.fileDependencies),
snapshot.getFileIterable()

@@ -323,3 +330,4 @@ );

addAllToSet(
resolveContext.contextDependencies,
/** @type {LazySet<string>} */
(resolveContext.contextDependencies),
snapshot.getContextIterable()

@@ -326,0 +334,0 @@ );

@@ -22,4 +22,4 @@ /*

* @callback CallbackCache
* @param {(WebpackError | null)=} err
* @param {T=} result
* @param {(Error | null)=} err
* @param {(T | null)=} result
* @returns {void}

@@ -200,3 +200,3 @@ */

* @param {string} name the child cache name
* @param {string | HashConstructor} hashFunction the hash function to use
* @param {(string | HashConstructor)=} hashFunction the hash function to use
*/

@@ -203,0 +203,0 @@ constructor(cache, name, hashFunction) {

@@ -36,2 +36,3 @@ /*

/** @typedef {import("./ModuleGraph")} ModuleGraph */
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
/** @typedef {import("./RuntimeModule")} RuntimeModule */

@@ -59,2 +60,6 @@ /** @typedef {typeof import("./util/Hash")} Hash */

class ModuleHashInfo {
/**
* @param {string} hash hash
* @param {string} renderedHash rendered hash
*/
constructor(hash, renderedHash) {

@@ -185,2 +190,5 @@ this.hash = hash;

/** @typedef {Set<Chunk>} EntryInChunks */
/** @typedef {Set<Chunk>} RuntimeInChunks */
class ChunkGraphModule {

@@ -190,5 +198,5 @@ constructor() {

this.chunks = new SortableSet();
/** @type {Set<Chunk> | undefined} */
/** @type {EntryInChunks | undefined} */
this.entryInChunks = undefined;
/** @type {Set<Chunk> | undefined} */
/** @type {RuntimeInChunks | undefined} */
this.runtimeInChunks = undefined;

@@ -201,5 +209,5 @@ /** @type {RuntimeSpecMap<ModuleHashInfo> | undefined} */

this.runtimeRequirements = undefined;
/** @type {RuntimeSpecMap<string>} */
/** @type {RuntimeSpecMap<string> | undefined} */
this.graphHashes = undefined;
/** @type {RuntimeSpecMap<string>} */
/** @type {RuntimeSpecMap<string> | undefined} */
this.graphHashesWithConnections = undefined;

@@ -292,2 +300,5 @@ }

const set = new Set();
/**
* @param {Module} module module
*/
const addDependencies = module => {

@@ -426,3 +437,3 @@ for (const connection of moduleGraph.getOutgoingConnections(module)) {

const cgc = this._getChunkGraphChunk(chunk);
const old = cgc.entryModules.get(oldModule);
const old = /** @type {Entrypoint} */ (cgc.entryModules.get(oldModule));
/** @type {Map<Module, Entrypoint>} */

@@ -726,3 +737,3 @@ const newEntryModules = new Map();

: chunk.getAllAsyncChunks()) {
/** @type {(string|number)[]} */
/** @type {(string | number)[] | undefined} */
let array;

@@ -766,3 +777,3 @@ for (const module of this.getOrderedChunkModulesIterable(

: chunk.getAllAsyncChunks()) {
/** @type {Record<string|number, string>} */
/** @type {Record<string|number, string> | undefined} */
let idToHashMap;

@@ -1127,3 +1138,3 @@ for (const module of this.getOrderedChunkModulesIterable(

const cgm = this._getChunkGraphModule(module);
for (const chunk of cgm.entryInChunks) {
for (const chunk of /** @type {EntryInChunks} */ (cgm.entryInChunks)) {
const cgc = this._getChunkGraphChunk(chunk);

@@ -1236,10 +1247,3 @@ cgc.entryModules.delete(module);

concatComparators(
compareSelect(
/**
* @param {RuntimeModule} r runtime module
* @returns {number=} stage
*/
r => r.stage,
compareIds
),
compareSelect(r => /** @type {RuntimeModule} */ (r).stage, compareIds),
compareModulesByIdentifier

@@ -1289,3 +1293,3 @@ )

* @param {AsyncDependenciesBlock} depBlock the async block
* @returns {ChunkGroup} the chunk group
* @returns {ChunkGroup | undefined} the chunk group
*/

@@ -1379,3 +1383,3 @@ getBlockChunkGroup(depBlock) {

}
return first(hashInfoItems);
return /** @type {T} */ (first(hashInfoItems));
} else {

@@ -1592,2 +1596,6 @@ const hashInfo = hashes.get(runtime);

}
/**
* @param {ConnectionState} state state
* @returns {"F" | "T" | "O"} result
*/
const activeStateToString = state => {

@@ -1663,2 +1671,5 @@ if (state === false) return "F";

const hash = createHash(this._hashFunction);
/**
* @param {Module} module module
*/
const addModuleToHash = module => {

@@ -1673,2 +1684,5 @@ hash.update(

};
/**
* @param {Set<Module>} modules modules
*/
const addModulesToHash = modules => {

@@ -1675,0 +1689,0 @@ let xor = ZERO_BIG_INT;

@@ -73,3 +73,3 @@ /*

* Creates an instance of ChunkGroup.
* @param {string|ChunkGroupOptions=} options chunk group options passed to chunkGroup
* @param {string | ChunkGroupOptions=} options chunk group options passed to chunkGroup
*/

@@ -84,3 +84,3 @@ constructor(options) {

this.groupDebugId = debugId++;
this.options = options;
this.options = /** @type {ChunkGroupOptions} */ (options);
/** @type {SortableSet<ChunkGroup>} */

@@ -113,14 +113,14 @@ this._children = new SortableSet(undefined, sortById);

addOptions(options) {
for (const key of Object.keys(options)) {
if (
this.options[/** @type {keyof ChunkGroupOptions} */ (key)] === undefined
) {
this.options[key] =
options[/** @type {keyof ChunkGroupOptions} */ (key)];
} else if (
this.options[/** @type {keyof ChunkGroupOptions} */ (key)] !==
options[/** @type {keyof ChunkGroupOptions} */ (key)]
) {
for (const _key of Object.keys(options)) {
const key = /** @type {keyof ChunkGroupOptions} */ (_key);
if (this.options[key] === undefined) {
/** @type {TODO} */
(this.options)[key] = options[key];
} else if (this.options[key] !== options[key]) {
if (key.endsWith("Order")) {
this.options[key] = Math.max(this.options[key], options[key]);
/** @type {TODO} */
(this.options)[key] = Math.max(
/** @type {number} */ (this.options[key]),
/** @type {number} */ (options[key])
);
} else {

@@ -225,3 +225,3 @@ throw new Error(

* @param {Chunk} newChunk New chunk that will be replaced with
* @returns {boolean} returns true if the replacement was successful
* @returns {boolean | undefined} returns true if the replacement was successful
*/

@@ -228,0 +228,0 @@ replaceChunk(oldChunk, newChunk) {

@@ -18,2 +18,3 @@ /*

/** @typedef {import("./logging/Logger").Logger} Logger */
/** @typedef {import("./util/fs").IStats} IStats */
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */

@@ -92,4 +93,4 @@ /** @typedef {import("./util/fs").StatsCallback} StatsCallback */

}
for (const entry of entries) {
const file = /** @type {string} */ (entry);
for (const entry of /** @type {string[]} */ (entries)) {
const file = entry;
const filename = directory ? `${directory}/${file}` : file;

@@ -201,3 +202,3 @@ if (!directories.has(filename) && !currentAssets.has(filename)) {

if (err) return handleError(err);
if (!stats.isDirectory()) {
if (!(/** @type {IStats} */ (stats).isDirectory())) {
push({

@@ -212,3 +213,3 @@ type: "unlink",

/** @type {NonNullable<OutputFileSystem["readdir"]>} */
(fs.readdir)(path, (err, entries) => {
(fs.readdir)(path, (err, _entries) => {
if (err) return handleError(err);

@@ -221,2 +222,3 @@ /** @type {Job} */

};
const entries = /** @type {string[]} */ (_entries);
if (entries.length === 0) {

@@ -363,3 +365,3 @@ push(deleteJob);

const logger = compilation.getLogger("webpack.CleanPlugin");
const fs = compiler.outputFileSystem;
const fs = /** @type {OutputFileSystem} */ (compiler.outputFileSystem);

@@ -366,0 +368,0 @@ if (!fs.readdir) {

@@ -43,6 +43,10 @@ /*

/** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./Compilation").References} References */
/** @typedef {import("./Dependency")} Dependency */
/** @typedef {import("./FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
/** @typedef {import("./Module")} Module */
/** @typedef {import("./Module").BuildInfo} BuildInfo */
/** @typedef {import("./logging/createConsoleLogger").LoggingFunction} LoggingFunction */
/** @typedef {import("./util/WeakTupleMap")} WeakTupleMap */
/** @typedef {import("./util/fs").IStats} IStats */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */

@@ -61,2 +65,9 @@ /** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */

* @template T
* @callback RunCallback
* @param {Error | null} err
* @param {T=} result
*/
/**
* @template T
* @callback Callback

@@ -69,3 +80,3 @@ * @param {(Error | null)=} err

* @callback RunAsChildCallback
* @param {(Error | null)=} err
* @param {Error | null} err
* @param {Chunk[]=} entries

@@ -84,2 +95,5 @@ * @param {Compilation=} compilation

/** @typedef {{ sizeOnlySource: SizeOnlySource | undefined, writtenTo: Map<string, number> }} CacheEntry */
/** @typedef {{ path: string, source: Source, size: number | undefined, waiting: ({ cacheEntry: any, file: string }[] | undefined) }} SimilarEntry */
/**

@@ -97,7 +111,8 @@ * @param {string[]} array an array

/**
* @param {Object} obj an object
* @param {Object<string, any>} obj an object
* @param {string[]} keys the keys of the object
* @returns {Object} the object with properties sorted by property name
* @returns {Object<string, any>} the object with properties sorted by property name
*/
const sortObject = (obj, keys) => {
/** @type {Object<string, any>} */
const o = {};

@@ -208,5 +223,5 @@ for (const k of keys.sort()) {

/** @type {string=} */
/** @type {string | undefined} */
this.name = undefined;
/** @type {Compilation=} */
/** @type {Compilation | undefined} */
this.parentCompilation = undefined;

@@ -220,9 +235,9 @@ /** @type {Compiler} */

/** @type {OutputFileSystem} */
/** @type {OutputFileSystem | null} */
this.outputFileSystem = null;
/** @type {IntermediateFileSystem} */
/** @type {IntermediateFileSystem | null} */
this.intermediateFileSystem = null;
/** @type {InputFileSystem} */
/** @type {InputFileSystem | null} */
this.inputFileSystem = null;
/** @type {WatchFileSystem} */
/** @type {WatchFileSystem | null} */
this.watchFileSystem = null;

@@ -234,2 +249,3 @@

this.recordsOutputPath = null;
/** @type {Record<string, TODO>} */
this.records = {};

@@ -257,2 +273,3 @@ /** @type {Set<string | RegExp>} */

/** @type {LoggingFunction | undefined} */
this.infrastructureLogger = undefined;

@@ -268,3 +285,3 @@

/** @type {Map<Module, { buildInfo: object, references: WeakMap<Dependency, Module>, memCache: WeakTupleMap }> | undefined} */
/** @type {Map<Module, { buildInfo: BuildInfo, references: References | undefined, memCache: WeakTupleMap }> | undefined} */
this.moduleMemCaches = undefined;

@@ -285,8 +302,8 @@

/** @type {Compilation} */
/** @type {Compilation | undefined} */
this._lastCompilation = undefined;
/** @type {NormalModuleFactory} */
/** @type {NormalModuleFactory | undefined} */
this._lastNormalModuleFactory = undefined;
/** @private @type {WeakMap<Source, { sizeOnlySource: SizeOnlySource, writtenTo: Map<string, number> }>} */
/** @private @type {WeakMap<Source, CacheEntry>} */
this._assetEmittingSourceCache = new WeakMap();

@@ -430,3 +447,3 @@ /** @private @type {Map<string, number>} */

* @param {WatchOptions} watchOptions the watcher's options
* @param {Callback<Stats>} handler signals when the call finishes
* @param {RunCallback<Stats>} handler signals when the call finishes
* @returns {Watching} a compiler watcher

@@ -446,3 +463,3 @@ */

/**
* @param {Callback<Stats>} callback signals when the call finishes
* @param {RunCallback<Stats>} callback signals when the call finishes
* @returns {void}

@@ -455,4 +472,9 @@ */

/** @type {Logger | undefined} */
let logger;
/**
* @param {Error | null} err error
* @param {Stats=} stats stats
*/
const finalCallback = (err, stats) => {

@@ -469,3 +491,3 @@ if (logger) logger.time("beginIdle");

if (callback !== undefined) callback(err, stats);
this.hooks.afterDone.call(stats);
this.hooks.afterDone.call(/** @type {Stats} */ (stats));
};

@@ -477,5 +499,12 @@

const onCompiled = (err, compilation) => {
/**
* @param {Error | null} err error
* @param {Compilation=} _compilation compilation
* @returns {void}
*/
const onCompiled = (err, _compilation) => {
if (err) return finalCallback(err);
const compilation = /** @type {Compilation} */ (_compilation);
if (this.hooks.shouldEmit.call(compilation) === false) {

@@ -496,3 +525,4 @@ compilation.startTime = startTime;

this.emitAssets(compilation, err => {
logger.timeEnd("emitAssets");
/** @type {Logger} */
(logger).timeEnd("emitAssets");
if (err) return finalCallback(err);

@@ -505,6 +535,8 @@

compilation.endTime = Date.now();
logger.time("done hook");
/** @type {Logger} */
(logger).time("done hook");
const stats = new Stats(compilation);
this.hooks.done.callAsync(stats, err => {
logger.timeEnd("done hook");
/** @type {Logger} */
(logger).timeEnd("done hook");
if (err) return finalCallback(err);

@@ -520,5 +552,7 @@

logger.time("emitRecords");
/** @type {Logger} */
(logger).time("emitRecords");
this.emitRecords(err => {
logger.timeEnd("emitRecords");
/** @type {Logger} */
(logger).timeEnd("emitRecords");
if (err) return finalCallback(err);

@@ -528,6 +562,8 @@

compilation.endTime = Date.now();
logger.time("done hook");
/** @type {Logger} */
(logger).time("done hook");
const stats = new Stats(compilation);
this.hooks.done.callAsync(stats, err => {
logger.timeEnd("done hook");
/** @type {Logger} */
(logger).timeEnd("done hook");
if (err) return finalCallback(err);

@@ -582,2 +618,7 @@ this.cache.storeBuildDependencies(

/**
* @param {Error | null} err error
* @param {Chunk[]=} entries entries
* @param {Compilation=} compilation compilation
*/
const finalCallback = (err, entries, compilation) => {

@@ -590,16 +631,25 @@ try {

);
err.details = e.stack;
this.parentCompilation.errors.push(err);
err.details = /** @type {Error} */ (e).stack;
/** @type {Compilation} */
(this.parentCompilation).errors.push(err);
}
};
this.compile((err, compilation) => {
this.compile((err, _compilation) => {
if (err) return finalCallback(err);
this.parentCompilation.children.push(compilation);
const compilation = /** @type {Compilation} */ (_compilation);
const parentCompilation = /** @type {Compilation} */ (
this.parentCompilation
);
parentCompilation.children.push(compilation);
for (const { name, source, info } of compilation.getAssets()) {
this.parentCompilation.emitAsset(name, source, info);
parentCompilation.emitAsset(name, source, info);
}
/** @type {Chunk[]} */
const entries = [];
for (const ep of compilation.entrypoints.values()) {

@@ -628,4 +678,9 @@ entries.push(...ep.chunks);

emitAssets(compilation, callback) {
/** @type {string} */
let outputPath;
/**
* @param {Error=} err error
* @returns {void}
*/
const emitFiles = err => {

@@ -636,3 +691,3 @@ if (err) return callback(err);

compilation.assets = { ...compilation.assets };
/** @type {Map<string, { path: string, source: Source, size: number, waiting: { cacheEntry: any, file: string }[] }>} */
/** @type {Map<string, SimilarEntry>} */
const caseInsensitiveMap = new Map();

@@ -661,6 +716,11 @@ /** @type {Set<string>} */

/**
* @param {Error=} err error
* @returns {void}
*/
const writeOut = err => {
if (err) return callback(err);
const targetPath = join(
this.outputFileSystem,
/** @type {OutputFileSystem} */
(this.outputFileSystem),
outputPath,

@@ -685,2 +745,3 @@ targetFile

/** @type {SimilarEntry | undefined} */
let similarEntry;

@@ -716,3 +777,3 @@

caseInsensitiveTargetPath,
(similarEntry = {
(similarEntry = /** @type {SimilarEntry} */ ({
path: targetPath,

@@ -722,3 +783,3 @@ source,

waiting: undefined
})
}))
);

@@ -751,5 +812,7 @@ return false;

this._assetEmittingWrittenFiles.set(targetPath, newGeneration);
cacheEntry.writtenTo.set(targetPath, newGeneration);
/** @type {CacheEntry} */
(cacheEntry).writtenTo.set(targetPath, newGeneration);
} else {
cacheEntry.writtenTo.set(targetPath, targetFileGeneration);
/** @type {CacheEntry} */
(cacheEntry).writtenTo.set(targetPath, targetFileGeneration);
}

@@ -765,3 +828,4 @@ callback();

const doWrite = content => {
this.outputFileSystem.writeFile(targetPath, content, err => {
/** @type {OutputFileSystem} */
(this.outputFileSystem).writeFile(targetPath, content, err => {
if (err) return callback(err);

@@ -777,3 +841,4 @@

: targetFileGeneration + 1;
cacheEntry.writtenTo.set(targetPath, newGeneration);
/** @type {CacheEntry} */
(cacheEntry).writtenTo.set(targetPath, newGeneration);
this._assetEmittingWrittenFiles.set(targetPath, newGeneration);

@@ -794,7 +859,19 @@ this.hooks.assetEmitted.callAsync(

/**
* @param {number} size size
*/
const updateWithReplacementSource = size => {
updateFileWithReplacementSource(file, cacheEntry, size);
similarEntry.size = size;
if (similarEntry.waiting !== undefined) {
for (const { file, cacheEntry } of similarEntry.waiting) {
updateFileWithReplacementSource(
file,
/** @type {CacheEntry} */ (cacheEntry),
size
);
/** @type {SimilarEntry} */
(similarEntry).size = size;
if (
/** @type {SimilarEntry} */ (similarEntry).waiting !== undefined
) {
for (const { file, cacheEntry } of /** @type {SimilarEntry} */ (
similarEntry
).waiting) {
updateFileWithReplacementSource(file, cacheEntry, size);

@@ -805,2 +882,7 @@ }

/**
* @param {string} file file
* @param {CacheEntry} cacheEntry cache entry
* @param {number} size size
*/
const updateFileWithReplacementSource = (

@@ -822,6 +904,10 @@ file,

/**
* @param {IStats} stats stats
* @returns {void}
*/
const processExistingFile = stats => {
// skip emitting if it's already there and an immutable file
if (immutable) {
updateWithReplacementSource(stats.size);
updateWithReplacementSource(/** @type {number} */ (stats.size));
return alreadyWritten();

@@ -840,15 +926,14 @@ }

compilation.comparedForEmitAssets.add(file);
return this.outputFileSystem.readFile(
targetPath,
(err, existingContent) => {
if (
err ||
!content.equals(/** @type {Buffer} */ (existingContent))
) {
return doWrite(content);
} else {
return alreadyWritten();
}
return /** @type {OutputFileSystem} */ (
this.outputFileSystem
).readFile(targetPath, (err, existingContent) => {
if (
err ||
!content.equals(/** @type {Buffer} */ (existingContent))
) {
return doWrite(content);
} else {
return alreadyWritten();
}
);
});
}

@@ -870,3 +955,5 @@

// check if the Source has been written to this target file
const writtenGeneration = cacheEntry.writtenTo.get(targetPath);
const writtenGeneration = /** @type {CacheEntry} */ (
cacheEntry
).writtenTo.get(targetPath);
if (writtenGeneration === targetFileGeneration) {

@@ -878,5 +965,9 @@ // if yes, we may skip writing the file

if (this._assetEmittingPreviousFiles.has(targetPath)) {
const sizeOnlySource = /** @type {SizeOnlySource} */ (
/** @type {CacheEntry} */ (cacheEntry).sizeOnlySource
);
// We assume that assets from the last compilation say intact on disk (they are not removed)
compilation.updateAsset(file, cacheEntry.sizeOnlySource, {
size: cacheEntry.sizeOnlySource.size()
compilation.updateAsset(file, sizeOnlySource, {
size: sizeOnlySource.size()
});

@@ -900,7 +991,8 @@

if (this.options.output.compareBeforeEmit) {
this.outputFileSystem.stat(targetPath, (err, stats) => {
const exists = !err && stats.isFile();
/** @type {OutputFileSystem} */
(this.outputFileSystem).stat(targetPath, (err, stats) => {
const exists = !err && /** @type {IStats} */ (stats).isFile();
if (exists) {
processExistingFile(stats);
processExistingFile(/** @type {IStats} */ (stats));
} else {

@@ -916,3 +1008,3 @@ processMissingFile();

if (targetFile.match(/\/|\\/)) {
const fs = this.outputFileSystem;
const fs = /** @type {OutputFileSystem} */ (this.outputFileSystem);
const dir = dirname(fs, join(fs, outputPath, targetFile));

@@ -946,3 +1038,7 @@ mkdirp(fs, dir, writeOut);

outputPath = compilation.getPath(this.outputPath, {});
mkdirp(this.outputFileSystem, outputPath, emitFiles);
mkdirp(
/** @type {OutputFileSystem} */ (this.outputFileSystem),
outputPath,
emitFiles
);
});

@@ -983,4 +1079,5 @@ }

const writeFile = () => {
this.outputFileSystem.writeFile(
this.recordsOutputPath,
/** @type {OutputFileSystem} */
(this.outputFileSystem).writeFile(
/** @type {string} */ (this.recordsOutputPath),
JSON.stringify(

@@ -1008,4 +1105,4 @@ this.records,

const recordsOutputPathDirectory = dirname(
this.outputFileSystem,
this.recordsOutputPath
/** @type {OutputFileSystem} */ (this.outputFileSystem),
/** @type {string} */ (this.recordsOutputPath)
);

@@ -1015,6 +1112,10 @@ if (!recordsOutputPathDirectory) {

}
mkdirp(this.outputFileSystem, recordsOutputPathDirectory, err => {
if (err) return callback(err);
writeFile();
});
mkdirp(
/** @type {OutputFileSystem} */ (this.outputFileSystem),
recordsOutputPathDirectory,
err => {
if (err) return callback(err);
writeFile();
}
);
}

@@ -1059,3 +1160,4 @@

}
this.inputFileSystem.stat(this.recordsInputPath, err => {
/** @type {InputFileSystem} */
(this.inputFileSystem).stat(this.recordsInputPath, err => {
// It doesn't exist

@@ -1065,13 +1167,23 @@ // We can ignore this.

this.inputFileSystem.readFile(this.recordsInputPath, (err, content) => {
if (err) return callback(err);
/** @type {InputFileSystem} */
(this.inputFileSystem).readFile(
/** @type {string} */ (this.recordsInputPath),
(err, content) => {
if (err) return callback(err);
try {
this.records = parseJson(content.toString("utf-8"));
} catch (e) {
return callback(new Error(`Cannot parse records: ${e.message}`));
try {
this.records = parseJson(
/** @type {Buffer} */ (content).toString("utf-8")
);
} catch (e) {
return callback(
new Error(
`Cannot parse records: ${/** @type {Error} */ (e).message}`
)
);
}
return callback();
}
return callback();
});
);
});

@@ -1170,2 +1282,6 @@ }

/**
* @param {CompilationParams} params the compilation parameters
* @returns {Compilation} compilation
*/
createCompilation(params) {

@@ -1193,3 +1309,3 @@ this._cleanupLastCompilation();

context: this.options.context,
fs: this.inputFileSystem,
fs: /** @type {InputFileSystem} */ (this.inputFileSystem),
resolverFactory: this.resolverFactory,

@@ -1220,3 +1336,3 @@ options: this.options.module,

/**
* @param {Callback<Compilation>} callback signals when the compilation finishes
* @param {RunCallback<Compilation>} callback signals when the compilation finishes
* @returns {void}

@@ -1272,3 +1388,3 @@ */

/**
* @param {Callback<void>} callback signals when the compiler closes
* @param {RunCallback<void>} callback signals when the compiler closes
* @returns {void}

@@ -1275,0 +1391,0 @@ */

@@ -40,8 +40,7 @@ /*

/**
* @typedef {GenerateContext} Context
* @extends {InitFragment<Context>}
* @extends {InitFragment<GenerateContext>}
*/
class ConditionalInitFragment extends InitFragment {
/**
* @param {string|Source} content the source code that will be included as initialization code
* @param {string | Source | undefined} content the source code that will be included as initialization code
* @param {number} stage category of initialization code (contribute to order)

@@ -51,3 +50,3 @@ * @param {number} position position in the category (contribute to order)

* @param {RuntimeSpec | boolean} runtimeCondition in which runtime this fragment should be executed
* @param {string|Source=} endContent the source code that will be included at the end of the module
* @param {string | Source=} endContent the source code that will be included at the end of the module
*/

@@ -68,3 +67,3 @@ constructor(

* @param {GenerateContext} context context
* @returns {string | Source} the source code that will be included as initialization code
* @returns {string | Source | undefined} the source code that will be included as initialization code
*/

@@ -71,0 +70,0 @@ getContent(context) {

@@ -475,3 +475,2 @@ /*

});
F(snapshot, "unmanagedPaths", () => []);
A(snapshot, "immutablePaths", () => {

@@ -498,2 +497,3 @@ if (process.versions.pnp === "1") {

}
F(snapshot, "unmanagedPaths", () => []);
F(snapshot, "resolveBuildDependencies", () => ({

@@ -559,2 +559,3 @@ timestamp: true,

);
D(generatorOptions, "exportsConvention", "as-is");
};

@@ -647,2 +648,23 @@

);
F(module.generator, "css/auto", () => ({}));
D(
module.generator["css/auto"],
"localIdentName",
"[uniqueName]-[id]-[local]"
);
F(module.generator, "css/module", () => ({}));
D(
module.generator["css/module"],
"localIdentName",
"[uniqueName]-[id]-[local]"
);
F(module.generator, "css/global", () => ({}));
D(
module.generator["css/global"],
"localIdentName",
"[uniqueName]-[id]-[local]"
);
}

@@ -908,2 +930,3 @@

});
D(output, "cssHeadDataCompression", !development);
D(output, "assetModuleFilename", "[hash][ext][query]");

@@ -910,0 +933,0 @@ D(output, "webassemblyModuleFilename", "[hash].module.wasm");

@@ -323,2 +323,3 @@ /*

cssChunkFilename: output.cssChunkFilename,
cssHeadDataCompression: output.cssHeadDataCompression,
clean: output.clean,

@@ -450,3 +451,4 @@ compareBeforeEmit: output.compareBeforeEmit,

immutablePaths: optionalNestedArray(snapshot.immutablePaths, p => [...p]),
managedPaths: optionalNestedArray(snapshot.managedPaths, p => [...p])
managedPaths: optionalNestedArray(snapshot.managedPaths, p => [...p]),
unmanagedPaths: optionalNestedArray(snapshot.unmanagedPaths, p => [...p])
})),

@@ -453,0 +455,0 @@ stats: nestedConfig(config.stats, stats => {

@@ -12,2 +12,3 @@ /*

/** @typedef {import("./ContainerEntryModule").ExposeOptions} ExposeOptions */
/** @typedef {import("./ContainerEntryModule").ExposesList} ExposesList */

@@ -17,3 +18,3 @@ class ContainerEntryDependency extends Dependency {

* @param {string} name entry name
* @param {[string, ExposeOptions][]} exposes list of exposed modules
* @param {ExposesList} exposes list of exposed modules
* @param {string} shareScope name of the share scope

@@ -20,0 +21,0 @@ */

@@ -42,2 +42,4 @@ /*

/** @typedef {[string, ExposeOptions][]} ExposesList */
const SOURCE_TYPES = new Set(["javascript"]);

@@ -48,3 +50,3 @@

* @param {string} name container entry name
* @param {[string, ExposeOptions][]} exposes list of exposed modules
* @param {ExposesList} exposes list of exposed modules
* @param {string} shareScope name of the share scope

@@ -51,0 +53,0 @@ */

@@ -16,2 +16,4 @@ /*

/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("./ContainerEntryModule").ExposeOptions} ExposeOptions */
/** @typedef {import("./ContainerEntryModule").ExposesList} ExposesList */

@@ -45,12 +47,14 @@ const validate = createSchemaValidation(

filename: options.filename || undefined,
exposes: parseOptions(
options.exposes,
item => ({
import: Array.isArray(item) ? item : [item],
name: undefined
}),
item => ({
import: Array.isArray(item.import) ? item.import : [item.import],
name: item.name || undefined
})
exposes: /** @type {ExposesList} */ (
parseOptions(
options.exposes,
item => ({
import: Array.isArray(item) ? item : [item],
name: undefined
}),
item => ({
import: Array.isArray(item.import) ? item.import : [item.import],
name: item.name || undefined
})
)
)

@@ -57,0 +61,0 @@ };

@@ -132,3 +132,3 @@ /*

const ids = this.dependencies.map(dep =>
chunkGraph.getModuleId(moduleGraph.getModule(dep))
chunkGraph.getModuleId(/** @type {Module} */ (moduleGraph.getModule(dep)))
);

@@ -135,0 +135,0 @@ const code = Template.asString([

@@ -13,2 +13,5 @@ /*

/** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../Chunk").ChunkId} ChunkId */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("./RemoteModule")} RemoteModule */

@@ -25,7 +28,10 @@

generate() {
const { compilation, chunkGraph } = this;
const compilation = /** @type {Compilation} */ (this.compilation);
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
const { runtimeTemplate, moduleGraph } = compilation;
/** @type {Record<ChunkId, (string | number)[]>} */
const chunkToRemotesMapping = {};
/** @type {Record<string | number, [string, string, string | number | null]>} */
const idToExternalAndNameMapping = {};
for (const chunk of this.chunk.getAllAsyncChunks()) {
for (const chunk of /** @type {Chunk} */ (this.chunk).getAllAsyncChunks()) {
const modules = chunkGraph.getChunkModulesIterableBySourceType(

@@ -36,3 +42,6 @@ chunk,

if (!modules) continue;
const remotes = (chunkToRemotesMapping[chunk.id] = []);
/** @type {(string | number)[]} */
const remotes = (chunkToRemotesMapping[
/** @type {ChunkId} */ (chunk.id)
] = []);
for (const m of modules) {

@@ -39,0 +48,0 @@ const module = /** @type {RemoteModule} */ (m);

@@ -47,2 +47,3 @@ /*

/** @typedef {import("./dependencies/ContextElementDependency")} ContextElementDependency */
/** @typedef {import("./javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

@@ -70,2 +71,3 @@ /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */

* @property {string=} layer
* @property {Attributes=} attributes
*/

@@ -72,0 +74,0 @@

@@ -292,3 +292,4 @@ /*

category,
typePrefix
typePrefix,
attributes
} = options;

@@ -369,3 +370,4 @@ if (!regExp || !resource) return callback(null, []);

referencedExports,
obj.context
obj.context,
attributes
);

@@ -372,0 +374,0 @@ dep.optional = true;

@@ -12,2 +12,3 @@ /*

/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */

@@ -108,3 +109,3 @@ class ContextReplacementPlugin {

result.resource = join(
compiler.inputFileSystem,
/** @type {InputFileSystem} */ (compiler.inputFileSystem),
result.resource,

@@ -137,3 +138,3 @@ newContentResource

result.resource = join(
compiler.inputFileSystem,
/** @type {InputFileSystem} */ (compiler.inputFileSystem),
origResource,

@@ -140,0 +141,0 @@ result.resource

@@ -13,4 +13,7 @@ /*

const Template = require("../Template");
const { cssExportConvention } = require("../util/conventions");
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorLocalIdentName} CssGeneratorLocalIdentName */
/** @typedef {import("../Dependency")} Dependency */

@@ -31,4 +34,12 @@ /** @typedef {import("../Generator").GenerateContext} GenerateContext */

class CssExportsGenerator extends Generator {
constructor() {
/**
* @param {CssGeneratorExportsConvention} convention the convention of the exports name
* @param {CssGeneratorLocalIdentName | undefined} localIdentName css export local ident name
*/
constructor(convention, localIdentName) {
super();
/** @type {CssGeneratorExportsConvention} */
this.convention = convention;
/** @type {CssGeneratorLocalIdentName | undefined} */
this.localIdentName = localIdentName;
}

@@ -48,2 +59,3 @@

const initFragments = [];
/** @type {Map<string, string>} */
const cssExports = new Map();

@@ -103,15 +115,17 @@

const usedIdentifiers = new Set();
for (const [k, v] of cssExports) {
let identifier = Template.toIdentifier(k);
let i = 0;
while (usedIdentifiers.has(identifier)) {
identifier = Template.toIdentifier(k + i);
for (const [name, v] of cssExports) {
for (let k of cssExportConvention(name, this.convention)) {
let identifier = Template.toIdentifier(k);
let i = 0;
while (usedIdentifiers.has(identifier)) {
identifier = Template.toIdentifier(k + i);
}
usedIdentifiers.add(identifier);
generateContext.concatenationScope.registerExport(k, identifier);
source.add(
`${
generateContext.runtimeTemplate.supportsConst() ? "const" : "var"
} ${identifier} = ${JSON.stringify(v)};\n`
);
}
usedIdentifiers.add(identifier);
generateContext.concatenationScope.registerExport(k, identifier);
source.add(
`${
generateContext.runtimeTemplate.supportsConst ? "const" : "var"
} ${identifier} = ${JSON.stringify(v)};\n`
);
}

@@ -130,9 +144,12 @@ return source;

}
const newCssExports = [];
for (let [k, v] of cssExports) {
for (let name of cssExportConvention(k, this.convention)) {
newCssExports.push(`\t${JSON.stringify(name)}: ${JSON.stringify(v)}`);
}
}
return new RawSource(
`${otherUsed ? `${RuntimeGlobals.makeNamespaceObject}(` : ""}${
module.moduleArgument
}.exports = {\n${Array.from(
cssExports,
([k, v]) => `\t${JSON.stringify(k)}: ${JSON.stringify(v)}`
).join(",\n")}\n}${otherUsed ? ")" : ""};`
}.exports = {\n${newCssExports.join(",\n")}\n}${otherUsed ? ")" : ""};`
);

@@ -139,0 +156,0 @@ }

@@ -12,4 +12,7 @@ /*

const RuntimeGlobals = require("../RuntimeGlobals");
const { cssExportConvention } = require("../util/conventions");
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorLocalIdentName} CssGeneratorLocalIdentName */
/** @typedef {import("../Dependency")} Dependency */

@@ -24,4 +27,12 @@ /** @typedef {import("../Generator").GenerateContext} GenerateContext */

class CssGenerator extends Generator {
constructor() {
/**
* @param {CssGeneratorExportsConvention} convention the convention of the exports name
* @param {CssGeneratorLocalIdentName | undefined} localIdentName css export local ident name
*/
constructor(convention, localIdentName) {
super();
/** @type {CssGeneratorExportsConvention} */
this.convention = convention;
/** @type {CssGeneratorLocalIdentName | undefined} */
this.localIdentName = localIdentName;
}

@@ -39,2 +50,3 @@

const initFragments = [];
/** @type {Map<string, string>} */
const cssExports = new Map();

@@ -92,4 +104,10 @@

if (cssExports.size > 0) {
const newCssExports = new Map();
for (let [name, v] of cssExports) {
for (let newName of cssExportConvention(name, this.convention)) {
newCssExports.set(newName, v);
}
}
const data = generateContext.getData();
data.set("css-exports", cssExports);
data.set("css-exports", newCssExports);
}

@@ -96,0 +114,0 @@

@@ -19,9 +19,12 @@ /*

/** @typedef {import("../Compilation").RuntimeRequirementsContext} RuntimeRequirementsContext */
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
/**
* @typedef {Object} JsonpCompilationPluginHooks
* @typedef {Object} CssLoadingRuntimeModulePluginHooks
* @property {SyncWaterfallHook<[string, Chunk]>} createStylesheet
* @property {SyncWaterfallHook<[string, Chunk]>} linkPreload
* @property {SyncWaterfallHook<[string, Chunk]>} linkPrefetch
*/
/** @type {WeakMap<Compilation, JsonpCompilationPluginHooks>} */
/** @type {WeakMap<Compilation, CssLoadingRuntimeModulePluginHooks>} */
const compilationHooksMap = new WeakMap();

@@ -32,3 +35,3 @@

* @param {Compilation} compilation the compilation
* @returns {JsonpCompilationPluginHooks} hooks
* @returns {CssLoadingRuntimeModulePluginHooks} hooks
*/

@@ -44,3 +47,5 @@ static getCompilationHooks(compilation) {

hooks = {
createStylesheet: new SyncWaterfallHook(["source", "chunk"])
createStylesheet: new SyncWaterfallHook(["source", "chunk"]),
linkPreload: new SyncWaterfallHook(["source", "chunk"]),
linkPrefetch: new SyncWaterfallHook(["source", "chunk"])
};

@@ -53,3 +58,3 @@ compilationHooksMap.set(compilation, hooks);

/**
* @param {Set<string>} runtimeRequirements runtime requirements
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
*/

@@ -66,3 +71,5 @@ constructor(runtimeRequirements) {

generate() {
const { compilation, chunk, _runtimeRequirements } = this;
const { _runtimeRequirements } = this;
const compilation = /** @type {Compilation} */ (this.compilation);
const chunk = /** @type {Chunk} */ (this.chunk);
const {

@@ -74,5 +81,6 @@ chunkGraph,

uniqueName,
chunkLoadTimeout: loadTimeout
chunkLoadTimeout: loadTimeout,
cssHeadDataCompression: withCompression
}
} = /** @type {Compilation} */ (compilation);
} = compilation;
const fn = RuntimeGlobals.ensureChunkHandlers;

@@ -94,2 +102,8 @@ const conditionMap = chunkGraph.getChunkConditionMap(

hasCssMatcher !== false;
const withPrefetch = this._runtimeRequirements.has(
RuntimeGlobals.prefetchChunkHandlers
);
const withPreload = this._runtimeRequirements.has(
RuntimeGlobals.preloadChunkHandlers
);
/** @type {boolean} */

@@ -114,6 +128,12 @@ const withHmr = _runtimeRequirements.has(

const { createStylesheet } = CssLoadingRuntimeModule.getCompilationHooks(
/** @type {Compilation} */ (compilation)
const { linkPreload, linkPrefetch } =
CssLoadingRuntimeModule.getCompilationHooks(compilation);
const withFetchPriority = _runtimeRequirements.has(
RuntimeGlobals.hasFetchPriority
);
const { createStylesheet } =
CssLoadingRuntimeModule.getCompilationHooks(compilation);
const stateExpression = withHmr

@@ -125,5 +145,19 @@ ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_css`

"link = document.createElement('link');",
`if (${RuntimeGlobals.scriptNonce}) {`,
Template.indent(
`link.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
),
"}",
uniqueName
? 'link.setAttribute("data-webpack", uniqueName + ":" + key);'
: "",
withFetchPriority
? Template.asString([
"if(fetchPriority) {",
Template.indent(
'link.setAttribute("fetchpriority", fetchPriority);'
),
"}"
])
: "",
"link.setAttribute(loadingAttribute, 1);",

@@ -175,5 +209,5 @@ 'link.rel = "stylesheet";',

[
`var data, token = "", token2, exports = {}, exportsWithId = [], exportsWithDashes = [], ${
`var data, token = "", token2 = "", exports = {}, ${
withHmr ? "moduleIds = [], " : ""
}name = ${name}, i = 0, cc = 1;`,
}name = ${name}, i, cc = 1;`,
"try {",

@@ -200,35 +234,30 @@ Template.indent([

"if(!data) return [];",
"for(; cc; i++) {",
withCompression
? Template.asString([
// LZW decode
`var map = {}, char = data[0], oldPhrase = char, decoded = char, code = 256, maxCode = "\uffff".charCodeAt(0), phrase;`,
"for (i = 1; i < data.length; i++) {",
Template.indent([
"cc = data[i].charCodeAt(0);",
"if (cc < 256) phrase = data[i]; else phrase = map[cc] ? map[cc] : (oldPhrase + char);",
"decoded += phrase;",
"char = phrase.charAt(0);",
"map[code] = oldPhrase + char;",
"if (++code > maxCode) { code = 256; map = {}; }",
"oldPhrase = phrase;"
]),
"}",
"data = decoded;"
])
: "// css head data compression is disabled",
"for(i = 0; cc; i++) {",
Template.indent([
"cc = data.charCodeAt(i);",
`if(cc == ${cc("(")}) { token2 = token; token = ""; }`,
`if(cc == ${cc(":")}) { token2 = token; token = ""; }`,
`else if(cc == ${cc(
")"
)}) { exports[token2.replace(/^_/, "")] = token.replace(/^_/, ""); token = ""; }`,
`else if(cc == ${cc("/")} || cc == ${cc(
"%"
)}) { token = token.replace(/^_/, ""); exports[token] = token; exportsWithId.push(token); if(cc == ${cc(
"%"
)}) exportsWithDashes.push(token); token = ""; }`,
"/"
)}) { token = token.replace(/^_/, ""); token2 = token2.replace(/^_/, ""); exports[token2] = token; token = ""; token2 = ""; }`,
`else if(!cc || cc == ${cc(
","
)}) { token = token.replace(/^_/, ""); exportsWithId.forEach(${runtimeTemplate.expressionFunction(
`exports[x] = ${
uniqueName
? runtimeTemplate.concatenation(
{ expr: "uniqueName" },
"-",
{ expr: "token" },
"-",
{ expr: "exports[x]" }
)
: runtimeTemplate.concatenation({ expr: "token" }, "-", {
expr: "exports[x]"
})
}`,
"x"
)}); exportsWithDashes.forEach(${runtimeTemplate.expressionFunction(
`exports[x] = "--" + exports[x]`,
"x"
)}); ${
)}) { token = token.replace(/^_/, ""); ${
RuntimeGlobals.makeNamespaceObject

@@ -240,3 +269,3 @@ }(exports); target[token] = (${runtimeTemplate.basicFunction(

withHmr ? "moduleIds.push(token); " : ""
}token = ""; exports = {}; exportsWithId.length = 0; exportsWithDashes.length = 0; }`,
}token = ""; token2 = ""; exports = {}; }`,
`else if(cc == ${cc("\\")}) { token += data[++i] }`,

@@ -254,3 +283,5 @@ `else { token += data[i]; }`

`var loadStylesheet = ${runtimeTemplate.basicFunction(
"chunkId, url, done" + (withHmr ? ", hmr" : ""),
"chunkId, url, done" +
(withHmr ? ", hmr" : "") +
(withFetchPriority ? ", fetchPriority" : ""),
[

@@ -323,70 +354,155 @@ 'var link, needAttach, key = "chunk-" + chunkId;',

? Template.asString([
`${fn}.css = ${runtimeTemplate.basicFunction("chunkId, promises", [
"// css chunk loading",
`var installedChunkData = ${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;`,
'if(installedChunkData !== 0) { // 0 means "already installed".',
Template.indent([
"",
'// a Promise means "currently loading".',
"if(installedChunkData) {",
Template.indent(["promises.push(installedChunkData[2]);"]),
"} else {",
`${fn}.css = ${runtimeTemplate.basicFunction(
`chunkId, promises${withFetchPriority ? " , fetchPriority" : ""}`,
[
"// css chunk loading",
`var installedChunkData = ${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;`,
'if(installedChunkData !== 0) { // 0 means "already installed".',
Template.indent([
hasCssMatcher === true
? "if(true) { // all chunks have CSS"
: `if(${hasCssMatcher("chunkId")}) {`,
"",
'// a Promise means "currently loading".',
"if(installedChunkData) {",
Template.indent(["promises.push(installedChunkData[2]);"]),
"} else {",
Template.indent([
"// setup Promise in chunk cache",
`var promise = new Promise(${runtimeTemplate.expressionFunction(
`installedChunkData = installedChunks[chunkId] = [resolve, reject]`,
"resolve, reject"
)});`,
"promises.push(installedChunkData[2] = promise);",
"",
"// start chunk loading",
`var url = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkCssFilename}(chunkId);`,
"// create error before stack unwound to get useful stacktrace later",
"var error = new Error();",
`var loadingEnded = ${runtimeTemplate.basicFunction(
"event",
[
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId)) {`,
Template.indent([
"installedChunkData = installedChunks[chunkId];",
"if(installedChunkData !== 0) installedChunks[chunkId] = undefined;",
"if(installedChunkData) {",
hasCssMatcher === true
? "if(true) { // all chunks have CSS"
: `if(${hasCssMatcher("chunkId")}) {`,
Template.indent([
"// setup Promise in chunk cache",
`var promise = new Promise(${runtimeTemplate.expressionFunction(
`installedChunkData = installedChunks[chunkId] = [resolve, reject]`,
"resolve, reject"
)});`,
"promises.push(installedChunkData[2] = promise);",
"",
"// start chunk loading",
`var url = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkCssFilename}(chunkId);`,
"// create error before stack unwound to get useful stacktrace later",
"var error = new Error();",
`var loadingEnded = ${runtimeTemplate.basicFunction(
"event",
[
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId)) {`,
Template.indent([
'if(event.type !== "load") {',
"installedChunkData = installedChunks[chunkId];",
"if(installedChunkData !== 0) installedChunks[chunkId] = undefined;",
"if(installedChunkData) {",
Template.indent([
"var errorType = event && event.type;",
"var realHref = event && event.target && event.target.href;",
"error.message = 'Loading css chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realHref + ')';",
"error.name = 'ChunkLoadError';",
"error.type = errorType;",
"error.request = realHref;",
"installedChunkData[1](error);"
'if(event.type !== "load") {',
Template.indent([
"var errorType = event && event.type;",
"var realHref = event && event.target && event.target.href;",
"error.message = 'Loading css chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realHref + ')';",
"error.name = 'ChunkLoadError';",
"error.type = errorType;",
"error.request = realHref;",
"installedChunkData[1](error);"
]),
"} else {",
Template.indent([
`loadCssChunkData(${RuntimeGlobals.moduleFactories}, link, chunkId);`,
"installedChunkData[0]();"
]),
"}"
]),
"} else {",
Template.indent([
`loadCssChunkData(${RuntimeGlobals.moduleFactories}, link, chunkId);`,
"installedChunkData[0]();"
]),
"}"
]),
"}"
]),
"}"
]
)};`,
"var link = loadStylesheet(chunkId, url, loadingEnded);"
]
)};`,
`var link = loadStylesheet(chunkId, url, loadingEnded${
withFetchPriority ? ", fetchPriority" : ""
});`
]),
"} else installedChunks[chunkId] = 0;"
]),
"} else installedChunks[chunkId] = 0;"
"}"
]),
"}"
]),
"}"
])};`
]
)};`
])
: "// no chunk loading",
"",
withPrefetch && hasCssMatcher !== false
? `${
RuntimeGlobals.prefetchChunkHandlers
}.s = ${runtimeTemplate.basicFunction("chunkId", [
`if((!${
RuntimeGlobals.hasOwnProperty
}(installedChunks, chunkId) || installedChunks[chunkId] === undefined) && ${
hasCssMatcher === true ? "true" : hasCssMatcher("chunkId")
}) {`,
Template.indent([
"installedChunks[chunkId] = null;",
linkPrefetch.call(
Template.asString([
"var link = document.createElement('link');",
crossOriginLoading
? `link.crossOrigin = ${JSON.stringify(
crossOriginLoading
)};`
: "",
`if (${RuntimeGlobals.scriptNonce}) {`,
Template.indent(
`link.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
),
"}",
'link.rel = "prefetch";',
'link.as = "style";',
`link.href = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkCssFilename}(chunkId);`
]),
chunk
),
"document.head.appendChild(link);"
]),
"}"
])};`
: "// no prefetching",
"",
withPreload && hasCssMatcher !== false
? `${
RuntimeGlobals.preloadChunkHandlers
}.s = ${runtimeTemplate.basicFunction("chunkId", [
`if((!${
RuntimeGlobals.hasOwnProperty
}(installedChunks, chunkId) || installedChunks[chunkId] === undefined) && ${
hasCssMatcher === true ? "true" : hasCssMatcher("chunkId")
}) {`,
Template.indent([
"installedChunks[chunkId] = null;",
linkPreload.call(
Template.asString([
"var link = document.createElement('link');",
"link.charset = 'utf-8';",
`if (${RuntimeGlobals.scriptNonce}) {`,
Template.indent(
`link.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
),
"}",
'link.rel = "preload";',
'link.as = "style";',
`link.href = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkCssFilename}(chunkId);`,
crossOriginLoading
? crossOriginLoading === "use-credentials"
? 'link.crossOrigin = "use-credentials";'
: Template.asString([
"if (link.href.indexOf(window.location.origin + '/') !== 0) {",
Template.indent(
`link.crossOrigin = ${JSON.stringify(
crossOriginLoading
)};`
),
"}"
])
: ""
]),
chunk
),
"document.head.appendChild(link);"
]),
"}"
])};`
: "// no preloaded",
withHmr

@@ -393,0 +509,0 @@ ? Template.asString([

@@ -131,2 +131,31 @@ /*

/**
* @param {string} str string
* @returns {string} encoded string
*/
const LZWEncode = str => {
/** @type {Map<string, string>} */
const map = new Map();
let encoded = "";
let phrase = str[0];
let code = 256;
let maxCode = "\uffff".charCodeAt(0);
for (let i = 1; i < str.length; i++) {
const c = str[i];
if (map.has(phrase + c)) {
phrase += c;
} else {
encoded += phrase.length > 1 ? map.get(phrase) : phrase;
map.set(phrase + c, String.fromCharCode(code));
phrase = c;
if (++code > maxCode) {
code = 256;
map.clear();
}
}
}
encoded += phrase.length > 1 ? map.get(phrase) : phrase;
return encoded;
};
const plugin = "CssModulesPlugin";

@@ -217,4 +246,10 @@

return generatorOptions.exportsOnly
? new CssExportsGenerator()
: new CssGenerator();
? new CssExportsGenerator(
generatorOptions.exportsConvention,
generatorOptions.localIdentName
)
: new CssGenerator(
generatorOptions.exportsConvention,
generatorOptions.localIdentName
);
});

@@ -331,2 +366,4 @@ normalModuleFactory.hooks.createModuleClass

uniqueName: compilation.outputOptions.uniqueName,
cssHeadDataCompression:
compilation.outputOptions.cssHeadDataCompression,
modules

@@ -543,2 +580,3 @@ }),

* @param {string | undefined} options.uniqueName unique name
* @param {boolean | undefined} options.cssHeadDataCompression compress css head data
* @param {Chunk} options.chunk chunk

@@ -552,2 +590,3 @@ * @param {ChunkGraph} options.chunkGraph chunk graph

uniqueName,
cssHeadDataCompression,
chunk,

@@ -626,12 +665,6 @@ chunkGraph,

exports
? Array.from(exports, ([n, v]) => {
const shortcutValue = `${
uniqueName ? uniqueName + "-" : ""
}${moduleId}-${n}`;
return v === shortcutValue
? `${escapeCss(n)}/`
: v === "--" + shortcutValue
? `${escapeCss(n)}%`
: `${escapeCss(n)}(${escapeCss(v)})`;
}).join("")
? Array.from(
exports,
([n, v]) => `${escapeCss(n)}:${escapeCss(v)}/`
).join("")
: ""

@@ -646,2 +679,3 @@ }${escapeCss(moduleId)}`

}
const metaDataStr = metaData.join(",");
source.add(

@@ -651,3 +685,3 @@ `head{--webpack-${escapeCss(

true
)}:${metaData.join(",")};}`
)}:${cssHeadDataCompression ? LZWEncode(metaDataStr) : metaDataStr};}`
);

@@ -654,0 +688,0 @@ return source;

@@ -20,5 +20,11 @@ /*

/** @typedef {import("../../declarations/plugins/debug/ProfilingPlugin").ProfilingPluginOptions} ProfilingPluginOptions */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../ContextModuleFactory")} ContextModuleFactory */
/** @typedef {import("../ModuleFactory")} ModuleFactory */
/** @typedef {import("../NormalModuleFactory")} NormalModuleFactory */
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
/** @typedef {TODO} Inspector */
const validate = createSchemaValidation(

@@ -32,2 +38,4 @@ require("../../schemas/plugins/debug/ProfilingPlugin.check.js"),

);
/** @type {Inspector | undefined} */
let inspector = undefined;

@@ -43,2 +51,5 @@

class Profiler {
/**
* @param {Inspector} inspector inspector
*/
constructor(inspector) {

@@ -146,3 +157,3 @@ this.session = undefined;

const trace = new Tracer();
const profiler = new Profiler(inspector);
const profiler = new Profiler(/** @type {Inspector} */ (inspector));
if (/\/|\\/.test(outputPath)) {

@@ -223,3 +234,4 @@ const dirPath = dirname(fs, outputPath);

const tracer = createTrace(
compiler.intermediateFileSystem,
/** @type {IntermediateFileSystem} */
(compiler.intermediateFileSystem),
this.outputPath

@@ -328,2 +340,7 @@ );

/**
* @param {any} instance instance
* @param {Trace} tracer tracer
* @param {string} logLabel log label
*/
const interceptAllHooksFor = (instance, tracer, logLabel) => {

@@ -340,2 +357,6 @@ if (Reflect.has(instance, "hooks")) {

/**
* @param {NormalModuleFactory} moduleFactory normal module factory
* @param {Trace} tracer tracer
*/
const interceptAllParserHooks = (moduleFactory, tracer) => {

@@ -360,2 +381,6 @@ const moduleTypes = [

/**
* @param {Compilation} compilation compilation
* @param {Trace} tracer tracer
*/
const interceptAllJavascriptModulesPluginHooks = (compilation, tracer) => {

@@ -362,0 +387,0 @@ interceptAllHooksFor(

@@ -311,4 +311,6 @@ /*

const TYPEOF_OPERATOR_REGEXP = /^typeof\s+/;
const WEBPACK_REQUIRE_FUNCTION_REGEXP = /__webpack_require__\s*(!?\.)/;
const WEBPACK_REQUIRE_IDENTIFIER_REGEXP = /__webpack_require__/;
const WEBPACK_REQUIRE_FUNCTION_REGEXP = new RegExp(
`${RuntimeGlobals.require}\\s*(!?\\.)`
);
const WEBPACK_REQUIRE_IDENTIFIER_REGEXP = new RegExp(RuntimeGlobals.require);

@@ -315,0 +317,0 @@ class DefinePlugin {

@@ -106,3 +106,3 @@ /*

)
identifiers[idx] = param.string;
identifiers[/** @type {number} */ (idx)] = param.string;
const result = this.processItem(parser, expr, param, namedModule);

@@ -117,3 +117,4 @@ if (result === undefined) {

const deps = [];
param.array.forEach((request, idx) => {
/** @type {string[]} */
(param.array).forEach((request, idx) => {
let dep;

@@ -156,3 +157,3 @@ let localModule;

* @param {string=} namedModule named module
* @returns {boolean} result
* @returns {boolean | undefined} result
*/

@@ -199,3 +200,6 @@ processItem(parser, expr, param, namedModule) {

} else {
dep = this.newRequireItemDependency(param.string, param.range);
dep = this.newRequireItemDependency(
/** @type {string} */ (param.string),
param.range
);
dep.optional = !!parser.scope.inTry;

@@ -384,3 +388,3 @@ parser.state.current.addDependency(dep);

}
parser.scope.inTry = inTry;
parser.scope.inTry = /** @type {boolean} */ (inTry);
if (fn.callee.object.body.type === "BlockStatement") {

@@ -387,0 +391,0 @@ parser.detectMode(fn.callee.object.body.body);

@@ -24,2 +24,3 @@ /*

/** @typedef {import("estree").Expression} Expression */
/** @typedef {import("estree").Identifier} Identifier */
/** @typedef {import("estree").SourceLocation} SourceLocation */

@@ -53,3 +54,5 @@ /** @typedef {import("estree").SpreadElement} SpreadElement */

fnData.fn.params.filter(i => {
return !["require", "module", "exports"].includes(i.name);
return !["require", "module", "exports"].includes(
/** @type {Identifier} */ (i).name
);
}),

@@ -56,0 +59,0 @@ () => {

@@ -11,2 +11,3 @@ /*

/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
/** @typedef {"exports" | "module.exports" | "this" | "Object.defineProperty(exports)" | "Object.defineProperty(module.exports)" | "Object.defineProperty(this)"} CommonJSDependencyBaseKeywords */

@@ -17,3 +18,3 @@

* @param {Module} module module
* @param {Set<string>} runtimeRequirements runtime requirements
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
* @returns {[string, string]} type and base

@@ -20,0 +21,0 @@ */

@@ -23,2 +23,4 @@ /*

/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../ExportsInfo")} ExportsInfo */
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
/** @typedef {import("../Module")} Module */

@@ -39,3 +41,3 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */

* @param {Range} range range
* @param {Range} valueRange value range
* @param {Range | null} valueRange value range
* @param {CommonJSDependencyBaseKeywords} base base

@@ -74,3 +76,5 @@ * @param {string[]} names names

getIds(moduleGraph) {
return moduleGraph.getMeta(this)[idsSymbol] || this.ids;
return (
/** @type {TODO} */ (moduleGraph.getMeta(this))[idsSymbol] || this.ids
);
}

@@ -84,3 +88,3 @@

setIds(moduleGraph, ids) {
moduleGraph.getMeta(this)[idsSymbol] = ids;
/** @type {TODO} */ (moduleGraph.getMeta(this))[idsSymbol] = ids;
}

@@ -109,7 +113,10 @@

if (this.resultUsed) return getFullResult();
/** @type {ExportsInfo | undefined} */
let exportsInfo = moduleGraph.getExportsInfo(
moduleGraph.getParentModule(this)
/** @type {Module} */ (moduleGraph.getParentModule(this))
);
for (const name of this.names) {
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
const exportInfo = /** @type {ExportInfo} */ (
exportsInfo.getReadOnlyExportInfo(name)
);
const used = exportInfo.getUsed(runtime);

@@ -190,10 +197,13 @@ if (used === UsageState.Unused) return Dependency.NO_EXPORTS_REFERENCED;

return {
exports: Array.from(reexportInfo.exports, name => {
return {
name,
from,
export: ids.concat(name),
canMangle: !(name in EMPTY_OBJECT) && false
};
}),
exports: Array.from(
/** @type {TODO} */ (reexportInfo).exports,
name => {
return {
name,
from,
export: ids.concat(name),
canMangle: !(name in EMPTY_OBJECT) && false
};
}
),
// TODO handle deep reexports

@@ -217,3 +227,3 @@ dependencies: [from.module]

* @param {Module} importedModule the imported module (optional)
* @returns {{exports?: Set<string>, checked?: Set<string>}} information
* @returns {{exports?: Set<string>, checked?: Set<string>} | undefined} information
*/

@@ -223,4 +233,5 @@ getStarReexports(

runtime,
importedModule = moduleGraph.getModule(this)
importedModule = /** @type {Module} */ (moduleGraph.getModule(this))
) {
/** @type {ExportsInfo | undefined} */
let importedExportsInfo = moduleGraph.getExportsInfo(importedModule);

@@ -230,4 +241,5 @@ const ids = this.getIds(moduleGraph);

importedExportsInfo = importedExportsInfo.getNestedExportsInfo(ids);
/** @type {ExportsInfo | undefined} */
let exportsInfo = moduleGraph.getExportsInfo(
moduleGraph.getParentModule(this)
/** @type {Module} */ (moduleGraph.getParentModule(this))
);

@@ -257,3 +269,4 @@ if (this.names.length > 0)

if (noExtraImports) {
for (const exportInfo of exportsInfo.orderedExports) {
for (const exportInfo of /** @type {ExportsInfo} */ (exportsInfo)
.orderedExports) {
const name = exportInfo.name;

@@ -276,3 +289,5 @@ if (exportInfo.getUsed(runtime) === UsageState.Unused) continue;

} else if (noExtraExports) {
for (const importedExportInfo of importedExportsInfo.orderedExports) {
for (const importedExportInfo of /** @type {ExportsInfo} */ (
importedExportsInfo
).orderedExports) {
const name = importedExportInfo.name;

@@ -279,0 +294,0 @@ if (importedExportInfo.provided === false) continue;

@@ -29,3 +29,3 @@ /*

* @param {Range} range range
* @param {Range} valueRange value range
* @param {Range | null} valueRange value range
* @param {CommonJSDependencyBaseKeywords} base base

@@ -158,6 +158,10 @@ * @param {string[]} names names

dep.range[0],
dep.valueRange[0] - 1,
/** @type {Range} */ (dep.valueRange)[0] - 1,
"__webpack_unused_export__ = ("
);
source.replace(dep.valueRange[1], dep.range[1] - 1, ")");
source.replace(
/** @type {Range} */ (dep.valueRange)[1],
dep.range[1] - 1,
")"
);
return;

@@ -167,3 +171,3 @@ }

dep.range[0],
dep.valueRange[0] - 1,
/** @type {Range} */ (dep.valueRange)[0] - 1,
`Object.defineProperty(${base}${propertyAccess(

@@ -173,3 +177,7 @@ used.slice(0, -1)

);
source.replace(dep.valueRange[1], dep.range[1] - 1, "))");
source.replace(
/** @type {Range} */ (dep.valueRange)[1],
dep.range[1] - 1,
"))"
);
return;

@@ -176,0 +184,0 @@ }

@@ -23,3 +23,3 @@ /*

/** @typedef {import("estree").Super} Super */
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("../ModuleGraph")} ModuleGraph */

@@ -29,2 +29,3 @@ /** @typedef {import("../NormalModule")} NormalModule */

/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("./CommonJsDependencyHelpers").CommonJSDependencyBaseKeywords} CommonJSDependencyBaseKeywords */

@@ -195,3 +196,3 @@

* @param {string[]} members members of the export
* @returns {boolean} true, when the expression was handled
* @returns {boolean | undefined} true, when the expression was handled
*/

@@ -211,11 +212,11 @@ const handleAssignExport = (expr, base, members) => {

const dep = new CommonJsExportRequireDependency(
expr.range,
/** @type {Range} */ (expr.range),
null,
base,
members,
requireCall.argument.string,
/** @type {string} */ (requireCall.argument.string),
requireCall.ids,
!parser.isStatementLevelExpression(expr)
);
dep.loc = expr.loc;
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
dep.optional = !!parser.scope.inTry;

@@ -235,3 +236,3 @@ parser.state.module.addDependency(dep);

const dep = new CommonJsExportsDependency(
expr.left.range,
/** @type {Range} */ (expr.left.range),
null,

@@ -241,3 +242,3 @@ base,

);
dep.loc = expr.loc;
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addDependency(dep);

@@ -293,8 +294,8 @@ parser.walkExpression(expr.right);

const dep = new CommonJsExportsDependency(
expr.range,
expr.arguments[2].range,
/** @type {Range} */ (expr.range),
/** @type {Range} */ (expr.arguments[2].range),
`Object.defineProperty(${exportsArg.identifier})`,
[property]
);
dep.loc = expr.loc;
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addDependency(dep);

@@ -318,3 +319,7 @@

if (members.length === 0) {
bailout(`${base} is used directly at ${formatLocation(expr.loc)}`);
bailout(
`${base} is used directly at ${formatLocation(
/** @type {DependencyLocation} */ (expr.loc)
)}`
);
}

@@ -326,3 +331,3 @@ if (call && members.length === 1) {

)}(...) prevents optimization as ${base} is passed as call context at ${formatLocation(
expr.loc
/** @type {DependencyLocation} */ (expr.loc)
)}`

@@ -332,3 +337,3 @@ );

const dep = new CommonJsSelfReferenceDependency(
expr.range,
/** @type {Range} */ (expr.range),
base,

@@ -338,3 +343,3 @@ members,

);
dep.loc = expr.loc;
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addDependency(dep);

@@ -412,3 +417,3 @@ if (call) {

);
dep.loc = expr.loc;
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addDependency(dep);

@@ -415,0 +420,0 @@ return true;

@@ -347,3 +347,2 @@ /*

parser.state.module.addPresentationalDependency(dep);
return true;
} else {

@@ -360,4 +359,4 @@ const result = processRequireItem(expr, param);

}
return true;
}
return true;
};

@@ -364,0 +363,0 @@ parser.hooks.call

@@ -13,4 +13,6 @@ /*

/** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("./ContextDependency")} ContextDependency */

@@ -28,2 +30,6 @@ /** @typedef {import("./ContextDependency").ContextDependencyOptions} ContextDependencyOptions */

/**
* @param {string} prefix prefix
* @returns {{prefix: string, context: string}} result
*/
const splitContextFromPrefix = prefix => {

@@ -43,3 +49,2 @@ const idx = prefix.lastIndexOf("/");

/** @typedef {Partial<Omit<ContextDependencyOptions, "resource">>} PartialContextDependencyOptions */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: [number, number], ...args: any[]): ContextDependency }} ContextDependencyConstructor */

@@ -69,9 +74,9 @@

if (param.isTemplateString()) {
let prefixRaw = param.quasis[0].string;
const quasis = /** @type {BasicEvaluatedExpression[]} */ (param.quasis);
let prefixRaw = /** @type {string} */ (quasis[0].string);
let postfixRaw =
param.quasis.length > 1
? param.quasis[param.quasis.length - 1].string
: "";
/** @type {string} */
(quasis.length > 1 ? quasis[quasis.length - 1].string : "");
const valueRange = param.range;
const valueRange = /** @type {Range} */ (param.range);
const { context, prefix } = splitContextFromPrefix(prefixRaw);

@@ -86,7 +91,11 @@ const {

// We join the quasis with the expression regexp
const innerQuasis = param.quasis.slice(1, param.quasis.length - 1);
const innerQuasis = quasis.slice(1, quasis.length - 1);
const innerRegExp =
options.wrappedContextRegExp.source +
/** @type {RegExp} */ (options.wrappedContextRegExp).source +
innerQuasis
.map(q => quoteMeta(q.string) + options.wrappedContextRegExp.source)
.map(
q =>
quoteMeta(/** @type {string} */ (q.string)) +
/** @type {RegExp} */ (options.wrappedContextRegExp).source
)
.join("");

@@ -109,3 +118,3 @@

request: context + query + fragment,
recursive: options.wrappedContextRecursive,
recursive: /** @type {boolean} */ (options.wrappedContextRecursive),
regExp,

@@ -119,10 +128,13 @@ mode: "sync",

);
dep.loc = expr.loc;
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
/** @type {{ value: string, range: Range }[]} */
const replaces = [];
const parts = /** @type {BasicEvaluatedExpression[]} */ (param.parts);
param.parts.forEach((part, i) => {
parts.forEach((part, i) => {
if (i % 2 === 0) {
// Quasis or merged quasi
let range = part.range;
let value = part.string;
let range = /** @type {Range} */ (part.range);
let value = /** @type {string} */ (part.string);
if (param.templateStringKind === "cooked") {

@@ -135,10 +147,16 @@ value = JSON.stringify(value);

value = prefix;
range = [param.range[0], part.range[1]];
range = [
/** @type {Range} */ (param.range)[0],
/** @type {Range} */ (part.range)[1]
];
value =
(param.templateStringKind === "cooked" ? "`" : "String.raw`") +
value;
} else if (i === param.parts.length - 1) {
} else if (i === parts.length - 1) {
// postfix
value = postfix;
range = [part.range[0], param.range[1]];
range = [
/** @type {Range} */ (part.range)[0],
/** @type {Range} */ (param.range)[1]
];
value = value + "`";

@@ -174,5 +192,7 @@ } else if (

let prefixRaw =
param.prefix && param.prefix.isString() ? param.prefix.string : "";
/** @type {string} */
(param.prefix && param.prefix.isString() ? param.prefix.string : "");
let postfixRaw =
param.postfix && param.postfix.isString() ? param.postfix.string : "";
/** @type {string} */
(param.postfix && param.postfix.isString() ? param.postfix.string : "");
const prefixRange =

@@ -182,3 +202,3 @@ param.prefix && param.prefix.isString() ? param.prefix.range : null;

param.postfix && param.postfix.isString() ? param.postfix.range : null;
const valueRange = param.range;
const valueRange = /** @type {Range} */ (param.range);
const { context, prefix } = splitContextFromPrefix(prefixRaw);

@@ -191,5 +211,5 @@ const {

const regExp = new RegExp(
`^${quoteMeta(prefix)}${options.wrappedContextRegExp.source}${quoteMeta(
postfix
)}$`
`^${quoteMeta(prefix)}${
/** @type {RegExp} */ (options.wrappedContextRegExp).source
}${quoteMeta(postfix)}$`
);

@@ -199,3 +219,3 @@ const dep = new Dep(

request: context + query + fragment,
recursive: options.wrappedContextRecursive,
recursive: /** @type {boolean} */ (options.wrappedContextRecursive),
regExp,

@@ -209,3 +229,3 @@ mode: "sync",

);
dep.loc = expr.loc;
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
const replaces = [];

@@ -239,4 +259,4 @@ if (prefixRange) {

{
request: options.exprContextRequest,
recursive: options.exprContextRecursive,
request: /** @type {string} */ (options.exprContextRequest),
recursive: /** @type {boolean} */ (options.exprContextRecursive),
regExp: /** @type {RegExp} */ (options.exprContextRegExp),

@@ -247,6 +267,6 @@ mode: "sync",

range,
param.range,
/** @type {Range} */ (param.range),
...depArgs
);
dep.loc = expr.loc;
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
dep.critical =

@@ -253,0 +273,0 @@ options.exprContextCritical &&

@@ -14,2 +14,3 @@ /*

/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

@@ -27,2 +28,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */

* @param {string=} context context
* @param {Attributes=} attributes attributes
*/

@@ -35,3 +37,4 @@ constructor(

referencedExports,
context
context,
attributes
) {

@@ -47,2 +50,4 @@ super(request);

}
this.assertions = attributes;
}

@@ -85,2 +90,3 @@

write(this.referencedExports);
write(this.assertions);
super.serialize(context);

@@ -97,2 +103,3 @@ }

this.referencedExports = read();
this.assertions = read();
super.deserialize(context);

@@ -99,0 +106,0 @@ }

@@ -8,2 +8,4 @@ /*

const createHash = require("../util/createHash");
const { makePathsRelative } = require("../util/identifier");
const makeSerializable = require("../util/makeSerializable");

@@ -13,2 +15,6 @@ const NullDependency = require("./NullDependency");

/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorLocalIdentName} CssGeneratorLocalIdentName */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../CssModule")} CssModule */
/** @typedef {import("../Dependency")} Dependency */

@@ -18,2 +24,5 @@ /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */

/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../css/CssExportsGenerator")} CssExportsGenerator */
/** @typedef {import("../css/CssGenerator")} CssGenerator */
/** @typedef {import("../css/CssParser").Range} Range */

@@ -23,2 +32,47 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

/**
* @param {string} local css local
* @param {CssModule} module module
* @param {ChunkGraph} chunkGraph chunk graph
* @param {RuntimeTemplate} runtimeTemplate runtime template
* @returns {string} local ident
*/
const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
const localIdentName =
/** @type {CssGenerator | CssExportsGenerator} */
(module.generator).localIdentName;
const relativeResourcePath = makePathsRelative(
/** @type {string} */ (module.context),
module.resourceResolveData.path
);
const { hashFunction, hashDigest, hashDigestLength, hashSalt, uniqueName } =
runtimeTemplate.outputOptions;
const hash = createHash(hashFunction);
if (hashSalt) {
hash.update(hashSalt);
}
hash.update(relativeResourcePath);
if (!/\[local\]/.test(localIdentName)) {
hash.update(local);
}
const localIdentHash = /** @type {string} */ (hash.digest(hashDigest))
// Remove all leading digits
.replace(/^\d+/, "")
// Replace all slashes with underscores (same as in base64url)
.replace(/\//g, "_")
// Remove everything that is not an alphanumeric or underscore
.replace(/[^A-Za-z0-9_]+/g, "_")
.slice(0, hashDigestLength);
return runtimeTemplate.compilation
.getPath(localIdentName, {
filename: relativeResourcePath,
hash: localIdentHash,
contentHash: localIdentHash,
chunkGraph,
module
})
.replace(/\[local\]/g, local)
.replace(/\[uniqueName\]/g, uniqueName);
};
class CssLocalIdentifierDependency extends NullDependency {

@@ -119,15 +173,16 @@ /**

const moduleId = chunkGraph.getModuleId(module);
const identifier =
const localIdent =
dep.prefix +
(runtimeTemplate.outputOptions.uniqueName
? runtimeTemplate.outputOptions.uniqueName + "-"
: "") +
(used ? moduleId + "-" + used : "-");
getLocalIdent(
used,
/** @type {CssModule} */ (module),
chunkGraph,
runtimeTemplate
);
source.replace(
dep.range[0],
dep.range[1] - 1,
escapeCssIdentifier(identifier, dep.prefix)
escapeCssIdentifier(localIdent, dep.prefix)
);
if (used) cssExports.set(used, identifier);
if (used) cssExports.set(used, localIdent);
}

@@ -134,0 +189,0 @@ };

@@ -8,2 +8,3 @@ /*

const RawDataUrlModule = require("../asset/RawDataUrlModule");
const makeSerializable = require("../util/makeSerializable");

@@ -28,3 +29,5 @@ const memoize = require("../util/memoize");

const getRawDataUrlModule = memoize(() => require("../asset/RawDataUrlModule"));
const getIgnoredRawDataUrlModule = memoize(() => {
return new RawDataUrlModule("data:,", `ignored-asset`, `(ignored asset)`);
});

@@ -56,4 +59,3 @@ class CssUrlDependency extends ModuleDependency {

createIgnoredModule(context) {
const RawDataUrlModule = getRawDataUrlModule();
return new RawDataUrlModule("data:,", `ignored-asset`, `(ignored asset)`);
return getIgnoredRawDataUrlModule();
}

@@ -60,0 +62,0 @@

@@ -28,3 +28,3 @@ /*

* @param {Module} module the module
* @param {string[] | null} exportName name of the export if any
* @param {string[] | null} _exportName name of the export if any
* @param {string | null} property name of the requested property

@@ -34,4 +34,4 @@ * @param {RuntimeSpec} runtime for which runtime

*/
const getProperty = (moduleGraph, module, exportName, property, runtime) => {
if (!exportName) {
const getProperty = (moduleGraph, module, _exportName, property, runtime) => {
if (!_exportName) {
switch (property) {

@@ -53,2 +53,3 @@ case "usedExports": {

}
const exportName = /** @type {string[]} */ (_exportName);
switch (property) {

@@ -55,0 +56,0 @@ case "canMangle": {

@@ -23,3 +23,3 @@ /*

* @param {string} importedModule imported module
* @param {Array<{ name: string, value?: string }>|ImportSpecifiers} specifiers import specifiers
* @param {Array<{ name: string, value?: string }> | ImportSpecifiers} specifiers import specifiers
* @param {string=} defaultImport default import

@@ -60,3 +60,5 @@ */

if (newSpecifiersMap.has(name)) {
const currentSpecifiers = newSpecifiersMap.get(name);
const currentSpecifiers =
/** @type {Set<string>} */
(newSpecifiersMap.get(name));
for (const spec of specifiers) currentSpecifiers.add(spec);

@@ -76,3 +78,3 @@ } else {

* @param {GenerateContext} context context
* @returns {string | Source} the source code that will be included as initialization code
* @returns {string | Source | undefined} the source code that will be included as initialization code
*/

@@ -79,0 +81,0 @@ getContent({ runtimeRequirements }) {

@@ -8,3 +8,5 @@ /*

/** @typedef {import("estree").ArrowFunctionExpression} ArrowFunctionExpression */
/** @typedef {import("estree").Expression} Expression */
/** @typedef {import("estree").FunctionExpression} FunctionExpression */
/** @typedef {import("estree").SpreadElement} SpreadElement */

@@ -14,3 +16,3 @@

* @param {Expression | SpreadElement} expr expressions
* @returns {{fn: TODO, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
* @returns {{fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
*/

@@ -17,0 +19,0 @@ module.exports = expr => {

@@ -17,3 +17,3 @@ /*

/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
/** @typedef {import("../javascript/JavascriptParser").Assertions} Assertions */
/** @typedef {import("../javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */

@@ -37,7 +37,7 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

* @param {Range} range location in source code
* @param {Assertions} assertions assertions
* @param {Attributes} attributes assertions
* @param {string} operator operator
*/
constructor(request, sourceOrder, ids, name, range, assertions, operator) {
super(request, sourceOrder, ids, name, range, false, assertions, []);
constructor(request, sourceOrder, ids, name, range, attributes, operator) {
super(request, sourceOrder, ids, name, range, false, attributes, []);
this.operator = operator;

@@ -44,0 +44,0 @@ }

@@ -17,7 +17,10 @@ /*

harmonySpecifierTag,
getAssertions
getAttributes
} = require("./HarmonyImportDependencyParserPlugin");
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").FunctionDeclaration} FunctionDeclaration */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */

@@ -41,2 +44,6 @@ const { HarmonyStarExportsList } = HarmonyExportImportedSpecifierDependency;

/**
* @param {JavascriptParser} parser the parser
* @returns {void}
*/
apply(parser) {

@@ -48,6 +55,10 @@ const { exportPresenceMode } = this;

const dep = new HarmonyExportHeaderDependency(
statement.declaration && statement.declaration.range,
statement.range
/** @type {Range | false} */ (
statement.declaration && statement.declaration.range
),
/** @type {Range} */ (statement.range)
);
dep.loc = Object.create(statement.loc);
dep.loc = Object.create(
/** @type {DependencyLocation} */ (statement.loc)
);
dep.loc.index = -1;

@@ -63,12 +74,17 @@ parser.state.module.addPresentationalDependency(dep);

(parser.state.lastHarmonyImportOrder || 0) + 1;
const clearDep = new ConstDependency("", statement.range);
clearDep.loc = Object.create(statement.loc);
const clearDep = new ConstDependency(
"",
/** @type {Range} */ (statement.range)
);
clearDep.loc = /** @type {DependencyLocation} */ (statement.loc);
clearDep.loc.index = -1;
parser.state.module.addPresentationalDependency(clearDep);
const sideEffectDep = new HarmonyImportSideEffectDependency(
source,
/** @type {string} */ (source),
parser.state.lastHarmonyImportOrder,
getAssertions(statement)
getAttributes(statement)
);
sideEffectDep.loc = Object.create(statement.loc);
sideEffectDep.loc = Object.create(
/** @type {DependencyLocation} */ (statement.loc)
);
sideEffectDep.loc.index = -1;

@@ -83,9 +99,8 @@ parser.state.current.addDependency(sideEffectDep);

const isFunctionDeclaration = expr.type === "FunctionDeclaration";
const comments = parser.getComments([
statement.range[0],
expr.range[0]
]);
const exprRange = /** @type {Range} */ (expr.range);
const statementRange = /** @type {Range} */ (statement.range);
const comments = parser.getComments([statementRange[0], exprRange[0]]);
const dep = new HarmonyExportExpressionDependency(
expr.range,
statement.range,
exprRange,
statementRange,
comments

@@ -106,8 +121,7 @@ .map(c => {

? {
id: expr.id ? expr.id.name : undefined,
range: [
expr.range[0],
exprRange[0],
expr.params.length > 0
? expr.params[0].range[0]
: expr.body.range[0]
? /** @type {Range} */ (expr.params[0].range)[0]
: /** @type {Range} */ (expr.body.range)[0]
],

@@ -121,3 +135,5 @@ prefix: `${expr.async ? "async " : ""}function${

);
dep.loc = Object.create(statement.loc);
dep.loc = Object.create(
/** @type {DependencyLocation} */ (statement.loc)
);
dep.loc.index = -1;

@@ -159,3 +175,5 @@ parser.state.current.addDependency(dep);

}
dep.loc = Object.create(statement.loc);
dep.loc = Object.create(
/** @type {DependencyLocation} */ (statement.loc)
);
dep.loc.index = idx;

@@ -179,3 +197,3 @@ parser.state.current.addDependency(dep);

const dep = new HarmonyExportImportedSpecifierDependency(
source,
/** @type {string} */ (source),
parser.state.lastHarmonyImportOrder,

@@ -192,3 +210,5 @@ id ? [id] : [],

}
dep.loc = Object.create(statement.loc);
dep.loc = Object.create(
/** @type {DependencyLocation} */ (statement.loc)
);
dep.loc.index = idx;

@@ -195,0 +215,0 @@ parser.state.current.addDependency(dep);

@@ -20,3 +20,3 @@ /*

/**
* @param {Range} range range
* @param {Range | false} range range
* @param {Range} rangeStatement range statement

@@ -23,0 +23,0 @@ */

@@ -27,2 +27,3 @@ /*

/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */

@@ -34,3 +35,6 @@ /** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */

/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
/** @typedef {import("../ModuleGraph")} ModuleGraph */

@@ -41,3 +45,3 @@ /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */

/** @typedef {import("../WebpackError")} WebpackError */
/** @typedef {import("../javascript/JavascriptParser").Assertions} Assertions */
/** @typedef {import("../javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

@@ -84,3 +88,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */

// for "reexport-named-default" | "reexport-fake-namespace-object" | "reexport-namespace-object"
/** @type {string|null} */
/** @type {string | null} */
this.name = null;

@@ -183,3 +187,3 @@ /** @type {ExportInfo | null} */

const runtime = keyToRuntime(runtimeKey);
const parentModule = moduleGraph.getParentModule(dep);
const parentModule = /** @type {Module} */ (moduleGraph.getParentModule(dep));
const exportsInfo = moduleGraph.getExportsInfo(parentModule);

@@ -201,3 +205,3 @@

moduleGraph,
parentModule.buildMeta.strictHarmonyModule
/** @type {BuildMeta} */ (parentModule.buildMeta).strictHarmonyModule
);

@@ -342,3 +346,3 @@

* @param {HarmonyStarExportsList | null} allStarExports all star exports in the module
* @param {Assertions=} assertions import assertions
* @param {Attributes=} attributes import assertions
*/

@@ -354,5 +358,5 @@ constructor(

allStarExports,
assertions
attributes
) {
super(request, sourceOrder, assertions);
super(request, sourceOrder, attributes);

@@ -433,7 +437,8 @@ this.ids = ids;

runtime,
exportsInfo = moduleGraph.getExportsInfo(moduleGraph.getParentModule(this)),
importedModule = moduleGraph.getModule(this)
exportsInfo = moduleGraph.getExportsInfo(
/** @type {Module} */ (moduleGraph.getParentModule(this))
),
importedModule = /** @type {Module} */ (moduleGraph.getModule(this))
) {
const importedExportsInfo = moduleGraph.getExportsInfo(importedModule);
const noExtraExports =

@@ -468,3 +473,3 @@ importedExportsInfo.otherExportsInfo.provided === false;

const checked = new Set();
/** @type {Set<string>} */
/** @type {Set<string> | undefined} */
const hidden = hiddenExports !== undefined ? new Set() : undefined;

@@ -481,3 +486,4 @@

if (hiddenExports !== undefined && hiddenExports.has(name)) {
hidden.add(name);
/** @type {Set<string>} */
(hidden).add(name);
continue;

@@ -497,3 +503,4 @@ }

if (hiddenExports !== undefined && hiddenExports.has(name)) {
hidden.add(name);
/** @type {Set<string>} */
(hidden).add(name);
continue;

@@ -512,3 +519,3 @@ }

* @param {ModuleGraph} moduleGraph module graph
* @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
* @returns {null | false | GetConditionFn} function to determine if the connection is active
*/

@@ -649,3 +656,5 @@ getCondition(moduleGraph) {

case "dynamic-reexport": {
const from = moduleGraph.getConnection(this);
const from =
/** @type {ModuleGraphConnection} */
(moduleGraph.getConnection(this));
return {

@@ -666,7 +675,9 @@ exports: true,

hideExports: mode.hidden,
dependencies: [moduleGraph.getModule(this)]
dependencies: [/** @type {Module} */ (moduleGraph.getModule(this))]
};
// falls through
case "normal-reexport": {
const from = moduleGraph.getConnection(this);
const from =
/** @type {ModuleGraphConnection} */
(moduleGraph.getConnection(this));
return {

@@ -685,7 +696,9 @@ exports: Array.from(mode.items, item => ({

{
const from = moduleGraph.getConnection(this);
const from =
/** @type {ModuleGraphConnection} */
(moduleGraph.getConnection(this));
return {
exports: [
{
name: mode.name,
name: /** @type {string} */ (mode.name),
from,

@@ -702,11 +715,13 @@ export: ["default"]

return {
exports: [mode.name],
dependencies: [moduleGraph.getModule(this)]
exports: [/** @type {string} */ (mode.name)],
dependencies: [/** @type {Module} */ (moduleGraph.getModule(this))]
};
case "reexport-fake-namespace-object": {
const from = moduleGraph.getConnection(this);
const from =
/** @type {ModuleGraphConnection} */
(moduleGraph.getConnection(this));
return {
exports: [
{
name: mode.name,
name: /** @type {string} */ (mode.name),
from,

@@ -729,7 +744,9 @@ export: null,

case "reexport-namespace-object": {
const from = moduleGraph.getConnection(this);
const from =
/** @type {ModuleGraphConnection} */
(moduleGraph.getConnection(this));
return {
exports: [
{
name: mode.name,
name: /** @type {string} */ (mode.name),
from,

@@ -744,7 +761,9 @@ export: null

case "reexport-named-default": {
const from = moduleGraph.getConnection(this);
const from =
/** @type {ModuleGraphConnection} */
(moduleGraph.getConnection(this));
return {
exports: [
{
name: mode.name,
name: /** @type {string} */ (mode.name),
from,

@@ -770,3 +789,4 @@ export: ["default"]

return this.exportPresenceMode;
return moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
const module = /** @type {Module} */ (moduleGraph.getParentModule(this));
return /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule
? ExportPresenceModes.ERROR

@@ -849,3 +869,3 @@ : ExportPresenceModes.WARN;

const conflictingExportInfo = moduleGraph.getExportInfo(
conflictingModule,
/** @type {Module} */ (conflictingModule),
exportInfo.name

@@ -972,3 +992,3 @@ );

/**
* @param {InitFragment[]} initFragments target array for init fragments
* @param {InitFragment<GenerateContext>[]} initFragments target array for init fragments
* @param {HarmonyExportImportedSpecifierDependency} dep dependency

@@ -980,3 +1000,3 @@ * @param {ExportMode} mode the export mode

* @param {RuntimeTemplate} runtimeTemplate the runtime template
* @param {Set<string>} runtimeRequirements runtime requirements
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
* @returns {void}

@@ -994,3 +1014,3 @@ */

) {
const importedModule = moduleGraph.getModule(dep);
const importedModule = /** @type {Module} */ (moduleGraph.getModule(dep));
const importVar = dep.getImportVar(moduleGraph);

@@ -1196,2 +1216,10 @@

/**
* @param {Module} module module
* @param {string | string[] | false} key key
* @param {string} name name
* @param {number} fakeType fake type
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
* @returns {[InitFragment<GenerateContext>, HarmonyExportInitFragment]} init fragments
*/
getReexportFakeNamespaceObjectFragments(

@@ -1227,2 +1255,10 @@ module,

/**
* @param {Module} module module
* @param {string} key key
* @param {string} name name
* @param {string | string[] | false} valueKey value key
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
* @returns {string} result
*/
getConditionalReexportStatement(

@@ -1255,2 +1291,7 @@ module,

/**
* @param {string} name name
* @param {null | false | string | string[]} valueKey value key
* @returns {string | undefined} value
*/
getReturnValue(name, valueKey) {

@@ -1257,0 +1298,0 @@ if (valueKey === null) {

@@ -16,2 +16,6 @@ /*

/**
* @param {Iterable<string>} iterable iterable strings
* @returns {string} result
*/
const joinIterableWithComma = iterable => {

@@ -37,3 +41,3 @@ // This is more performant than Array.from().join(", ")

/**
* @typedef {GenerateContext} Context
* @extends {InitFragment<GenerateContext>} Context
*/

@@ -104,2 +108,6 @@ class HarmonyExportInitFragment extends InitFragment {

/**
* @param {HarmonyExportInitFragment} other other
* @returns {HarmonyExportInitFragment} merged result
*/
merge(other) {

@@ -137,3 +145,3 @@ let exportMap;

* @param {GenerateContext} context context
* @returns {string | Source} the source code that will be included as initialization code
* @returns {string | Source | undefined} the source code that will be included as initialization code
*/

@@ -140,0 +148,0 @@ getContent({ runtimeTemplate, runtimeRequirements }) {

@@ -23,7 +23,9 @@ /*

/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../ExportsInfo")} ExportsInfo */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../WebpackError")} WebpackError */
/** @typedef {import("../javascript/JavascriptParser").Assertions} Assertions */
/** @typedef {import("../javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

@@ -39,2 +41,6 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */

ERROR: /** @type {3} */ (3),
/**
* @param {string | false} str param
* @returns {0 | 1 | 2 | 3} result
*/
fromUserOption(str) {

@@ -61,8 +67,8 @@ switch (str) {

* @param {number} sourceOrder source order
* @param {Assertions=} assertions import assertions
* @param {Attributes=} attributes import assertions
*/
constructor(request, sourceOrder, assertions) {
constructor(request, sourceOrder, attributes) {
super(request);
this.sourceOrder = sourceOrder;
this.assertions = assertions;
this.assertions = attributes;
}

@@ -90,6 +96,8 @@

const module = moduleGraph.getParentModule(this);
const meta = moduleGraph.getMeta(module);
const meta = /** @type {TODO} */ (moduleGraph.getMeta(module));
let importVarMap = meta.importVarMap;
if (!importVarMap) meta.importVarMap = importVarMap = new Map();
let importVar = importVarMap.get(moduleGraph.getModule(this));
let importVar = importVarMap.get(
/** @type {Module} */ (moduleGraph.getModule(this))
);
if (importVar) return importVar;

@@ -99,3 +107,6 @@ importVar = `${Template.toIdentifier(

)}__WEBPACK_IMPORTED_MODULE_${importVarMap.size}__`;
importVarMap.set(moduleGraph.getModule(this), importVar);
importVarMap.set(
/** @type {Module} */ (moduleGraph.getModule(this)),
importVar
);
return importVar;

@@ -115,3 +126,3 @@ }

update,
module: moduleGraph.getModule(this),
module: /** @type {Module} */ (moduleGraph.getModule(this)),
chunkGraph,

@@ -138,6 +149,8 @@ importVar: this.getImportVar(moduleGraph),

const parentModule = moduleGraph.getParentModule(this);
const parentModule =
/** @type {Module} */
(moduleGraph.getParentModule(this));
const exportsType = importedModule.getExportsType(
moduleGraph,
parentModule.buildMeta.strictHarmonyModule
/** @type {BuildMeta} */ (parentModule.buildMeta).strictHarmonyModule
);

@@ -180,3 +193,5 @@ if (exportsType === "namespace" || exportsType === "default-with-named") {

}
exportsInfo = exportInfo.getNestedExportsInfo();
exportsInfo =
/** @type {ExportsInfo} */
(exportInfo.getNestedExportsInfo());
}

@@ -218,3 +233,4 @@

ids[0] !== "default" &&
importedModule.buildMeta.defaultObject === "redirect-warn"
/** @type {BuildMeta} */
(importedModule.buildMeta).defaultObject === "redirect-warn"
) {

@@ -221,0 +237,0 @@ // For these modules only the default export is supported

@@ -24,3 +24,6 @@ /*

/** @typedef {import("estree").ImportExpression} ImportExpression */
/** @typedef {import("estree").Literal} Literal */
/** @typedef {import("estree").MemberExpression} MemberExpression */
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
/** @typedef {import("estree").Property} Property */
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */

@@ -48,20 +51,43 @@ /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */

/**
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | ImportExpression} node node with assertions
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | (ImportExpression & { arguments?: ObjectExpression[] })} node node with assertions
* @returns {Record<string, any> | undefined} assertions
*/
function getAssertions(node) {
function getAttributes(node) {
if (
node.type === "ImportExpression" &&
node.arguments &&
node.arguments[0] &&
node.arguments[0].type === "ObjectExpression" &&
node.arguments[0].properties[0] &&
node.arguments[0].properties[0].type === "Property" &&
node.arguments[0].properties[0].value.type === "ObjectExpression" &&
node.arguments[0].properties[0].value.properties
) {
const properties = /** @type {Property[]} */ (
node.arguments[0].properties[0].value.properties
);
const result = {};
for (const property of properties) {
const key =
property.key.type === "Identifier"
? property.key.name
: /** @type {Literal} */ (property.key).value;
result[key] = /** @type {Literal} */ (property.value).value;
}
return result;
}
// TODO remove cast when @types/estree has been updated to import assertions
const assertions = /** @type {{ assertions?: ImportAttributeNode[] }} */ (
node
).assertions;
if (assertions === undefined) {
const attributes =
/** @type {{ assertions?: ImportAttributeNode[] }} */
(node).assertions;
if (attributes === undefined) {
return undefined;
}
const result = {};
for (const assertion of assertions) {
for (const attribute of attributes) {
const key =
assertion.key.type === "Identifier"
? assertion.key.name
: assertion.key.value;
result[key] = assertion.value.value;
attribute.key.type === "Identifier"
? attribute.key.name
: attribute.key.value;
result[key] = attribute.value.value;
}

@@ -130,7 +156,7 @@ return result;

parser.unsetAsiPosition(/** @type {Range} */ (statement.range)[1]);
const assertions = getAssertions(statement);
const attributes = getAttributes(statement);
const sideEffectDep = new HarmonyImportSideEffectDependency(
source,
/** @type {string} */ (source),
parser.state.lastHarmonyImportOrder,
assertions
attributes
);

@@ -151,3 +177,3 @@ sideEffectDep.loc = /** @type {DependencyLocation} */ (statement.loc);

sourceOrder: parser.state.lastHarmonyImportOrder,
assertions: getAssertions(statement)
assertions: getAttributes(statement)
});

@@ -375,2 +401,4 @@ return true;

module.exports.harmonySpecifierTag = harmonySpecifierTag;
module.exports.getAssertions = getAssertions;
// TODO remove it in webpack@6 in favor getAttributes
module.exports.getAssertions = getAttributes;
module.exports.getAttributes = getAttributes;

@@ -13,2 +13,3 @@ /*

/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */

@@ -19,3 +20,3 @@ /** @typedef {import("../Module")} Module */

/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
/** @typedef {import("../javascript/JavascriptParser").Assertions} Assertions */
/** @typedef {import("../javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("../util/Hash")} Hash */

@@ -26,8 +27,8 @@ /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */

/**
* @param {TODO} request the request string
* @param {string} request the request string
* @param {number} sourceOrder source order
* @param {Assertions=} assertions assertions
* @param {Attributes=} attributes assertions
*/
constructor(request, sourceOrder, assertions) {
super(request, sourceOrder, assertions);
constructor(request, sourceOrder, attributes) {
super(request, sourceOrder, attributes);
}

@@ -41,3 +42,3 @@

* @param {ModuleGraph} moduleGraph module graph
* @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
* @returns {null | false | GetConditionFn} function to determine if the connection is active
*/

@@ -44,0 +45,0 @@ getCondition(moduleGraph) {

@@ -20,2 +20,3 @@ /*

/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */

@@ -30,3 +31,3 @@ /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */

/** @typedef {import("../WebpackError")} WebpackError */
/** @typedef {import("../javascript/JavascriptParser").Assertions} Assertions */
/** @typedef {import("../javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */

@@ -50,3 +51,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

* @param {TODO} exportPresenceMode export presence mode
* @param {Assertions=} assertions assertions
* @param {Attributes=} attributes assertions
* @param {Range[]=} idRanges ranges for members of ids; the two arrays are right-aligned

@@ -61,6 +62,6 @@ */

exportPresenceMode,
assertions,
attributes,
idRanges // TODO webpack 6 make this non-optional. It must always be set to properly trim ids.
) {
super(request, sourceOrder, assertions);
super(request, sourceOrder, attributes);
this.ids = ids;

@@ -124,3 +125,3 @@ this.name = name;

* @param {ModuleGraph} moduleGraph module graph
* @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
* @returns {null | false | GetConditionFn} function to determine if the connection is active
*/

@@ -127,0 +128,0 @@ getCondition(moduleGraph) {

@@ -19,2 +19,3 @@ /*

/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */

@@ -30,7 +31,9 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

* @param {(string[][] | null)=} referencedExports list of referenced exports
* @param {Attributes=} attributes assertions
*/
constructor(request, range, referencedExports) {
constructor(request, range, referencedExports, attributes) {
super(request);
this.range = range;
this.referencedExports = referencedExports;
this.assertions = attributes;
}

@@ -57,3 +60,5 @@

if (referencedExport[0] === "default") {
const selfModule = moduleGraph.getParentModule(this);
const selfModule =
/** @type {Module} */
(moduleGraph.getParentModule(this));
const importedModule =

@@ -88,2 +93,3 @@ /** @type {Module} */

context.write(this.referencedExports);
context.write(this.assertions);
super.serialize(context);

@@ -98,2 +104,3 @@ }

this.referencedExports = context.read();
this.assertions = context.read();
super.deserialize(context);

@@ -100,0 +107,0 @@ }

@@ -18,2 +18,3 @@ /*

/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */

@@ -26,5 +27,6 @@

* @param {(string[][] | null)=} referencedExports list of referenced exports
* @param {Attributes=} attributes assertions
*/
constructor(request, range, referencedExports) {
super(request, range, referencedExports);
constructor(request, range, referencedExports, attributes) {
super(request, range, referencedExports, attributes);
}

@@ -31,0 +33,0 @@

@@ -12,3 +12,10 @@ /*

/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("./ContextDependency").ContextDependencyOptions} ContextDependencyOptions */
class ImportMetaContextDependency extends ContextDependency {
/**
* @param {ContextDependencyOptions} options options
* @param {Range} range range
*/
constructor(options, range) {

@@ -15,0 +22,0 @@ super(options);

@@ -19,4 +19,7 @@ /*

/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../ContextModule").ContextModuleOptions} ContextModuleOptions */
/** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
/** @typedef {Pick<ContextModuleOptions, 'mode'|'recursive'|'regExp'|'include'|'exclude'|'chunkName'>&{groupOptions: RawChunkGroupOptions, exports?: ContextModuleOptions["referencedExports"]}} ImportMetaContextOptions */

@@ -40,3 +43,3 @@

* @param {string} msg message
* @param {SourceLocation} loc location
* @param {DependencyLocation} loc location
* @returns {WebpackError} error

@@ -77,3 +80,3 @@ */

if (!requestExpr.isString()) return;
const request = requestExpr.string;
const request = /** @type {string} */ (requestExpr.string);
const errors = [];

@@ -101,3 +104,3 @@ let regExp = /^\.\/.*$/;

"Parsing import.meta.webpackContext options failed.",
optionsNode.loc
/** @type {DependencyLocation} */ (optionsNode.loc)
)

@@ -115,3 +118,3 @@ );

} else {
regExp = regExpExpr.regExp;
regExp = /** @type {RegExp} */ (regExpExpr.regExp);
}

@@ -171,9 +174,12 @@ break;

if (expr.isString()) {
exports = [[expr.string]];
exports = [[/** @type {string} */ (expr.string)]];
} else if (expr.isArray()) {
const items = expr.items;
const items =
/** @type {BasicEvaluatedExpression[]} */
(expr.items);
if (
items.every(i => {
if (!i.isArray()) return false;
const innerItems = i.items;
const innerItems =
/** @type {BasicEvaluatedExpression[]} */ (i.items);
return innerItems.every(i => i.isString());

@@ -184,5 +190,8 @@ })

for (const i1 of items) {
/** @type {string[]} */
const export_ = [];
for (const i2 of i1.items) {
export_.push(i2.string);
for (const i2 of /** @type {BasicEvaluatedExpression[]} */ (
i1.items
)) {
export_.push(/** @type {string} */ (i2.string));
}

@@ -235,3 +244,5 @@ exports.push(export_);

expr.isString() &&
["high", "low", "auto"].includes(expr.string)
["high", "low", "auto"].includes(
/** @type {string} */ (expr.string)
)
) {

@@ -256,3 +267,3 @@ groupOptions.fetchPriority =

} else {
recursive = recursiveExpr.bool;
recursive = /** @type {boolean} */ (recursiveExpr.bool);
}

@@ -267,3 +278,3 @@ break;

)}.`,
optionsNode.loc
/** @type {DependencyLocation} */ (optionsNode.loc)
)

@@ -292,5 +303,5 @@ );

},
expr.range
/** @type {Range} */ (expr.range)
);
dep.loc = expr.loc;
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
dep.optional = !!parser.scope.inTry;

@@ -297,0 +308,0 @@ parser.state.current.addDependency(dep);

@@ -12,2 +12,3 @@ /*

const ContextDependencyHelpers = require("./ContextDependencyHelpers");
const { getAttributes } = require("./HarmonyImportDependencyParserPlugin");
const ImportContextDependency = require("./ImportContextDependency");

@@ -18,2 +19,3 @@ const ImportDependency = require("./ImportDependency");

/** @typedef {import("estree").ImportExpression} ImportExpression */
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */

@@ -263,2 +265,4 @@ /** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */

if (param.isString()) {
const attributes = getAttributes(expr);
if (mode === "eager") {

@@ -268,3 +272,4 @@ const dep = new ImportEagerDependency(

/** @type {Range} */ (expr.range),
exports
exports,
attributes
);

@@ -276,3 +281,4 @@ parser.state.current.addDependency(dep);

/** @type {Range} */ (expr.range),
exports
exports,
attributes
);

@@ -292,3 +298,4 @@ parser.state.current.addDependency(dep);

/** @type {Range} */ (expr.range),
exports
exports,
attributes
);

@@ -324,3 +331,4 @@ dep.loc = /** @type {DependencyLocation} */ (expr.loc);

category: "esm",
referencedExports: exports
referencedExports: exports,
attributes: getAttributes(expr)
},

@@ -327,0 +335,0 @@ parser

@@ -18,2 +18,3 @@ /*

/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */

@@ -26,5 +27,6 @@

* @param {(string[][] | null)=} referencedExports list of referenced exports
* @param {Attributes=} attributes assertions
*/
constructor(request, range, referencedExports) {
super(request, range, referencedExports);
constructor(request, range, referencedExports, attributes) {
super(request, range, referencedExports, attributes);
this.weak = true;

@@ -31,0 +33,0 @@ }

@@ -10,2 +10,3 @@ /*

/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
/** @typedef {import("../ModuleGraph")} ModuleGraph */

@@ -34,3 +35,3 @@ /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */

* @param {ModuleGraph} moduleGraph module graph
* @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
* @returns {null | false | GetConditionFn} function to determine if the connection is active
*/

@@ -37,0 +38,0 @@ getCondition(moduleGraph) {

@@ -10,2 +10,3 @@ /*

/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
/** @typedef {import("../ModuleGraph")} ModuleGraph */

@@ -35,3 +36,3 @@ /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */

* @param {ModuleGraph} moduleGraph module graph
* @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
* @returns {null | false | GetConditionFn} function to determine if the connection is active
*/

@@ -38,0 +39,0 @@ getCondition(moduleGraph) {

@@ -10,11 +10,10 @@ /*

const DependencyTemplate = require("../DependencyTemplate");
const memoize = require("../util/memoize");
const RawModule = require("../RawModule");
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
const getRawModule = memoize(() => require("../RawModule"));
class ModuleDependency extends Dependency {

@@ -29,4 +28,5 @@ /**

this.range = undefined;
// TODO move it to subclasses and rename
// assertions must be serialized by subclasses that use it
/** @type {Record<string, any> | undefined} */
/** @type {Attributes | undefined} */
this.assertions = undefined;

@@ -66,3 +66,2 @@ this._context = undefined;

createIgnoredModule(context) {
const RawModule = getRawModule();
return new RawModule(

@@ -69,0 +68,0 @@ "/* (ignored) */",

@@ -18,2 +18,3 @@ /*

/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../ModuleGraph")} ModuleGraph */

@@ -110,3 +111,5 @@ /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */

if (usedByExports !== false) {
const selfModule = moduleGraph.getParentModule(dep);
const selfModule =
/** @type {Module} */
(moduleGraph.getParentModule(dep));
const exportsInfo = moduleGraph.getExportsInfo(selfModule);

@@ -113,0 +116,0 @@ const merged = deepMergeRuntime(runtimes, runtime);

@@ -83,3 +83,3 @@ /*

"dependencyType",
options.category
/** @type {string} */ (options.category)
)

@@ -86,0 +86,0 @@ ).options;

@@ -14,5 +14,12 @@ /*

/** @typedef {import("../ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
module.exports = class RequireEnsureDependenciesBlockParserPlugin {
/**
* @param {JavascriptParser} parser the parser
* @returns {void}
*/
apply(parser) {

@@ -49,5 +56,8 @@ parser.hooks.call

);
const dependenciesItems = dependenciesExpr.isArray()
? dependenciesExpr.items
: [dependenciesExpr];
const dependenciesItems =
/** @type {BasicEvaluatedExpression[]} */ (
dependenciesExpr.isArray()
? dependenciesExpr.items
: [dependenciesExpr]
);
const successExpressionArg = expr.arguments[1];

@@ -65,6 +75,5 @@ const successExpression =

const depBlock = new RequireEnsureDependenciesBlock(
/** @type {ChunkGroupOptions & { entryOptions?: TODO }} */ (
chunkName
),
expr.loc
/** @type {ChunkGroupOptions & { entryOptions?: TODO }} */
(chunkName),
/** @type {DependencyLocation} */ (expr.loc)
);

@@ -75,10 +84,11 @@ const errorCallbackExists =

const dep = new RequireEnsureDependency(
expr.range,
expr.arguments[1].range,
errorCallbackExists && expr.arguments[2].range
/** @type {Range} */ (expr.range),
/** @type {Range} */ (expr.arguments[1].range),
errorCallbackExists &&
/** @type {Range} */ (expr.arguments[2].range)
);
dep.loc = expr.loc;
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
depBlock.addDependency(dep);
const old = parser.state.current;
parser.state.current = depBlock;
parser.state.current = /** @type {TODO} */ (depBlock);
try {

@@ -90,5 +100,7 @@ let failed = false;

const ensureDependency = new RequireEnsureItemDependency(
ee.string
/** @type {string} */ (ee.string)
);
ensureDependency.loc = ee.loc || expr.loc;
ensureDependency.loc =
/** @type {DependencyLocation} */
(expr.loc);
depBlock.addDependency(ensureDependency);

@@ -95,0 +107,0 @@ } else {

@@ -24,3 +24,3 @@ /*

* @param {Range} contentRange content range
* @param {Range} errorHandlerRange error handler range
* @param {Range | false} errorHandlerRange error handler range
*/

@@ -27,0 +27,0 @@ constructor(range, contentRange, errorHandlerRange) {

@@ -9,2 +9,3 @@ /*

const RuntimeGlobals = require("../RuntimeGlobals");
const RawDataUrlModule = require("../asset/RawDataUrlModule");
const {

@@ -20,2 +21,3 @@ getDependencyUsedByExportsCondition

/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */

@@ -33,3 +35,5 @@ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */

const getRawDataUrlModule = memoize(() => require("../asset/RawDataUrlModule"));
const getIgnoredRawDataUrlModule = memoize(() => {
return new RawDataUrlModule("data:,", `ignored-asset`, `(ignored asset)`);
});

@@ -62,3 +66,3 @@ class URLDependency extends ModuleDependency {

* @param {ModuleGraph} moduleGraph module graph
* @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
* @returns {null | false | GetConditionFn} function to determine if the connection is active
*/

@@ -78,4 +82,3 @@ getCondition(moduleGraph) {

createIgnoredModule(context) {
const RawDataUrlModule = getRawDataUrlModule();
return new RawDataUrlModule("data:,", `ignored-asset`, `(ignored asset)`);
return getIgnoredRawDataUrlModule();
}

@@ -82,0 +85,0 @@

@@ -372,3 +372,4 @@ /*

parser.state.module.addPresentationalDependency(dep);
expressions.type = undefined;
/** @type {TODO} */
(expressions).type = undefined;
}

@@ -375,0 +376,0 @@ } else if (insertType === "comma") {

@@ -8,2 +8,3 @@ /*

const RawModule = require("./RawModule");
const memoize = require("./util/memoize");

@@ -84,6 +85,7 @@

/** @typedef {function(ModuleGraphConnection, RuntimeSpec): ConnectionState} GetConditionFn */
const TRANSITIVE = Symbol("transitive");
const getIgnoredModule = memoize(() => {
const RawModule = require("./RawModule");
return new RawModule("/* (ignored) */", `ignored`, `(ignored)`);

@@ -240,3 +242,3 @@ });

* @param {ModuleGraph} moduleGraph module graph
* @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
* @returns {null | false | GetConditionFn} function to determine if the connection is active
*/

@@ -243,0 +245,0 @@ getCondition(moduleGraph) {

@@ -16,4 +16,4 @@ /*

/** @typedef {import("./Generator").GenerateContext} GenerateContext */
/** @template T @typedef {import("./InitFragment")<T>} InitFragment */
/** @typedef {import("./Module")} Module */
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
/** @typedef {import("./ModuleGraph")} ModuleGraph */

@@ -23,2 +23,7 @@ /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */

/**
* @template T
* @typedef {import("./InitFragment")<T>} InitFragment
*/
/**
* @typedef {Object} DependencyTemplateContext

@@ -29,3 +34,3 @@ * @property {RuntimeTemplate} runtimeTemplate the runtime template

* @property {ChunkGraph} chunkGraph the chunk graph
* @property {Set<string>} runtimeRequirements the requirements for runtime
* @property {RuntimeRequirements} runtimeRequirements the requirements for runtime
* @property {Module} module current module

@@ -32,0 +37,0 @@ * @property {RuntimeSpec} runtime current runtime, for which code is generated

@@ -51,2 +51,3 @@ /*

// Info from Factory
/** @type {Dependency[]} */
this.dependencies = dependencies;

@@ -53,0 +54,0 @@ this.name = name;

@@ -20,2 +20,3 @@ /*

/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */

@@ -64,3 +65,4 @@ const validate = createSchemaValidation(

if (typeof manifest === "string") {
compiler.inputFileSystem.readFile(manifest, (err, result) => {
/** @type {InputFileSystem} */
(compiler.inputFileSystem).readFile(manifest, (err, result) => {
if (err) return callback(err);

@@ -75,3 +77,5 @@ const data = {

try {
data.data = parseJson(result.toString("utf-8"));
data.data = parseJson(
/** @type {Buffer} */ (result).toString("utf-8")
);
} catch (e) {

@@ -78,0 +82,0 @@ // Store the error in the params so that it can

@@ -44,3 +44,6 @@ /*

);
for (const entry of desc.import) {
const descImport =
/** @type {Exclude<EntryDescription["import"], undefined>} */
(desc.import);
for (const entry of descImport) {
new EntryPlugin(context, entry, options).apply(compiler);

@@ -47,0 +50,0 @@ }

@@ -62,3 +62,8 @@ /*

// TODO webpack 6 remove string option
dep.loc = { name: typeof options === "object" ? options.name : options };
dep.loc = {
name:
typeof options === "object"
? /** @type {string} */ (options.name)
: options
};
return dep;

@@ -65,0 +70,0 @@ }

@@ -92,3 +92,3 @@ /*

* @param {Chunk} newChunk New chunk that will be replaced with
* @returns {boolean} returns true if the replacement was successful
* @returns {boolean | undefined} returns true if the replacement was successful
*/

@@ -95,0 +95,0 @@ replaceChunk(oldChunk, newChunk) {

@@ -22,2 +22,3 @@ /*

/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */

@@ -56,3 +57,3 @@ /**

/**
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
*/

@@ -59,0 +60,0 @@ constructor(runtimeRequirements) {

@@ -210,5 +210,2 @@ /*

this._otherExportsInfo.setHasUseInfo();
if (this._otherExportsInfo.canMangleUse === undefined) {
this._otherExportsInfo.canMangleUse = true;
}
}

@@ -674,3 +671,3 @@ }

/**
* @param {string | string[]} name the export name
* @param {string | string[] | undefined} name the export name
* @param {RuntimeSpec} runtime check usage for this runtime only

@@ -677,0 +674,0 @@ * @returns {string | string[] | false} the used name

@@ -32,2 +32,4 @@ /*

/** @typedef {import("./ExportsInfo")} ExportsInfo */
/** @typedef {import("./Generator").GenerateContext} GenerateContext */
/** @typedef {import("./Module").BuildInfo} BuildInfo */
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */

@@ -38,3 +40,5 @@ /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */

/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
/** @typedef {import("./Module").SourceTypes} SourceTypes */
/** @typedef {import("./ModuleGraph")} ModuleGraph */
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */

@@ -46,2 +50,3 @@ /** @typedef {import("./RequestShortener")} RequestShortener */

/** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
/** @typedef {import("./javascript/JavascriptParser").Attributes} Attributes */
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

@@ -54,2 +59,7 @@ /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */

/** @typedef {{ attributes?: Attributes }} ImportDependencyMeta */
/** @typedef {{ layer?: string, supports?: string, media?: string }} CssImportDependencyMeta */
/** @typedef {ImportDependencyMeta | CssImportDependencyMeta} DependencyMeta */
/**

@@ -61,3 +71,3 @@ * @typedef {Object} SourceData

* @property {InitFragment<ChunkRenderContext>[]=} chunkInitFragments
* @property {ReadonlySet<string>=} runtimeRequirements
* @property {ReadOnlyRuntimeRequirements=} runtimeRequirements
*/

@@ -149,5 +159,10 @@

* @param {RuntimeTemplate} runtimeTemplate the runtime template
* @param {ImportDependencyMeta=} dependencyMeta the dependency meta
* @returns {SourceData} the generated source
*/
const getSourceForImportExternal = (moduleAndSpecifiers, runtimeTemplate) => {
const getSourceForImportExternal = (
moduleAndSpecifiers,
runtimeTemplate,
dependencyMeta
) => {
const importName = runtimeTemplate.outputOptions.importFunctionName;

@@ -159,5 +174,11 @@ if (!runtimeTemplate.supportsDynamicImport() && importName === "import") {

}
const attributes =
dependencyMeta && dependencyMeta.attributes
? `, ${JSON.stringify(dependencyMeta.attributes)}`
: "";
if (!Array.isArray(moduleAndSpecifiers)) {
return {
expression: `${importName}(${JSON.stringify(moduleAndSpecifiers)});`
expression: `${importName}(${JSON.stringify(
moduleAndSpecifiers
)}${attributes});`
};

@@ -167,3 +188,5 @@ }

return {
expression: `${importName}(${JSON.stringify(moduleAndSpecifiers[0])});`
expression: `${importName}(${JSON.stringify(
moduleAndSpecifiers[0]
)}${attributes});`
};

@@ -175,3 +198,3 @@ }

moduleName
)}).then(${runtimeTemplate.returningFunction(
)}${attributes}).then(${runtimeTemplate.returningFunction(
`module${propertyAccess(moduleAndSpecifiers, 1)}`,

@@ -183,2 +206,5 @@ "module"

/**
* @extends {InitFragment<ChunkRenderContext>}
*/
class ModuleExternalInitFragment extends InitFragment {

@@ -188,5 +214,6 @@ /**

* @param {string=} ident recomputed ident
* @param {ImportDependencyMeta=} dependencyMeta the dependency meta
* @param {string | HashConstructor=} hashFunction the hash function to use
*/
constructor(request, ident, hashFunction = "md4") {
constructor(request, ident, dependencyMeta, hashFunction = "md4") {
if (ident === undefined) {

@@ -203,3 +230,7 @@ ident = Template.toIdentifier(request);

super(
`import * as ${identifier} from ${JSON.stringify(request)};\n`,
`import * as ${identifier} from ${JSON.stringify(request)}${
dependencyMeta && dependencyMeta.attributes
? ` assert ${JSON.stringify(dependencyMeta.attributes)}`
: ""
};\n`,
InitFragment.STAGE_HARMONY_IMPORTS,

@@ -210,4 +241,5 @@ 0,

this._ident = ident;
this._request = request;
this._dependencyMeta = request;
this._identifier = identifier;
this._request = request;
}

@@ -228,5 +260,6 @@

write(obj._ident);
write(obj._dependencyMeta);
},
deserialize({ read }) {
return new ModuleExternalInitFragment(read(), read());
return new ModuleExternalInitFragment(read(), read(), read());
}

@@ -236,2 +269,9 @@ }

/**
* @param {string} input input
* @param {ExportsInfo} exportsInfo the exports info
* @param {RuntimeSpec=} runtime the runtime
* @param {RuntimeTemplate=} runtimeTemplate the runtime template
* @returns {string | undefined} the module remapping
*/
const generateModuleRemapping = (

@@ -260,5 +300,7 @@ input,

properties.push(
`[${JSON.stringify(used)}]: ${runtimeTemplate.returningFunction(
`${input}${propertyAccess([exportInfo.name])}`
)}`
`[${JSON.stringify(used)}]: ${
/** @type {RuntimeTemplate} */ (runtimeTemplate).returningFunction(
`${input}${propertyAccess([exportInfo.name])}`
)
}`
);

@@ -275,2 +317,3 @@ }

* @param {RuntimeTemplate} runtimeTemplate the runtime template
* @param {ImportDependencyMeta} dependencyMeta the dependency meta
* @returns {SourceData} the generated source

@@ -282,3 +325,4 @@ */

runtime,
runtimeTemplate
runtimeTemplate,
dependencyMeta
) => {

@@ -290,2 +334,3 @@ if (!Array.isArray(moduleAndSpecifiers))

undefined,
dependencyMeta,
runtimeTemplate.outputOptions.hashFunction

@@ -422,6 +467,7 @@ );

* @param {string | string[] | Record<string, string | string[]>} request request
* @param {TODO} type type
* @param {string} type type
* @param {string} userRequest user request
* @param {DependencyMeta=} dependencyMeta dependency meta
*/
constructor(request, type, userRequest) {
constructor(request, type, userRequest, dependencyMeta) {
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);

@@ -436,2 +482,4 @@

this.userRequest = userRequest;
/** @type {DependencyMeta=} */
this.dependencyMeta = dependencyMeta;
}

@@ -573,2 +621,7 @@

/**
* restore unsafe cache data
* @param {object} unsafeCacheData data from getUnsafeCacheData
* @param {NormalModuleFactory} normalModuleFactory the normal module factory handling the unsafe caching
*/
restoreFromUnsafeCache(unsafeCacheData, normalModuleFactory) {

@@ -602,2 +655,13 @@ this._restoreFromUnsafeCache(unsafeCacheData, normalModuleFactory);

/**
* @private
* @param {string | string[]} request request
* @param {string} externalType the external type
* @param {RuntimeTemplate} runtimeTemplate the runtime template
* @param {ModuleGraph} moduleGraph the module graph
* @param {ChunkGraph} chunkGraph the chunk graph
* @param {RuntimeSpec} runtime the runtime
* @param {DependencyMeta | undefined} dependencyMeta the dependency meta
* @returns {SourceData} the source data
*/
_getSourceData(

@@ -609,3 +673,4 @@ request,

chunkGraph,
runtime
runtime,
dependencyMeta
) {

@@ -628,6 +693,8 @@ switch (externalType) {

case "node-commonjs":
return this.buildInfo.module
return /** @type {BuildInfo} */ (this.buildInfo).module
? getSourceForCommonJsExternalInNodeModule(
request,
runtimeTemplate.outputOptions.importMetaName
/** @type {string} */ (
runtimeTemplate.outputOptions.importMetaName
)
)

@@ -650,7 +717,11 @@ : getSourceForCommonJsExternal(request);

case "import":
return getSourceForImportExternal(request, runtimeTemplate);
return getSourceForImportExternal(
request,
runtimeTemplate,
/** @type {ImportDependencyMeta} */ (dependencyMeta)
);
case "script":
return getSourceForScriptExternal(request, runtimeTemplate);
case "module": {
if (!this.buildInfo.module) {
if (!(/** @type {BuildInfo} */ (this.buildInfo).module)) {
if (!runtimeTemplate.supportsDynamicImport()) {

@@ -664,3 +735,7 @@ throw new Error(

}
return getSourceForImportExternal(request, runtimeTemplate);
return getSourceForImportExternal(
request,
runtimeTemplate,
/** @type {ImportDependencyMeta} */ (dependencyMeta)
);
}

@@ -676,3 +751,4 @@ if (!runtimeTemplate.supportsEcmaScriptModuleSyntax()) {

runtime,
runtimeTemplate
runtimeTemplate,
/** @type {ImportDependencyMeta} */ (dependencyMeta)
);

@@ -719,5 +795,20 @@ }

const sources = new Map();
const dependencyMeta = /** @type {CssImportDependencyMeta} */ (
this.dependencyMeta
);
const layer =
dependencyMeta.layer !== undefined
? ` layer(${dependencyMeta.layer})`
: "";
const supports = dependencyMeta.supports
? ` supports(${dependencyMeta.supports})`
: "";
const media = dependencyMeta.media ? ` ${dependencyMeta.media}` : "";
sources.set(
"css-import",
new RawSource(`@import url(${JSON.stringify(request)});`)
new RawSource(
`@import url(${JSON.stringify(
request
)})${layer}${supports}${media};`
)
);

@@ -736,3 +827,4 @@ return {

chunkGraph,
runtime
runtime,
this.dependencyMeta
);

@@ -825,2 +917,3 @@

write(this.userRequest);
write(this.dependencyMeta);

@@ -839,2 +932,3 @@ super.serialize(context);

this.userRequest = read();
this.dependencyMeta = read();

@@ -841,0 +935,0 @@ super.deserialize(context);

@@ -10,5 +10,12 @@ /*

const ExternalModule = require("./ExternalModule");
const ContextElementDependency = require("./dependencies/ContextElementDependency");
const CssImportDependency = require("./dependencies/CssImportDependency");
const HarmonyImportDependency = require("./dependencies/HarmonyImportDependency");
const ImportDependency = require("./dependencies/ImportDependency");
const { resolveByProperty, cachedSetProperty } = require("./util/cleverMerge");
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
/** @typedef {import("./Compilation").DepConstructor} DepConstructor */
/** @typedef {import("./ExternalModule").DependencyMeta} DependencyMeta */
/** @typedef {import("./Module")} Module */
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */

@@ -71,3 +78,3 @@

* @param {string|undefined} type type of external
* @param {function(Error=, ExternalModule=): void} callback callback
* @param {function((Error | null)=, ExternalModule=): void} callback callback
* @returns {void}

@@ -110,2 +117,23 @@ */

}
// TODO make it pluggable/add hooks to `ExternalModule` to allow output modules own externals?
/** @type {DependencyMeta | undefined} */
let dependencyMeta;
if (
dependency instanceof HarmonyImportDependency ||
dependency instanceof ImportDependency ||
dependency instanceof ContextElementDependency
) {
dependencyMeta = {
attributes: dependency.assertions
};
} else if (dependency instanceof CssImportDependency) {
dependencyMeta = {
layer: dependency.layer,
supports: dependency.supports,
media: dependency.media
};
}
callback(

@@ -116,3 +144,4 @@ null,

type || globalType,
dependency.request
dependency.request,
dependencyMeta
)

@@ -135,3 +164,9 @@ );

const next = () => {
/** @type {boolean | undefined} */
let asyncFlag;
/**
* @param {(Error | null)=} err err
* @param {ExternalModule=} module module
* @returns {void}
*/
const handleExternalsAndCallback = (err, module) => {

@@ -138,0 +173,0 @@ if (err) return callback(err);

@@ -16,2 +16,3 @@ /*

/** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
/** @typedef {import("./ModuleGraph")} ModuleGraph */

@@ -29,3 +30,3 @@ /** @typedef {import("./NormalModule")} NormalModule */

* @property {ChunkGraph} chunkGraph the chunk graph
* @property {Set<string>} runtimeRequirements the requirements for runtime
* @property {RuntimeRequirements} runtimeRequirements the requirements for runtime
* @property {RuntimeSpec} runtime the runtime

@@ -32,0 +33,0 @@ * @property {RuntimeSpec[]} [runtimes] the runtimes

@@ -15,3 +15,3 @@ /*

* @callback Callback
* @param {Error=} err
* @param {Error | null} err
* @param {T=} stats

@@ -55,3 +55,3 @@ * @returns {void}

* @template T
* @param {function((WebpackError | null)=, T=): void} callback webpack error callback
* @param {function(WebpackError | null, T=): void} callback webpack error callback
* @param {string} hook name of hook

@@ -58,0 +58,0 @@ * @returns {Callback<T>} generic callback

@@ -43,3 +43,3 @@ /*

/**
* @param {string | Source} content the source code that will be included as initialization code
* @param {string | Source | undefined} content the source code that will be included as initialization code
* @param {number} stage category of initialization code (contribute to order)

@@ -60,3 +60,3 @@ * @param {number} position position in the category (contribute to order)

* @param {GenerateContext} context context
* @returns {string | Source} the source code that will be included as initialization code
* @returns {string | Source | undefined} the source code that will be included as initialization code
*/

@@ -176,3 +176,5 @@ getContent(context) {

InitFragment.prototype.merge = undefined;
InitFragment.prototype.merge =
/** @type {TODO} */
(undefined);

@@ -179,0 +181,0 @@ InitFragment.STAGE_CONSTANTS = 10;

@@ -30,3 +30,3 @@ /*

this.type = TypeUnknown;
/** @type {[number, number] | undefined} */
/** @type {Range | undefined} */
this.range = undefined;

@@ -424,3 +424,3 @@ /** @type {boolean} */

* @param {BasicEvaluatedExpression | null | undefined} postfix Expression to be added after the innerExpressions
* @param {BasicEvaluatedExpression[]} innerExpressions Expressions to be wrapped
* @param {BasicEvaluatedExpression[] | undefined} innerExpressions Expressions to be wrapped
* @returns {this} this

@@ -427,0 +427,0 @@ */

@@ -14,4 +14,4 @@ /*

* @param {Entrypoint} entrypoint a chunk group
* @param {Chunk=} excludedChunk1 current chunk which is excluded
* @param {Chunk=} excludedChunk2 runtime chunk which is excluded
* @param {(Chunk | null)=} excludedChunk1 current chunk which is excluded
* @param {(Chunk | null)=} excludedChunk2 runtime chunk which is excluded
* @returns {Set<Chunk>} chunks

@@ -18,0 +18,0 @@ */

@@ -21,3 +21,3 @@ /*

* @param {string} value the const value
* @param {string[]=} runtimeRequirements runtime requirements
* @param {(string[] | null)=} runtimeRequirements runtime requirements
* @returns {function(Expression): true} plugin function

@@ -24,0 +24,0 @@ */

@@ -15,4 +15,6 @@ /*

/** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../Chunk").ChunkId} ChunkId */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../Entrypoint")} Entrypoint */
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */

@@ -77,5 +79,11 @@ /** @typedef {import("../ChunkGroup")} ChunkGroup */

for (const [module, entrypoint] of entries) {
const runtimeChunk = entrypoint.getRuntimeChunk();
const runtimeChunk =
/** @type {Entrypoint} */
(entrypoint).getRuntimeChunk();
const moduleId = chunkGraph.getModuleId(module);
const chunks = getAllChunks(entrypoint, chunk, runtimeChunk);
const chunks = getAllChunks(
/** @type {Entrypoint} */ (entrypoint),
chunk,
runtimeChunk
);
if (

@@ -113,7 +121,14 @@ currentChunks &&

for (const [module, entrypoint] of entries) {
const runtimeChunk = entrypoint.getRuntimeChunk();
const runtimeChunk =
/** @type {Entrypoint} */
(entrypoint).getRuntimeChunk();
const moduleId = chunkGraph.getModuleId(module);
hash.update(`${moduleId}`);
for (const c of getAllChunks(entrypoint, chunk, runtimeChunk))
for (const c of getAllChunks(
/** @type {Entrypoint} */ (entrypoint),
chunk,
/** @type {Chunk} */ (runtimeChunk)
)) {
hash.update(`${c.id}`);
}
}

@@ -132,5 +147,7 @@ };

if (c === chunk || filterFn(c, chunkGraph)) continue;
for (const id of c.ids) initialChunkIds.add(id);
for (const id of /** @type {ChunkId[]} */ (c.ids)) {
initialChunkIds.add(id);
}
}
return initialChunkIds;
};

@@ -15,2 +15,3 @@ /*

/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Compiler").IntermediateFileSystem} IntermediateFileSystem */
/** @typedef {import("./Module").BuildMeta} BuildMeta */

@@ -56,2 +57,4 @@

const moduleGraph = compilation.moduleGraph;
// store used paths to detect issue and output an error. #18200
const usedPaths = new Set();
asyncLib.forEach(

@@ -68,2 +71,7 @@ Array.from(compilation.chunks),

});
if (usedPaths.has(targetPath)) {
callback(new Error(`each chunk must have a unique path`));
return;
}
usedPaths.add(targetPath);
const name =

@@ -119,12 +127,12 @@ this.options.name &&

const buffer = Buffer.from(manifestContent, "utf8");
const intermediateFileSystem =
/** @type {IntermediateFileSystem} */ (
compiler.intermediateFileSystem
);
mkdirp(
compiler.intermediateFileSystem,
dirname(compiler.intermediateFileSystem, targetPath),
intermediateFileSystem,
dirname(intermediateFileSystem, targetPath),
err => {
if (err) return callback(err);
compiler.intermediateFileSystem.writeFile(
targetPath,
buffer,
callback
);
intermediateFileSystem.writeFile(targetPath, buffer, callback);
}

@@ -131,0 +139,0 @@ );

@@ -15,2 +15,3 @@ /*

/** @typedef {function(string): boolean} FilterFunction */
/** @typedef {function(string, LogTypeEnum, any[]): void} LoggingFunction */

@@ -44,3 +45,3 @@ /**

* @param {FilterItemTypes} item an input item
* @returns {FilterFunction} filter function
* @returns {FilterFunction | undefined} filter function
*/

@@ -81,11 +82,14 @@ const filterToFunction = item => {

* @param {LoggerOptions} options options object
* @returns {function(string, LogTypeEnum, any[]): void} logging function
* @returns {LoggingFunction} logging function
*/
module.exports = ({ level = "info", debug = false, console }) => {
const debugFilters =
typeof debug === "boolean"
? [() => debug]
: /** @type {FilterItemTypes[]} */ ([])
.concat(debug)
.map(filterToFunction);
/** @type {FilterFunction[]} */
(
typeof debug === "boolean"
? [() => debug]
: /** @type {FilterItemTypes[]} */ ([])
.concat(debug)
.map(filterToFunction)
);
/** @type {number} */

@@ -92,0 +96,0 @@ const loglevel = LogLevel[`${level}`] || 0;

@@ -98,2 +98,5 @@ /*

/**
* @param {string=} label label
*/
profile(label) {

@@ -103,2 +106,5 @@ this[LOG_SYMBOL](LogType.profile, [label]);

/**
* @param {string=} label label
*/
profileEnd(label) {

@@ -108,3 +114,7 @@ this[LOG_SYMBOL](LogType.profileEnd, [label]);

/**
* @param {string} label label
*/
time(label) {
/** @type {Map<string | undefined, [number, number]>} */
this[TIMERS_SYMBOL] = this[TIMERS_SYMBOL] || new Map();

@@ -114,2 +124,5 @@ this[TIMERS_SYMBOL].set(label, process.hrtime());

/**
* @param {string=} label label
*/
timeLog(label) {

@@ -124,2 +137,5 @@ const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);

/**
* @param {string=} label label
*/
timeEnd(label) {

@@ -131,6 +147,10 @@ const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);

const time = process.hrtime(prev);
this[TIMERS_SYMBOL].delete(label);
/** @type {Map<string | undefined, [number, number]>} */
(this[TIMERS_SYMBOL]).delete(label);
this[LOG_SYMBOL](LogType.time, [label, ...time]);
}
/**
* @param {string=} label label
*/
timeAggregate(label) {

@@ -144,3 +164,5 @@ const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);

const time = process.hrtime(prev);
this[TIMERS_SYMBOL].delete(label);
/** @type {Map<string | undefined, [number, number]>} */
(this[TIMERS_SYMBOL]).delete(label);
/** @type {Map<string | undefined, [number, number]>} */
this[TIMERS_AGGREGATES_SYMBOL] =

@@ -161,2 +183,5 @@ this[TIMERS_AGGREGATES_SYMBOL] || new Map();

/**
* @param {string=} label label
*/
timeAggregateEnd(label) {

@@ -163,0 +188,0 @@ if (this[TIMERS_AGGREGATES_SYMBOL] === undefined) return;

@@ -67,3 +67,3 @@ /*

* @property {ConcatenationScope=} concatenationScope when in concatenated module, information about other concatenated modules
* @property {CodeGenerationResults} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that)
* @property {CodeGenerationResults | undefined} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that)
* @property {Compilation=} compilation the compilation

@@ -79,2 +79,5 @@ * @property {ReadonlySet<string>=} sourceTypes source types

/** @typedef {Set<string>} RuntimeRequirements */
/** @typedef {ReadonlySet<string>} ReadOnlyRuntimeRequirements */
/**

@@ -84,3 +87,3 @@ * @typedef {Object} CodeGenerationResult

* @property {Map<string, any>=} data the resulting data for all source types
* @property {ReadonlySet<string>} runtimeRequirements the runtime requirements
* @property {ReadOnlyRuntimeRequirements} runtimeRequirements the runtime requirements
* @property {string=} hash a hash of the code generation result (will be automatically calculated from sources and runtimeRequirements if not provided)

@@ -276,2 +279,5 @@ */

/**
* @returns {number | null} the pre order index
*/
get index() {

@@ -285,2 +291,5 @@ return ModuleGraph.getModuleGraphForModule(

/**
* @param {number} value the pre order index
*/
set index(value) {

@@ -294,2 +303,5 @@ ModuleGraph.getModuleGraphForModule(

/**
* @returns {number | null} the post order index
*/
get index2() {

@@ -303,2 +315,5 @@ return ModuleGraph.getModuleGraphForModule(

/**
* @param {number} value the post order index
*/
set index2(value) {

@@ -312,2 +327,5 @@ ModuleGraph.getModuleGraphForModule(

/**
* @returns {number | null} the depth
*/
get depth() {

@@ -321,2 +339,5 @@ return ModuleGraph.getModuleGraphForModule(

/**
* @param {number} value the depth
*/
set depth(value) {

@@ -330,2 +351,5 @@ ModuleGraph.getModuleGraphForModule(

/**
* @returns {Module | null | undefined} issuer
*/
get issuer() {

@@ -339,2 +363,5 @@ return ModuleGraph.getModuleGraphForModule(

/**
* @param {Module | null} value issuer
*/
set issuer(value) {

@@ -886,2 +913,3 @@ ModuleGraph.getModuleGraphForModule(

const sources = this.codeGeneration(codeGenContext).sources;
return type ? sources.get(type) : sources.get(first(this.getSourceTypes()));

@@ -888,0 +916,0 @@ }

@@ -118,3 +118,3 @@ /*

* only evaluated when they are accessed. This is only obtained by setting a function as the value for each key.
* @param {Record<string, () => T>} obj the object to covert to a lazy access object
* @param {Record<string, () => T>} obj the object to convert to a lazy access object
* @returns {Object} the lazy access object

@@ -121,0 +121,0 @@ */

@@ -92,9 +92,12 @@ /*

/** @typedef {SortableSet<ModuleGraphConnection>} IncomingConnections */
/** @typedef {SortableSet<ModuleGraphConnection>} OutgoingConnections */
class ModuleGraphModule {
constructor() {
/** @type {SortableSet<ModuleGraphConnection>} */
/** @type {IncomingConnections} */
this.incomingConnections = new SortableSet();
/** @type {SortableSet<ModuleGraphConnection> | undefined} */
/** @type {OutgoingConnections | undefined} */
this.outgoingConnections = undefined;
/** @type {Module | null} */
/** @type {Module | null | undefined} */
this.issuer = undefined;

@@ -111,7 +114,7 @@ /** @type {(string | OptimizationBailoutFunction)[]} */

this.depth = null;
/** @type {ModuleProfile | undefined | null} */
/** @type {ModuleProfile | undefined} */
this.profile = undefined;
/** @type {boolean} */
this.async = false;
/** @type {ModuleGraphConnection[]} */
/** @type {ModuleGraphConnection[] | undefined} */
this._unassignedConnections = undefined;

@@ -123,16 +126,32 @@ }

constructor() {
/** @type {WeakMap<Dependency, ModuleGraphConnection | null>} */
/**
* @type {WeakMap<Dependency, ModuleGraphConnection | null>}
* @private
*/
this._dependencyMap = new WeakMap();
/** @type {Map<Module, ModuleGraphModule>} */
/**
* @type {Map<Module, ModuleGraphModule>}
* @private
*/
this._moduleMap = new Map();
/** @type {WeakMap<any, Object>} */
/**
* @type {WeakMap<any, Object>}
* @private
*/
this._metaMap = new WeakMap();
/** @type {WeakTupleMap<any[], any> | undefined} */
/**
* @type {WeakTupleMap<any[], any> | undefined}
* @private
*/
this._cache = undefined;
/** @type {Map<Module, WeakTupleMap<any, any>>} */
/**
* @type {Map<Module, WeakTupleMap<any, any>> | undefined}
* @private
*/
this._moduleMemCaches = undefined;
/** @type {string | undefined} */
/**
* @type {string | undefined}
* @private
*/
this._cacheStage = undefined;

@@ -169,3 +188,3 @@ }

* @param {Dependency} dependency the dependency
* @returns {Module} parent module
* @returns {Module | undefined} parent module
*/

@@ -178,3 +197,3 @@ getParentModule(dependency) {

* @param {Dependency} dependency the dependency
* @returns {DependenciesBlock} parent block
* @returns {DependenciesBlock | undefined} parent block
*/

@@ -194,3 +213,3 @@ getParentBlock(dependency) {

/**
* @param {Module} originModule the referencing module
* @param {Module | null} originModule the referencing module
* @param {Dependency} dependency the referencing dependency

@@ -240,4 +259,7 @@ * @param {Module} module the referenced module

connection.setActive(false);
const originMgm = this._getModuleGraphModule(connection.originModule);
originMgm.outgoingConnections.add(newConnection);
const originMgm = this._getModuleGraphModule(
/** @type {Module} */ (connection.originModule)
);
/** @type {OutgoingConnections} */
(originMgm.outgoingConnections).add(newConnection);
const targetMgm = this._getModuleGraphModule(module);

@@ -252,7 +274,12 @@ targetMgm.incomingConnections.add(newConnection);

removeConnection(dependency) {
const connection = this.getConnection(dependency);
const connection =
/** @type {ModuleGraphConnection} */
(this.getConnection(dependency));
const targetMgm = this._getModuleGraphModule(connection.module);
targetMgm.incomingConnections.delete(connection);
const originMgm = this._getModuleGraphModule(connection.originModule);
originMgm.outgoingConnections.delete(connection);
const originMgm = this._getModuleGraphModule(
/** @type {Module} */ (connection.originModule)
);
/** @type {OutgoingConnections} */
(originMgm.outgoingConnections).delete(connection);
this._dependencyMap.set(dependency, null);

@@ -267,3 +294,5 @@ }

addExplanation(dependency, explanation) {
const connection = this.getConnection(dependency);
const connection =
/** @type {ModuleGraphConnection} */
(this.getConnection(dependency));
connection.addExplanation(explanation);

@@ -480,3 +509,3 @@ }

* @param {Module} module the module
* @returns {readonly Map<Module | undefined, readonly ModuleGraphConnection[]>} reasons why a module is included, in a map by source module
* @returns {readonly Map<Module | undefined | null, readonly ModuleGraphConnection[]>} reasons why a module is included, in a map by source module
*/

@@ -501,3 +530,3 @@ getIncomingConnectionsByOriginModule(module) {

* @param {Module} module the module
* @returns {ModuleProfile | null} the module profile
* @returns {ModuleProfile | undefined} the module profile
*/

@@ -511,3 +540,3 @@ getProfile(module) {

* @param {Module} module the module
* @param {ModuleProfile | null} profile the module profile
* @param {ModuleProfile | undefined} profile the module profile
* @returns {void}

@@ -522,3 +551,3 @@ */

* @param {Module} module the module
* @returns {Module | null} the issuer module
* @returns {Module | null | undefined} the issuer module
*/

@@ -805,3 +834,3 @@ getIssuer(module) {

const memCache = this._moduleMemCaches.get(
this.getParentModule(dependency)
/** @type {Module} */ (this.getParentModule(dependency))
);

@@ -808,0 +837,0 @@ if (memCache !== undefined) {

@@ -9,2 +9,3 @@ /*

/** @typedef {import("./Dependency")} Dependency */
/** @typedef {import("./Dependency").GetConditionFn} GetConditionFn */
/** @typedef {import("./Module")} Module */

@@ -60,3 +61,3 @@ /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */

* @param {boolean=} weak the reference is weak
* @param {false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState=} condition condition for the connection
* @param {false | null | GetConditionFn | undefined} condition condition for the connection
*/

@@ -63,0 +64,0 @@ constructor(

@@ -31,3 +31,3 @@ /*

* @callback Callback
* @param {(Error | null)=} err
* @param {Error | null} err
* @param {T=} result

@@ -54,5 +54,7 @@ */

if (!Array.isArray(compilers)) {
/** @type {Compiler[]} */
compilers = Object.keys(compilers).map(name => {
compilers[name].name = name;
return compilers[name];
/** @type {Record<string, Compiler>} */
(compilers)[name].name = name;
return /** @type {Record<string, Compiler>} */ (compilers)[name];
});

@@ -226,6 +228,15 @@ }

};
/**
* @param {{source: Compiler, target: Compiler}} e1 edge 1
* @param {{source: Compiler, target: Compiler}} e2 edge 2
* @returns {number} result
*/
const sortEdges = (e1, e2) => {
return (
e1.source.name.localeCompare(e2.source.name) ||
e1.target.name.localeCompare(e2.target.name)
/** @type {string} */
(e1.source.name).localeCompare(
/** @type {string} */ (e2.source.name)
) ||
/** @type {string} */
(e1.target.name).localeCompare(/** @type {string} */ (e2.target.name))
);

@@ -296,2 +307,5 @@ };

const isDependencyFulfilled = d => fulfilledNames.has(d);
/**
* @returns {Compiler[]} compilers
*/
const getReadyCompilers = () => {

@@ -318,3 +332,3 @@ let readyCompilers = [];

const runCompilers = callback => {
if (remainingCompilers.length === 0) return callback();
if (remainingCompilers.length === 0) return callback(null);
asyncLib.map(

@@ -329,3 +343,5 @@ getReadyCompilers(),

},
/** @type {Callback<TODO>} */ (callback)
(err, results) => {
callback(err, /** @type {TODO} */ (results));
}
);

@@ -611,5 +627,7 @@ };

},
callback
error => {
callback(error);
}
);
}
};

@@ -11,3 +11,13 @@ /*

/** @typedef {import("../logging/createConsoleLogger").LoggerConsole} LoggerConsole */
/**
* @param {Object} options options
* @param {boolean=} options.colors colors
* @param {boolean=} options.appendOnly append only
* @param {NodeJS.WritableStream} options.stream stream
* @returns {LoggerConsole} logger function
*/
module.exports = ({ colors, appendOnly, stream }) => {
/** @type {string[] | undefined} */
let currentStatusMessage = undefined;

@@ -18,2 +28,9 @@ let hasStatusMessage = false;

/**
* @param {string} str string
* @param {string} prefix prefix
* @param {string} colorPrefix color prefix
* @param {string} colorSuffix color suffix
* @returns {string} indented string
*/
const indent = (str, prefix, colorPrefix, colorSuffix) => {

@@ -43,3 +60,3 @@ if (str === "") return str;

if (!currentStatusMessage) return;
const l = stream.columns || 40;
const l = /** @type {TODO} */ (stream).columns || 40;
const args = truncateArgs(currentStatusMessage, l - 1);

@@ -52,2 +69,8 @@ const str = args.join(" ");

/**
* @param {string} prefix prefix
* @param {string} colorPrefix color prefix
* @param {string} colorSuffix color suffix
* @returns {(function(...any[]): void)} function to write with colors
*/
const writeColored = (prefix, colorPrefix, colorSuffix) => {

@@ -54,0 +77,0 @@ return (...args) => {

@@ -8,3 +8,3 @@ /*

const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
const CachedInputFileSystem = require("enhanced-resolve").CachedInputFileSystem;
const fs = require("graceful-fs");

@@ -17,2 +17,3 @@ const createConsoleLogger = require("../logging/createConsoleLogger");

/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */

@@ -43,14 +44,19 @@ class NodeEnvironmentPlugin {

appendOnly: infrastructureLogging.appendOnly,
stream: infrastructureLogging.stream
stream:
/** @type {NodeJS.WritableStream} */
(infrastructureLogging.stream)
})
});
compiler.inputFileSystem = new CachedInputFileSystem(fs, 60000);
const inputFileSystem = compiler.inputFileSystem;
const inputFileSystem =
/** @type {InputFileSystem} */
(compiler.inputFileSystem);
compiler.outputFileSystem = fs;
compiler.intermediateFileSystem = fs;
compiler.watchFileSystem = new NodeWatchFileSystem(
compiler.inputFileSystem
);
compiler.watchFileSystem = new NodeWatchFileSystem(inputFileSystem);
compiler.hooks.beforeRun.tap("NodeEnvironmentPlugin", compiler => {
if (compiler.inputFileSystem === inputFileSystem) {
if (
compiler.inputFileSystem === inputFileSystem &&
inputFileSystem.purge
) {
compiler.fsStartTime = Date.now();

@@ -57,0 +63,0 @@ inputFileSystem.purge();

@@ -13,2 +13,3 @@ /*

/** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
/** @typedef {import("../util/fs").WatchFileSystem} WatchFileSystem */

@@ -19,2 +20,5 @@ /** @typedef {import("../util/fs").WatchMethod} WatchMethod */

class NodeWatchFileSystem {
/**
* @param {InputFileSystem} inputFileSystem input filesystem
*/
constructor(inputFileSystem) {

@@ -31,6 +35,6 @@ this.inputFileSystem = inputFileSystem;

* @param {Iterable<string>} directories watched directories
* @param {Iterable<string>} missing watched exitance entries
* @param {Iterable<string>} missing watched existence entries
* @param {number} startTime timestamp of start time
* @param {WatchOptions} options options object
* @param {function((Error | null)=, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback
* @param {function(Error | null, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback
* @param {function(string, number): void} callbackUndelayed callback when the first change was detected

@@ -87,24 +91,31 @@ * @returns {Watcher} a watcher

};
this.watcher.once("aggregated", (changes, removals) => {
// pause emitting events (avoids clearing aggregated changes and removals on timeout)
this.watcher.pause();
this.watcher.once(
"aggregated",
/**
* @param {Set<string>} changes changes
* @param {Set<string>} removals removals
*/
(changes, removals) => {
// pause emitting events (avoids clearing aggregated changes and removals on timeout)
this.watcher.pause();
if (this.inputFileSystem && this.inputFileSystem.purge) {
const fs = this.inputFileSystem;
for (const item of changes) {
fs.purge(item);
if (fs && fs.purge) {
for (const item of changes) {
fs.purge(item);
}
for (const item of removals) {
fs.purge(item);
}
}
for (const item of removals) {
fs.purge(item);
}
const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
callback(
null,
fileTimeInfoEntries,
contextTimeInfoEntries,
changes,
removals
);
}
const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
callback(
null,
fileTimeInfoEntries,
contextTimeInfoEntries,
changes,
removals
);
});
);

@@ -131,4 +142,4 @@ this.watcher.watch({ files, directories, missing, startTime });

const items = this.watcher && this.watcher.aggregatedRemovals;
if (items && this.inputFileSystem && this.inputFileSystem.purge) {
const fs = this.inputFileSystem;
const fs = this.inputFileSystem;
if (items && fs && fs.purge) {
for (const item of items) {

@@ -146,4 +157,4 @@ fs.purge(item);

const items = this.watcher && this.watcher.aggregatedChanges;
if (items && this.inputFileSystem && this.inputFileSystem.purge) {
const fs = this.inputFileSystem;
const fs = this.inputFileSystem;
if (items && fs && fs.purge) {
for (const item of items) {

@@ -175,4 +186,4 @@ fs.purge(item);

const changes = this.watcher && this.watcher.aggregatedChanges;
if (this.inputFileSystem && this.inputFileSystem.purge) {
const fs = this.inputFileSystem;
const fs = this.inputFileSystem;
if (fs && fs.purge) {
if (removals) {

@@ -179,0 +190,0 @@ for (const item of removals) {

@@ -21,6 +21,7 @@ /*

/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
/**
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
*/

@@ -27,0 +28,0 @@ constructor(runtimeRequirements) {

@@ -21,6 +21,7 @@ /*

/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
class RequireChunkLoadingRuntimeModule extends RuntimeModule {
/**
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
*/

@@ -27,0 +28,0 @@ constructor(runtimeRequirements) {

@@ -35,2 +35,3 @@ /*

/** @typedef {import("./javascript/JavascriptParser").Range} Range */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */

@@ -197,3 +198,7 @@ const PLUGIN_NAME = "NodeStuffPlugin";

setModuleConstant("__filename", module =>
relative(compiler.inputFileSystem, context, module.resource)
relative(
/** @type {InputFileSystem} */ (compiler.inputFileSystem),
context,
module.resource
)
);

@@ -232,3 +237,7 @@ break;

setModuleConstant("__dirname", module =>
relative(compiler.inputFileSystem, context, module.context)
relative(
/** @type {InputFileSystem} */ (compiler.inputFileSystem),
context,
/** @type {string} */ (module.context)
)
);

@@ -242,3 +251,5 @@ break;

if (!parser.state.module) return;
return evaluateToString(parser.state.module.context)(expr);
return evaluateToString(
/** @type {string} */ (parser.state.module.context)
)(expr);
});

@@ -245,0 +256,0 @@ }

@@ -929,2 +929,4 @@ /*

loaderContext._module =
// eslint-disable-next-line no-warning-comments
// @ts-ignore
loaderContext.fs =

@@ -1356,3 +1358,3 @@ undefined;

)
: this.generator.generate(this, {
: /** @type {Generator} */ (this.generator).generate(this, {
dependencyTemplates,

@@ -1359,0 +1361,0 @@ runtimeTemplate,

@@ -271,3 +271,3 @@ /*

),
/** @type {AsyncSeriesBailHook<[ResolveData], Module>} */
/** @type {AsyncSeriesBailHook<[ResolveData], Module | undefined>} */
factorize: new AsyncSeriesBailHook(["resolveData"]),

@@ -274,0 +274,0 @@ /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */

@@ -11,2 +11,4 @@ /*

/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
/** @typedef {function(import("./NormalModuleFactory").ResolveData): void} ModuleReplacer */

@@ -53,3 +55,5 @@

} else {
const fs = compiler.inputFileSystem;
const fs =
/** @type {InputFileSystem} */
(compiler.inputFileSystem);
if (

@@ -56,0 +60,0 @@ newResource.startsWith("/") ||

@@ -103,2 +103,3 @@ /*

let fromAggressiveSplittingSet;
/** @type {Map<Chunk, TODO>} */
let chunkSplitDataMap;

@@ -105,0 +106,0 @@ compilation.hooks.optimize.tap("AggressiveSplittingPlugin", () => {

@@ -40,3 +40,5 @@ /*

/** @typedef {import("eslint-scope").Reference} Reference */
/** @typedef {import("eslint-scope").Scope} Scope */
/** @typedef {import("eslint-scope").Variable} Variable */
/** @typedef {import("webpack-sources").Source} Source */

@@ -52,6 +54,8 @@ /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */

/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
/** @template T @typedef {import("../InitFragment")<T>} InitFragment */
/** @typedef {import("../Module").BuildInfo} BuildInfo */
/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
/** @typedef {import("../Module").SourceTypes} SourceTypes */

@@ -66,2 +70,5 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */

/** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
/** @typedef {import("../javascript/JavascriptParser").Program} Program */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("../util/Hash")} Hash */

@@ -72,5 +79,15 @@ /** @typedef {typeof import("../util/Hash")} HashConstructor */

/**
* @template T
* @typedef {import("../InitFragment")<T>} InitFragment
*/
/**
* @template T
* @typedef {import("../util/comparators").Comparator<T>} Comparator
*/
// fix eslint-scope to support class properties correctly
// cspell:word Referencer
const ReferencerClass = Referencer;
const ReferencerClass = /** @type {any} */ (Referencer);
if (!ReferencerClass.prototype.PropertyDefinition) {

@@ -115,20 +132,20 @@ ReferencerClass.prototype.PropertyDefinition =

* @property {number} index
* @property {Object} ast
* @property {Program | undefined} ast
* @property {Source} internalSource
* @property {ReplaceSource} source
* @property {InitFragment<ChunkRenderContext>[]=} chunkInitFragments
* @property {Iterable<string>} runtimeRequirements
* @property {ReadOnlyRuntimeRequirements} runtimeRequirements
* @property {Scope} globalScope
* @property {Scope} moduleScope
* @property {Map<string, string>} internalNames
* @property {Map<string, string>} exportMap
* @property {Map<string, string>} rawExportMap
* @property {Map<string, string> | undefined} exportMap
* @property {Map<string, string> | undefined} rawExportMap
* @property {string=} namespaceExportSymbol
* @property {string} namespaceObjectName
* @property {string | undefined} namespaceObjectName
* @property {boolean} interopNamespaceObjectUsed
* @property {string} interopNamespaceObjectName
* @property {string | undefined} interopNamespaceObjectName
* @property {boolean} interopNamespaceObject2Used
* @property {string} interopNamespaceObject2Name
* @property {string | undefined} interopNamespaceObject2Name
* @property {boolean} interopDefaultAccessUsed
* @property {string} interopDefaultAccessName
* @property {string | undefined} interopDefaultAccessName
*/

@@ -158,2 +175,4 @@

/** @typedef {Set<string>} UsedNames */
const RESERVED_NAMES = new Set(

@@ -199,2 +218,8 @@ [

comparator(a[property], b[property]);
/**
* @param {number} a a
* @param {number} b b
* @returns {0 | 1 | -1} result
*/
const compareNumbers = (a, b) => {

@@ -218,2 +243,6 @@ if (isNaN(a)) {

/**
* @param {Iterable<string>} iterable iterable object
* @returns {string} joined iterable object
*/
const joinIterableWithComma = iterable => {

@@ -252,3 +281,3 @@ // This is more performant than Array.from().join(", ")

* @param {boolean} asCall asCall
* @param {boolean} strictHarmonyModule strictHarmonyModule
* @param {boolean | undefined} strictHarmonyModule strictHarmonyModule
* @param {boolean | undefined} asiSafe asiSafe

@@ -282,3 +311,3 @@ * @param {Set<ExportInfo>} alreadyVisited alreadyVisited

info,
rawName: info.interopNamespaceObject2Name,
rawName: /** @type {string} */ (info.interopNamespaceObject2Name),
ids: exportName,

@@ -291,3 +320,3 @@ exportName

info,
rawName: info.interopNamespaceObjectName,
rawName: /** @type {string} */ (info.interopNamespaceObjectName),
ids: exportName,

@@ -380,3 +409,3 @@ exportName

info,
rawName: info.namespaceObjectName,
rawName: /** @type {string} */ (info.namespaceObjectName),
ids: exportName,

@@ -408,3 +437,3 @@ exportName

info,
rawName: info.namespaceObjectName,
rawName: /** @type {string} */ (info.namespaceObjectName),
ids: exportName,

@@ -461,3 +490,3 @@ exportName

moduleGraph,
refInfo,
/** @type {ModuleInfo} */ (refInfo),
reexport.export

@@ -472,3 +501,4 @@ ? [...reexport.export, ...exportName.slice(1)]

asCall,
info.module.buildMeta.strictHarmonyModule,
/** @type {BuildMeta} */
(info.module.buildMeta).strictHarmonyModule,
asiSafe,

@@ -484,3 +514,3 @@ alreadyVisited

info,
rawName: info.namespaceObjectName,
rawName: /** @type {string} */ (info.namespaceObjectName),
ids: usedName,

@@ -527,4 +557,4 @@ exportName

* @param {boolean} asCall asCall
* @param {boolean} callContext callContext
* @param {boolean} strictHarmonyModule strictHarmonyModule
* @param {boolean | undefined} callContext callContext
* @param {boolean | undefined} strictHarmonyModule strictHarmonyModule
* @param {boolean | undefined} asiSafe asiSafe

@@ -596,2 +626,8 @@ * @returns {string} the final name

/**
* @param {Scope | null} s scope
* @param {UsedNames} nameSet name set
* @param {TODO} scopeSet1 scope set 1
* @param {TODO} scopeSet2 scope set 2
*/
const addScopeSymbols = (s, nameSet, scopeSet1, scopeSet2) => {

@@ -610,2 +646,6 @@ let scope = s;

/**
* @param {Variable} variable variable
* @returns {Reference[]} references
*/
const getAllReferences = variable => {

@@ -626,2 +666,7 @@ let set = variable.references;

/**
* @param {TODO} ast ast
* @param {TODO} node node
* @returns {TODO} result
*/
const getPathInAst = (ast, node) => {

@@ -795,7 +840,10 @@ if (ast === node) {

const { rootModule } = this;
const { moduleArgument, exportsArgument } =
/** @type {BuildInfo} */
(rootModule.buildInfo);
this.buildInfo = {
strict: true,
cacheable: true,
moduleArgument: rootModule.buildInfo.moduleArgument,
exportsArgument: rootModule.buildInfo.exportsArgument,
moduleArgument,
exportsArgument,
fileDependencies: new LazySet(),

@@ -813,3 +861,3 @@ contextDependencies: new LazySet(),

// populate cacheable
if (!m.buildInfo.cacheable) {
if (!(/** @type {BuildInfo} */ (m.buildInfo).cacheable)) {
this.buildInfo.cacheable = false;

@@ -822,3 +870,5 @@ }

!(dep instanceof HarmonyImportDependency) ||
!this._modules.has(compilation.moduleGraph.getModule(dep))
!this._modules.has(
/** @type {Module} */ (compilation.moduleGraph.getModule(dep))
)
)) {

@@ -848,7 +898,10 @@ this.dependencies.push(d);

const { assets, assetsInfo, topLevelDeclarations } =
/** @type {BuildInfo} */ (m.buildInfo);
// populate topLevelDeclarations
if (m.buildInfo.topLevelDeclarations) {
if (topLevelDeclarations) {
const topLevelDeclarations = this.buildInfo.topLevelDeclarations;
if (topLevelDeclarations !== undefined) {
for (const decl of m.buildInfo.topLevelDeclarations) {
for (const decl of topLevelDeclarations) {
topLevelDeclarations.add(decl);

@@ -862,13 +915,13 @@ }

// populate assets
if (m.buildInfo.assets) {
if (assets) {
if (this.buildInfo.assets === undefined) {
this.buildInfo.assets = Object.create(null);
}
Object.assign(this.buildInfo.assets, m.buildInfo.assets);
Object.assign(/** @type {BuildInfo} */ (this.buildInfo).assets, assets);
}
if (m.buildInfo.assetsInfo) {
if (assetsInfo) {
if (this.buildInfo.assetsInfo === undefined) {
this.buildInfo.assetsInfo = new Map();
}
for (const [key, value] of m.buildInfo.assetsInfo) {
for (const [key, value] of assetsInfo) {
this.buildInfo.assetsInfo.set(key, value);

@@ -1084,3 +1137,3 @@ }

const cachedMakePathsRelative = makePathsRelative.bindContextCache(
rootModule.context,
/** @type {string} */ (rootModule.context),
associatedObjectForCache

@@ -1168,3 +1221,3 @@ );

// List of additional names in scope for module references
/** @type {Map<string, { usedNames: Set<string>, alreadyCheckedScopes: Set<TODO> }>} */
/** @type {Map<string, { usedNames: UsedNames, alreadyCheckedScopes: Set<TODO> }>} */
const usedNamesInScopeInfo = new Map();

@@ -1174,3 +1227,3 @@ /**

* @param {string} id export id
* @returns {{ usedNames: Set<string>, alreadyCheckedScopes: Set<TODO> }} info
* @returns {{ usedNames: UsedNames, alreadyCheckedScopes: Set<TODO> }} info
*/

@@ -1205,2 +1258,6 @@ const getUsedNamesInScopeInfo = (module, id) => {

const superClassCache = new WeakMap();
/**
* @param {Scope} scope scope
* @returns {TODO} result
*/
const getSuperClassExpressions = scope => {

@@ -1248,3 +1305,4 @@ const cacheEntry = superClassCache.get(scope);

false,
info.module.buildMeta.strictHarmonyModule,
/** @type {BuildMeta} */
(info.module.buildMeta).strictHarmonyModule,
true

@@ -1260,4 +1318,6 @@ );

if (
expr.range[0] <= reference.identifier.range[0] &&
expr.range[1] >= reference.identifier.range[1]
expr.range[0] <=
/** @type {Range} */ (reference.identifier.range)[0] &&
expr.range[1] >=
/** @type {Range} */ (reference.identifier.range)[1]
) {

@@ -1321,3 +1381,3 @@ for (const variable of expr.variables) {

for (const identifier of allIdentifiers) {
const r = identifier.range;
const r = /** @type {Range} */ (identifier.range);
const path = getPathInAst(info.ast, identifier);

@@ -1360,3 +1420,5 @@ if (path && path.length > 1) {

}
info.namespaceObjectName = namespaceObjectName;
info.namespaceObjectName =
/** @type {string} */
(namespaceObjectName);
topLevelDeclarations.add(namespaceObjectName);

@@ -1378,3 +1440,4 @@ break;

}
if (info.module.buildMeta.exportsType !== "namespace") {
const buildMeta = /** @type {BuildMeta} */ (info.module.buildMeta);
if (buildMeta.exportsType !== "namespace") {
const externalNameInterop = this.findNewName(

@@ -1391,4 +1454,4 @@ "namespaceObject",

if (
info.module.buildMeta.exportsType === "default" &&
info.module.buildMeta.defaultObject !== "redirect"
buildMeta.exportsType === "default" &&
buildMeta.defaultObject !== "redirect"
) {

@@ -1405,6 +1468,3 @@ const externalNameInterop = this.findNewName(

}
if (
info.module.buildMeta.exportsType === "dynamic" ||
!info.module.buildMeta.exportsType
) {
if (buildMeta.exportsType === "dynamic" || !buildMeta.exportsType) {
const externalNameInterop = this.findNewName(

@@ -1443,6 +1503,7 @@ "default",

!match.directImport,
info.module.buildMeta.strictHarmonyModule,
/** @type {BuildMeta} */
(info.module.buildMeta).strictHarmonyModule,
match.asiSafe
);
const r = reference.identifier.range;
const r = /** @type {Range} */ (reference.identifier.range);
const source = info.source;

@@ -1467,3 +1528,5 @@ // range is extended by 2 chars to cover the appended "._"

);
const strictHarmonyModule = rootInfo.module.buildMeta.strictHarmonyModule;
const strictHarmonyModule =
/** @type {BuildMeta} */
(rootInfo.module.buildMeta).strictHarmonyModule;
const exportsInfo = moduleGraph.getExportsInfo(rootInfo.module);

@@ -1498,3 +1561,5 @@ for (const exportInfo of exportsInfo.orderedExports) {

} catch (e) {
e.message += `\nwhile generating the root export '${name}' (used name: '${used}')`;
/** @type {Error} */
(e).message +=
`\nwhile generating the root export '${name}' (used name: '${used}')`;
throw e;

@@ -1569,3 +1634,4 @@ }

undefined,
info.module.buildMeta.strictHarmonyModule,
/** @type {BuildMeta} */
(info.module.buildMeta).strictHarmonyModule,
true

@@ -1741,3 +1807,5 @@ );

});
const source = codeGenResult.sources.get("javascript");
const source = /** @type {Source} */ (
codeGenResult.sources.get("javascript")
);
const data = codeGenResult.data;

@@ -1774,3 +1842,3 @@ const chunkInitFragments = data && data.get("chunkInitFragments");

});
const globalScope = scopeManager.acquire(ast);
const globalScope = /** @type {Scope} */ (scopeManager.acquire(ast));
const moduleScope = globalScope.childScopes[0];

@@ -1786,3 +1854,5 @@ const resultSource = new ReplaceSource(source);

} catch (err) {
err.message += `\nwhile analyzing module ${m.identifier()} for concatenation`;
/** @type {Error} */
(err).message +=
`\nwhile analyzing module ${m.identifier()} for concatenation`;
throw err;

@@ -1855,3 +1925,6 @@ }

}
map.set(item.module, item);
map.set(
/** @type {ModuleInfo} */ (item).module,
/** @type {ModuleInfo} */ (item)
);
return item;

@@ -1871,2 +1944,9 @@ } else {

/**
* @param {string} oldName old name
* @param {UsedNames} usedNamed1 used named 1
* @param {UsedNames} usedNamed2 used named 2
* @param {string} extraInfo extra info
* @returns {string} found new name
*/
findNewName(oldName, usedNamed1, usedNamed2, extraInfo) {

@@ -1937,2 +2017,6 @@ let name = oldName;

/**
* @param {ObjectDeserializerContext} context context
* @returns {ConcatenatedModule} ConcatenatedModule
*/
static deserialize(context) {

@@ -1939,0 +2023,0 @@ const obj = new ConcatenatedModule({

@@ -59,3 +59,3 @@ /*

throw new Error(
"Cannot fullfil chunk condition of " + module.identifier()
"Cannot fulfil chunk condition of " + module.identifier()
);

@@ -62,0 +62,0 @@ }

@@ -12,2 +12,3 @@ /*

/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../ModuleGraph")} ModuleGraph */

@@ -299,3 +300,5 @@ /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */

if (usedByExports !== true && usedByExports !== undefined) {
const selfModule = moduleGraph.getParentModule(dependency);
const selfModule =
/** @type {Module} */
(moduleGraph.getParentModule(dependency));
const exportsInfo = moduleGraph.getExportsInfo(selfModule);

@@ -325,3 +328,5 @@ let used = false;

if (usedByExports !== true && usedByExports !== undefined) {
const selfModule = moduleGraph.getParentModule(dependency);
const selfModule =
/** @type {Module} */
(moduleGraph.getParentModule(dependency));
const exportsInfo = moduleGraph.getExportsInfo(selfModule);

@@ -328,0 +333,0 @@ return (connections, runtime) => {

@@ -22,4 +22,6 @@ /*

/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("../dependencies/HarmonyImportSpecifierDependency")} HarmonyImportSpecifierDependency */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("./InnerGraph").InnerGraph} InnerGraph */

@@ -127,3 +129,6 @@ /** @typedef {import("./InnerGraph").TopLevelSymbol} TopLevelSymbol */

statement.type === "ClassDeclaration" &&
parser.isPure(statement, statement.range[0])
parser.isPure(
statement,
/** @type {Range} */ (statement.range)[0]
)
) {

@@ -142,6 +147,8 @@ const name = statement.id ? statement.id.name : "*default*";

decl.type === "ClassDeclaration") &&
parser.isPure(decl, decl.range[0])
parser.isPure(decl, /** @type {Range} */ (decl.range)[0])
) {
classWithTopLevelSymbol.set(decl, fn);
} else if (parser.isPure(decl, statement.range[0])) {
} else if (
parser.isPure(decl, /** @type {Range} */ (statement.range)[0])
) {
statementWithTopLevelSymbol.set(statement, fn);

@@ -170,7 +177,15 @@ if (

decl.init.type === "ClassExpression" &&
parser.isPure(decl.init, decl.id.range[1])
parser.isPure(
decl.init,
/** @type {Range} */ (decl.id.range)[1]
)
) {
const fn = InnerGraph.tagTopLevelSymbol(parser, name);
classWithTopLevelSymbol.set(decl.init, fn);
} else if (parser.isPure(decl.init, decl.id.range[1])) {
} else if (
parser.isPure(
decl.init,
/** @type {Range} */ (decl.id.range)[1]
)
) {
const fn = InnerGraph.tagTopLevelSymbol(parser, name);

@@ -221,5 +236,7 @@ declWithTopLevelSymbol.set(decl, fn);

const dep = new PureExpressionDependency(
purePart.range
/** @type {Range} */ (purePart.range)
);
dep.loc = statement.loc;
dep.loc =
/** @type {DependencyLocation} */
(statement.loc);
dep.usedByExports = usedByExports;

@@ -246,3 +263,5 @@ parser.state.module.addDependency(dep);

expr,
statement.id ? statement.id.range[1] : statement.range[0]
statement.id
? /** @type {Range} */ (statement.id.range)[1]
: /** @type {Range} */ (statement.range)[0]
)

@@ -281,3 +300,5 @@ ) {

expression,
element.key ? element.key.range[1] : element.range[0]
element.key
? /** @type {Range} */ (element.key.range)[1]
: /** @type {Range} */ (element.range)[0]
)

@@ -294,5 +315,7 @@ ) {

const dep = new PureExpressionDependency(
expression.range
/** @type {Range} */ (expression.range)
);
dep.loc = expression.loc;
dep.loc =
/** @type {DependencyLocation} */
(expression.loc);
dep.usedByExports = usedByExports;

@@ -332,5 +355,5 @@ parser.state.module.addDependency(dep);

const dep = new PureExpressionDependency(
decl.init.range
/** @type {Range} */ (decl.init.range)
);
dep.loc = decl.loc;
dep.loc = /** @type {DependencyLocation} */ (decl.loc);
dep.usedByExports = usedByExports;

@@ -337,0 +360,0 @@ parser.state.module.addDependency(dep);

@@ -26,2 +26,3 @@ /*

/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").BuildInfo} BuildInfo */
/** @typedef {import("../RequestShortener")} RequestShortener */

@@ -53,2 +54,5 @@ /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */

class ModuleConcatenationPlugin {
/**
* @param {TODO} options options
*/
constructor(options) {

@@ -176,3 +180,3 @@ if (typeof options !== "object") options = {};

// Must be in strict mode
if (!module.buildInfo.strict) {
if (!(/** @type {BuildInfo} */ (module.buildInfo).strict)) {
setBailoutReason(module, `Module is not in strict mode`);

@@ -248,3 +252,6 @@ continue;

relevantModules.sort((a, b) => {
return moduleGraph.getDepth(a) - moduleGraph.getDepth(b);
return (
/** @type {number} */ (moduleGraph.getDepth(a)) -
/** @type {number} */ (moduleGraph.getDepth(b))
);
});

@@ -934,2 +941,5 @@ logger.timeEnd("sort relevant modules");

/**
* @param {number} snapshot snapshot
*/
rollback(snapshot) {

@@ -936,0 +946,0 @@ const modules = this.modules;

@@ -80,2 +80,3 @@ /*

const maskByModule = new WeakMap();
/** @type {Module[]} */
const ordinalModules = [];

@@ -82,0 +83,0 @@

@@ -13,2 +13,5 @@ /*

class RuntimeChunkPlugin {
/**
* @param {{ name?: (entrypoint: { name: string }) => string }} options options
*/
constructor(options) {

@@ -41,3 +44,5 @@ this.options = {

// Determine runtime chunk name
let name = this.options.name;
let name =
/** @type {string | ((entrypoint: { name: string }) => string)} */
(this.options.name);
if (typeof name === "function") {

@@ -44,0 +49,0 @@ name = name({ name: entryName });

@@ -23,4 +23,7 @@ /*

/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */

@@ -40,3 +43,5 @@ /**

/** @type {WeakMap<any, Map<string, RegExp>>} */
/** @typedef {Map<string, RegExp>} CacheItem */
/** @type {WeakMap<any, CacheItem>} */
const globToRegexpCache = new WeakMap();

@@ -101,3 +106,3 @@

sideEffects,
cache
/** @type {CacheItem} */ (cache)
);

@@ -138,3 +143,6 @@ module.factoryMeta.sideEffectFree = !hasSideEffects;

if (
!parser.isPure(statement.expression, statement.range[0])
!parser.isPure(
statement.expression,
/** @type {Range} */ (statement.range)[0]
)
) {

@@ -147,3 +155,8 @@ sideEffectsStatement = statement;

case "DoWhileStatement":
if (!parser.isPure(statement.test, statement.range[0])) {
if (
!parser.isPure(
statement.test,
/** @type {Range} */ (statement.range)[0]
)
) {
sideEffectsStatement = statement;

@@ -155,8 +168,11 @@ }

if (
!parser.isPure(statement.init, statement.range[0]) ||
!parser.isPure(
statement.init,
/** @type {Range} */ (statement.range)[0]
) ||
!parser.isPure(
statement.test,
statement.init
? statement.init.range[1]
: statement.range[0]
? /** @type {Range} */ (statement.init.range)[1]
: /** @type {Range} */ (statement.range)[0]
) ||

@@ -166,6 +182,6 @@ !parser.isPure(

statement.test
? statement.test.range[1]
? /** @type {Range} */ (statement.test.range)[1]
: statement.init
? statement.init.range[1]
: statement.range[0]
? /** @type {Range} */ (statement.init.range)[1]
: /** @type {Range} */ (statement.range)[0]
)

@@ -179,3 +195,6 @@ ) {

if (
!parser.isPure(statement.discriminant, statement.range[0])
!parser.isPure(
statement.discriminant,
/** @type {Range} */ (statement.range)[0]
)
) {

@@ -189,3 +208,8 @@ sideEffectsStatement = statement;

case "FunctionDeclaration":
if (!parser.isPure(statement, statement.range[0])) {
if (
!parser.isPure(
statement,
/** @type {Range} */ (statement.range)[0]
)
) {
sideEffectsStatement = statement;

@@ -197,3 +221,6 @@ }

if (
!parser.isPure(statement.declaration, statement.range[0])
!parser.isPure(
statement.declaration,
/** @type {Range} */ (statement.range)[0]
)
) {

@@ -221,3 +248,4 @@ sideEffectsStatement = statement;

if (sideEffectsStatement === undefined) {
parser.state.module.buildMeta.sideEffectFree = true;
/** @type {BuildMeta} */
(parser.state.module.buildMeta).sideEffectFree = true;
} else {

@@ -230,3 +258,3 @@ const { loc, type } = sideEffectsStatement;

`Statement (${type}) with side effects in source code at ${formatLocation(
loc
/** @type {DependencyLocation} */ (loc)
)}`

@@ -261,2 +289,5 @@ );

/**
* @param {Module} module module
*/
const optimizeIncomingConnections = module => {

@@ -263,0 +294,0 @@ if (optimizedModules.has(module)) return;

@@ -163,3 +163,3 @@ /*

* @property {Set<Chunk>} chunks
* @property {Set<Chunk>} reuseableChunks
* @property {Set<Chunk>} reusableChunks
* @property {Set<bigint | Chunk>} chunksKeys

@@ -1181,3 +1181,3 @@ */

chunks: new Set(),
reuseableChunks: new Set(),
reusableChunks: new Set(),
chunksKeys: new Set()

@@ -1184,0 +1184,0 @@ })

@@ -16,2 +16,3 @@ /*

/** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../Compilation").Asset} Asset */
/** @typedef {import("../Compiler")} Compiler */

@@ -36,2 +37,8 @@ /** @typedef {import("../Entrypoint")} Entrypoint */

/**
* @param {Asset["name"]} name the name
* @param {Asset["source"]} source the source
* @param {Asset["info"]} info the info
* @returns {boolean} result
*/
const excludeSourceMap = (name, source, info) => !info.development;

@@ -109,2 +116,6 @@

/**
* @param {Asset["name"]} name the name
* @returns {boolean | undefined} result
*/
const fileFilter = name => {

@@ -111,0 +122,0 @@ const asset = compilation.getAsset(name);

@@ -62,3 +62,5 @@ /*

Object.keys(definitions).forEach(name => {
const request = [].concat(definitions[name]);
const request =
/** @type {string[]} */
([]).concat(definitions[name]);
const splittedName = name.split(".");

@@ -65,0 +67,0 @@ if (splittedName.length > 0) {

@@ -22,2 +22,3 @@ /*

/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
/** @typedef {import("./Module").SourceTypes} SourceTypes */

@@ -40,3 +41,3 @@ /** @typedef {import("./RequestShortener")} RequestShortener */

* @param {string=} readableIdentifier readable identifier
* @param {ReadonlySet<string>=} runtimeRequirements runtime requirements needed for the source code
* @param {ReadOnlyRuntimeRequirements=} runtimeRequirements runtime requirements needed for the source code
*/

@@ -43,0 +44,0 @@ constructor(source, identifier, readableIdentifier, runtimeRequirements) {

@@ -64,3 +64,5 @@ /*

return removeOperations(
resolveByProperty(options, "byDependency", dependencyType)
resolveByProperty(options, "byDependency", dependencyType),
// Keep the `unsafeCache` because it can be a `Proxy`
["unsafeCache"]
);

@@ -67,0 +69,0 @@ };

@@ -12,2 +12,6 @@ /*

class ObjectMatcherRulePlugin {
/**
* @param {string} ruleProperty the rule property
* @param {string=} dataProperty the data property
*/
constructor(ruleProperty, dataProperty) {

@@ -14,0 +18,0 @@ this.ruleProperty = ruleProperty;

@@ -12,6 +12,7 @@ /*

/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
class EnsureChunkRuntimeModule extends RuntimeModule {
/**
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
*/

@@ -18,0 +19,0 @@ constructor(runtimeRequirements) {

@@ -12,6 +12,7 @@ /*

/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
class GetTrustedTypesPolicyRuntimeModule extends HelperRuntimeModule {
/**
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
*/

@@ -18,0 +19,0 @@ constructor(runtimeRequirements) {

@@ -50,3 +50,3 @@ /*

this.dependentHash = false;
/** @type {string | undefined} */
/** @type {string | undefined | null} */
this._cachedGeneratedCode = undefined;

@@ -117,5 +117,5 @@ }

// ready at this point. We will cache it later instead.
hash.update(this.generate());
hash.update(/** @type {string} */ (this.generate()));
} else {
hash.update(this.getGeneratedCode());
hash.update(/** @type {string} */ (this.getGeneratedCode()));
}

@@ -184,3 +184,3 @@ } catch (err) {

if (this._cachedGeneratedCode) {
return /** @type {string | null} */ (this._cachedGeneratedCode);
return this._cachedGeneratedCode;
}

@@ -187,0 +187,0 @@ return (this._cachedGeneratedCode = this.generate());

@@ -63,2 +63,3 @@ /*

RuntimeGlobals.relativeUrl,
// TODO webpack 6 - rename to nonce, because we use it for CSS too
RuntimeGlobals.scriptNonce,

@@ -65,0 +66,0 @@ RuntimeGlobals.uncaughtErrorHandler,

@@ -16,9 +16,14 @@ /*

/** @typedef {import("../declarations/WebpackOptions").Environment} Environment */
/** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputOptions */
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
/** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./ChunkGraph")} ChunkGraph */
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
/** @typedef {import("./CodeGenerationResults").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("./Compilation")} Compilation */
/** @typedef {import("./Dependency")} Dependency */
/** @typedef {import("./Module")} Module */
/** @typedef {import("./Module").BuildMeta} BuildMeta */
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
/** @typedef {import("./ModuleGraph")} ModuleGraph */

@@ -56,4 +61,4 @@ /** @typedef {import("./RequestShortener")} RequestShortener */

/**
* @param {string|undefined} definition global object definition
* @returns {string} save to use global object
* @param {string | undefined} definition global object definition
* @returns {string | undefined} save to use global object
*/

@@ -87,4 +92,9 @@ function getGlobalObject(definition) {

this.requestShortener = requestShortener;
this.globalObject = getGlobalObject(outputOptions.globalObject);
this.contentHashReplacement = "X".repeat(outputOptions.hashDigestLength);
this.globalObject =
/** @type {string} */
(getGlobalObject(outputOptions.globalObject));
this.contentHashReplacement = "X".repeat(
/** @type {NonNullable<OutputOptions["hashDigestLength"]>} */
(outputOptions.hashDigestLength)
);
}

@@ -101,41 +111,53 @@

supportsConst() {
return this.outputOptions.environment.const;
return /** @type {Environment} */ (this.outputOptions.environment).const;
}
supportsArrowFunction() {
return this.outputOptions.environment.arrowFunction;
return /** @type {Environment} */ (this.outputOptions.environment)
.arrowFunction;
}
supportsAsyncFunction() {
return this.outputOptions.environment.asyncFunction;
return /** @type {Environment} */ (this.outputOptions.environment)
.asyncFunction;
}
supportsOptionalChaining() {
return this.outputOptions.environment.optionalChaining;
return /** @type {Environment} */ (this.outputOptions.environment)
.optionalChaining;
}
supportsForOf() {
return this.outputOptions.environment.forOf;
return /** @type {Environment} */ (this.outputOptions.environment).forOf;
}
supportsDestructuring() {
return this.outputOptions.environment.destructuring;
return /** @type {Environment} */ (this.outputOptions.environment)
.destructuring;
}
supportsBigIntLiteral() {
return this.outputOptions.environment.bigIntLiteral;
return /** @type {Environment} */ (this.outputOptions.environment)
.bigIntLiteral;
}
supportsDynamicImport() {
return this.outputOptions.environment.dynamicImport;
return /** @type {Environment} */ (this.outputOptions.environment)
.dynamicImport;
}
supportsEcmaScriptModuleSyntax() {
return this.outputOptions.environment.module;
return /** @type {Environment} */ (this.outputOptions.environment).module;
}
supportTemplateLiteral() {
return this.outputOptions.environment.templateLiteral;
return /** @type {Environment} */ (this.outputOptions.environment)
.templateLiteral;
}
/**
* @param {string} returnValue return value
* @param {string} args arguments
* @returns {string} returning function
*/
returningFunction(returnValue, args = "") {

@@ -147,2 +169,7 @@ return this.supportsArrowFunction()

/**
* @param {string} args arguments
* @param {string | string[]} body body
* @returns {string} basic function
*/
basicFunction(args, body) {

@@ -219,2 +246,7 @@ return this.supportsArrowFunction()

/**
* @param {string} expression expression
* @param {string} args arguments
* @returns {string} expression function code
*/
expressionFunction(expression, args = "") {

@@ -226,2 +258,5 @@ return this.supportsArrowFunction()

/**
* @returns {string} empty function code
*/
emptyFunction() {

@@ -231,2 +266,7 @@ return this.supportsArrowFunction() ? "x => {}" : "function() {}";

/**
* @param {string[]} items items
* @param {string} value value
* @returns {string} destructure array code
*/
destructureArray(items, value) {

@@ -240,2 +280,7 @@ return this.supportsDestructuring()

/**
* @param {string[]} items items
* @param {string} value value
* @returns {string} destructure object code
*/
destructureObject(items, value) {

@@ -249,2 +294,7 @@ return this.supportsDestructuring()

/**
* @param {string} args arguments
* @param {string} body body
* @returns {string} IIFE code
*/
iife(args, body) {

@@ -254,2 +304,8 @@ return `(${this.basicFunction(args, body)})()`;

/**
* @param {string} variable variable
* @param {string} array array
* @param {string | string[]} body body
* @returns {string} for each code
*/
forEach(variable, array, body) {

@@ -350,3 +406,3 @@ return this.supportsForOf()

* @param {Module} options.module the module
* @param {string} options.request the request that should be printed as comment
* @param {string=} options.request the request that should be printed as comment
* @param {string=} options.idExpr expression to use as id expression

@@ -388,3 +444,3 @@ * @param {"expression" | "promise" | "statements"} options.type which kind of code should be returned

* @param {ChunkGraph} options.chunkGraph the chunk graph
* @param {string} options.request the request that should be printed as comment
* @param {string=} options.request the request that should be printed as comment
* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)

@@ -418,5 +474,5 @@ * @returns {string} the expression

* @param {ChunkGraph} options.chunkGraph the chunk graph
* @param {string} options.request the request that should be printed as comment
* @param {string=} options.request the request that should be printed as comment
* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @returns {string} the expression

@@ -464,3 +520,3 @@ */

* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @returns {string} the expression

@@ -485,3 +541,3 @@ */

* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @returns {string} the expression

@@ -557,3 +613,3 @@ */

* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @returns {string} the promise expression

@@ -704,3 +760,3 @@ */

* @param {RuntimeSpec | boolean=} options.runtimeCondition only execute the statement in some runtimes
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @returns {string} expression

@@ -719,3 +775,5 @@ */

forEachRuntime(runtimeCondition, runtime =>
positiveRuntimeIds.add(`${chunkGraph.getRuntimeId(runtime)}`)
positiveRuntimeIds.add(
`${chunkGraph.getRuntimeId(/** @type {string} */ (runtime))}`
)
);

@@ -725,3 +783,5 @@ /** @type {Set<string>} */

forEachRuntime(subtractRuntime(runtime, runtimeCondition), runtime =>
negativeRuntimeIds.add(`${chunkGraph.getRuntimeId(runtime)}`)
negativeRuntimeIds.add(
`${chunkGraph.getRuntimeId(/** @type {string} */ (runtime))}`
)
);

@@ -745,3 +805,3 @@ runtimeRequirements.add(RuntimeGlobals.runtimeId);

* @param {boolean=} options.weak true, if this is a weak dependency
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @returns {[string, string]} the import statement and the compat statement

@@ -798,3 +858,4 @@ */

chunkGraph.moduleGraph,
originModule.buildMeta.strictHarmonyModule
/** @type {BuildMeta} */
(originModule.buildMeta).strictHarmonyModule
);

@@ -828,3 +889,3 @@ runtimeRequirements.add(RuntimeGlobals.require);

* @param {RuntimeSpec} options.runtime runtime for which this code will be generated
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @returns {string} expression

@@ -857,3 +918,4 @@ */

moduleGraph,
originModule.buildMeta.strictHarmonyModule
/** @type {BuildMeta} */
(originModule.buildMeta).strictHarmonyModule
);

@@ -940,6 +1002,6 @@

* @param {Object} options options
* @param {AsyncDependenciesBlock} options.block the async block
* @param {AsyncDependenciesBlock | undefined} options.block the async block
* @param {string} options.message the message
* @param {ChunkGraph} options.chunkGraph the chunk graph
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @returns {string} expression

@@ -990,2 +1052,6 @@ */

/**
* @param {Chunk} chunk chunk
* @returns {string} require chunk id code
*/
const requireChunkId = chunk =>

@@ -1007,3 +1073,3 @@ `${RuntimeGlobals.ensureChunk}(${JSON.stringify(chunk.id)}${

* @param {ChunkGraph} options.chunkGraph the chunk graph
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {string=} options.request request string used originally

@@ -1040,3 +1106,3 @@ * @returns {string} expression

* @param {ChunkGraph} options.chunkGraph the chunk graph
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {string=} options.request request string used originally

@@ -1061,3 +1127,3 @@ * @returns {string} expression

* @param {string} options.exportsArgument the name of the exports object
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @returns {string} statement

@@ -1084,3 +1150,5 @@ */

const codeGen = codeGenerationResults.get(module, runtime);
const { data } = codeGen;
const data = /** @type {NonNullable<CodeGenerationResult["data"]>} */ (
codeGen.data
);
const url = data.get("url");

@@ -1087,0 +1155,0 @@ if (url) return url.toString();

@@ -579,2 +579,3 @@ /*

const buf = [];
/** @type {import("zlib").Zlib & import("stream").Transform | undefined} */
let decompression;

@@ -581,0 +582,0 @@ if (file.endsWith(".gz")) {

@@ -49,2 +49,4 @@ /*

* @property {function(any): void} write
* @property {(function(any): void)=} writeLazy
* @property {(function(any, object=): (() => Promise<any> | any))=} writeSeparate
* @property {function(any): void} setCircularReference

@@ -51,0 +53,0 @@ */

@@ -7,3 +7,12 @@ /*

/**
* @template T, K
* @typedef {import("./SerializerMiddleware")<T, K>} SerializerMiddleware
*/
class Serializer {
/**
* @param {SerializerMiddleware<any, any>[]} middlewares serializer middlewares
* @param {TODO=} context context
*/
constructor(middlewares, context) {

@@ -15,2 +24,7 @@ this.serializeMiddlewares = middlewares.slice();

/**
* @param {any} obj object
* @param {TODO} context content
* @returns {Promise<any>} result
*/
serialize(obj, context) {

@@ -33,2 +47,7 @@ const ctx = { ...context, ...this.context };

/**
* @param {any} value value
* @param {TODO} context context
* @returns {Promise<any>} result
*/
deserialize(value, context) {

@@ -35,0 +54,0 @@ const ctx = { ...context, ...this.context };

@@ -45,3 +45,3 @@ /*

* @property {SemVerRange | false | undefined} requiredVersion version requirement
* @property {string} packageName package name to determine required version automatically
* @property {string=} packageName package name to determine required version automatically
* @property {boolean} strictVersion don't use shared version even if version isn't valid

@@ -48,0 +48,0 @@ * @property {boolean} singleton use single global version

@@ -120,3 +120,8 @@ /*

let unresolvedConsumes, resolvedConsumes, prefixedConsumes;
/** @type {Map<string, ConsumeOptions>} */
let unresolvedConsumes;
/** @type {Map<string, ConsumeOptions>} */
let resolvedConsumes;
/** @type {Map<string, ConsumeOptions>} */
let prefixedConsumes;
const promise = resolveMatchedConfigs(compilation, this._consumes).then(

@@ -142,2 +147,5 @@ ({ resolved, unresolved, prefixed }) => {

const createConsumeSharedModule = (context, request, config) => {
/**
* @param {string} details details
*/
const requiredVersionWarning = details => {

@@ -298,5 +306,11 @@ const error = new WebpackError(

}
const options = resolvedConsumes.get(resource);
const options = resolvedConsumes.get(
/** @type {string} */ (resource)
);
if (options !== undefined) {
return createConsumeSharedModule(context, resource, options);
return createConsumeSharedModule(
context,
/** @type {string} */ (resource),
options
);
}

@@ -303,0 +317,0 @@ return Promise.resolve();

@@ -20,5 +20,7 @@ /*

/** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../Chunk").ChunkId} ChunkId */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
/** @typedef {import("./ConsumeSharedModule")} ConsumeSharedModule */

@@ -28,3 +30,3 @@

/**
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
*/

@@ -43,2 +45,3 @@ constructor(runtimeRequirements) {

const { runtimeTemplate, codeGenerationResults } = compilation;
/** @type {Record<ChunkId, (string | number)[]>} */
const chunkToModuleMapping = {};

@@ -76,3 +79,7 @@ /** @type {Map<string | number, Source>} */

if (!modules) continue;
addModules(modules, chunk, (chunkToModuleMapping[chunk.id] = []));
addModules(
modules,
chunk,
(chunkToModuleMapping[/** @type {ChunkId} */ (chunk.id)] = [])
);
}

@@ -79,0 +86,0 @@ for (const chunk of /** @type {Chunk} */ (

@@ -18,2 +18,3 @@ /*

/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../NormalModuleFactory").NormalModuleCreateData} NormalModuleCreateData */

@@ -116,2 +117,8 @@ const validate = createSchemaValidation(

compilationData.set(compilation, resolvedProvideMap);
/**
* @param {string} key key
* @param {ProvideOptions} config config
* @param {NormalModuleCreateData["resource"]} resource resource
* @param {NormalModuleCreateData["resourceResolveData"]} resourceResolveData resource resolve data
*/
const provideSharedModule = (

@@ -156,3 +163,3 @@ key,

(module, { resource, resourceResolveData }, resolveData) => {
if (resolvedProvideMap.has(resource)) {
if (resolvedProvideMap.has(/** @type {string} */ (resource))) {
return module;

@@ -167,3 +174,3 @@ }

config,
resource,
/** @type {string} */ (resource),
resourceResolveData

@@ -178,3 +185,3 @@ );

provideSharedModule(
resource,
/** @type {string} */ (resource),
{

@@ -184,3 +191,3 @@ ...config,

},
resource,
/** @type {string} */ (resource),
resourceResolveData

@@ -218,3 +225,3 @@ );

if (err) return reject(err);
resolve();
resolve(null);
}

@@ -221,0 +228,0 @@ );

@@ -67,6 +67,6 @@ /*

);
return resolve();
return resolve(null);
}
resolved.set(/** @type {string} */ (result), config);
resolve();
resolve(null);
}

@@ -73,0 +73,0 @@ );

@@ -11,2 +11,4 @@ /*

/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
/** @typedef {import("../util/fs").JsonObject} JsonObject */
/** @typedef {import("../util/fs").JsonPrimitive} JsonPrimitive */

@@ -377,5 +379,5 @@ // Extreme shorthand only for github. eg: foo/bar

*
* @param {object} data description file data i.e.: package.json
* @param {JsonObject} data description file data i.e.: package.json
* @param {string} packageName name of the dependency
* @returns {string} normalized version
* @returns {string | undefined} normalized version
*/

@@ -391,8 +393,13 @@ const getRequiredVersionFromDescriptionFile = (data, packageName) => {

for (const dependencyType of dependencyTypes) {
const dependency = /** @type {JsonObject} */ (data[dependencyType]);
if (
data[dependencyType] &&
typeof data[dependencyType] === "object" &&
packageName in data[dependencyType]
dependency &&
typeof dependency === "object" &&
packageName in dependency
) {
return normalizeVersion(data[dependencyType][packageName]);
return normalizeVersion(
/** @type {Exclude<JsonPrimitive, null | boolean| number>} */ (
dependency[packageName]
)
);
}

@@ -399,0 +406,0 @@ }

@@ -32,2 +32,3 @@ /*

/** @typedef {import("./util/Hash")} Hash */
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */

@@ -169,3 +170,5 @@ const validate = createSchemaValidation(

apply(compiler) {
const outputFs = compiler.outputFileSystem;
const outputFs = /** @type {OutputFileSystem} */ (
compiler.outputFileSystem
);
const sourceMapFilename = this.sourceMapFilename;

@@ -172,0 +175,0 @@ const sourceMappingURLComment = this.sourceMappingURLComment;

@@ -10,2 +10,3 @@ /*

/** @typedef {import("./Compilation")} Compilation */
/** @typedef {import("./Compilation").NormalizedStatsOptions} NormalizedStatsOptions */
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */

@@ -62,3 +63,5 @@

const statsFactory = this.compilation.createStatsFactory(options);
const statsFactory = this.compilation.createStatsFactory(
/** @type {NormalizedStatsOptions} */ (options)
);

@@ -79,4 +82,8 @@ return statsFactory.create("compilation", this.compilation, {

const statsFactory = this.compilation.createStatsFactory(options);
const statsPrinter = this.compilation.createStatsPrinter(options);
const statsFactory = this.compilation.createStatsFactory(
/** @type {NormalizedStatsOptions} */ (options)
);
const statsPrinter = this.compilation.createStatsPrinter(
/** @type {NormalizedStatsOptions} */ (options)
);

@@ -83,0 +90,0 @@ const data = statsFactory.create("compilation", this.compilation, {

@@ -15,2 +15,3 @@ /*

/** @typedef {import("./ChunkGraph")} ChunkGraph */
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */

@@ -22,2 +23,6 @@ /** @typedef {import("./Compilation").PathData} PathData */

/**
* @param {string | number} id id
* @returns {string | number} result
*/
const prepareId = id => {

@@ -29,3 +34,5 @@ if (typeof id !== "string") return id;

return `" + (${match[1]} + "").replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_") + "`;
return `" + (${
/** @type {string[]} */ (match)[1]
} + "").replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_") + "`;
}

@@ -64,3 +71,11 @@

/** @typedef {(match: string, arg?: string, input?: string) => string} Replacer */
/**
* @param {string | number | null | undefined | (() => string | number | null | undefined)} value value
* @param {boolean=} allowEmpty allow empty
* @returns {Replacer} replacer
*/
const replacer = (value, allowEmpty) => {
/** @type {Replacer} */
const fn = (match, arg, input) => {

@@ -88,2 +103,8 @@ if (typeof value === "function") {

const deprecatedFunction = (() => () => {})();
/**
* @param {Function} fn function
* @param {string} message message
* @param {string} code code
* @returns {function(...any[]): void} function with deprecation output
*/
const deprecated = (fn, message, code) => {

@@ -235,3 +256,3 @@ let d = deprecationCache.get(message);

("contentHashWithLength" in chunk && chunk.contentHashWithLength
? chunk.contentHashWithLength[contentHashType]
? chunk.contentHashWithLength[/** @type {string} */ (contentHashType)]
: undefined),

@@ -264,3 +285,5 @@ assetInfo,

prepareId(
module instanceof Module ? chunkGraph.getModuleId(module) : module.id
module instanceof Module
? /** @type {ChunkGraph} */ (chunkGraph).getModuleId(module)
: module.id
)

@@ -271,3 +294,6 @@ );

module instanceof Module
? chunkGraph.getRenderedModuleHash(module, data.runtime)
? /** @type {ChunkGraph} */ (chunkGraph).getRenderedModuleHash(
module,
data.runtime
)
: module.hash

@@ -280,3 +306,3 @@ ),

const contentHashReplacer = hashLength(
replacer(data.contentHash),
replacer(/** @type {string} */ (data.contentHash)),
undefined,

@@ -312,3 +338,3 @@ assetInfo,

"runtime",
replacer(() => prepareId(data.runtime))
replacer(() => prepareId(/** @type {string} */ (data.runtime)))
);

@@ -315,0 +341,0 @@ } else {

@@ -41,7 +41,7 @@ /*

}
const prevMerge = innerCache.get(second);
const prevMerge = /** @type {T & O} */ (innerCache.get(second));
if (prevMerge !== undefined) return prevMerge;
const newMerge = _cleverMerge(first, second, true);
innerCache.set(second, newMerge);
return newMerge;
return /** @type {T & O} */ (newMerge);
};

@@ -73,3 +73,3 @@

if (result) return result;
if (result) return /** @type {T} */ (result);

@@ -82,3 +82,3 @@ result = {

return result;
return /** @type {T} */ (result);
};

@@ -263,3 +263,3 @@

return _cleverMerge(first, second, false);
return /** @type {T & O} */ (_cleverMerge(first, second, false));
};

@@ -505,11 +505,19 @@

/**
* @template T
* @template {object} T
* @param {T} obj the object
* @param {(keyof T)[]=} keysToKeepOriginalValue keys to keep original value
* @returns {T} the object without operations like "..." or DELETE
*/
const removeOperations = obj => {
const removeOperations = (obj, keysToKeepOriginalValue = []) => {
const newObj = /** @type {T} */ ({});
for (const key of Object.keys(obj)) {
const value = obj[key];
const value = obj[/** @type {keyof T} */ (key)];
const type = getValueType(value);
if (
type === VALUE_TYPE_OBJECT &&
keysToKeepOriginalValue.includes(/** @type {keyof T} */ (key))
) {
newObj[/** @type {keyof T} */ (key)] = value;
continue;
}
switch (type) {

@@ -520,9 +528,14 @@ case VALUE_TYPE_UNDEFINED:

case VALUE_TYPE_OBJECT:
newObj[key] = removeOperations(value);
newObj[key] = removeOperations(
/** @type {TODO} */ (value),
keysToKeepOriginalValue
);
break;
case VALUE_TYPE_ARRAY_EXTEND:
newObj[key] = value.filter(i => i !== "...");
newObj[key] =
/** @type {any[]} */
(value).filter(i => i !== "...");
break;
default:
newObj[key] = value;
newObj[/** @type {keyof T} */ (key)] = value;
break;

@@ -529,0 +542,0 @@ }

@@ -11,2 +11,3 @@ /*

/** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../Chunk").ChunkId} ChunkId */
/** @typedef {import("../ChunkGraph")} ChunkGraph */

@@ -50,3 +51,6 @@ /** @typedef {import("../ChunkGroup")} ChunkGroup */

exports.compareChunksById = (a, b) => {
return compareIds(a.id, b.id);
return compareIds(
/** @type {ChunkId} */ (a.id),
/** @type {ChunkId} */ (b.id)
);
};

@@ -171,4 +175,4 @@

const cmp = compareNumbers(
moduleGraph.getPostOrderIndex(a),
moduleGraph.getPostOrderIndex(b)
/** @type {number} */ (moduleGraph.getPostOrderIndex(a)),
/** @type {number} */ (moduleGraph.getPostOrderIndex(b))
);

@@ -192,4 +196,4 @@ if (cmp !== 0) return cmp;

const cmp = compareNumbers(
moduleGraph.getPreOrderIndex(a),
moduleGraph.getPreOrderIndex(b)
/** @type {number} */ (moduleGraph.getPreOrderIndex(a)),
/** @type {number} */ (moduleGraph.getPreOrderIndex(b))
);

@@ -268,3 +272,5 @@ if (cmp !== 0) return cmp;

const compareChunkGroupsByIndex = (a, b) => {
return a.index < b.index ? -1 : 1;
return /** @type {number} */ (a.index) < /** @type {number} */ (b.index)
? -1
: 1;
};

@@ -281,3 +287,3 @@

constructor() {
/** @private @type {WeakMap<any, WeakMap<any, T>>} */
/** @private @type {WeakMap<any, WeakMap<any, T | undefined>>} */
this._map = new WeakMap();

@@ -349,3 +355,6 @@ }

/** @template A, B @typedef {(input: A) => B} Selector */
/**
* @template A, B
* @typedef {(input: A) => B | undefined | null} Selector
*/

@@ -441,3 +450,7 @@ /** @type {TwoKeyWeakMap<Selector<any, any>, Comparator<any>, Comparator<any>>}} */

}
return (a, b) => compareNumbers(map.get(a), map.get(b));
return (a, b) =>
compareNumbers(
/** @type {number} */ (map.get(a)),
/** @type {number} */ (map.get(b))
);
};

@@ -453,3 +466,6 @@

return concatComparators(
compareSelect(chunk => chunk.name, compareIds),
compareSelect(
chunk => /** @type {string|number} */ (chunk.name),
compareIds
),
compareSelect(chunk => chunk.runtime, compareRuntime),

@@ -487,4 +503,6 @@ compareSelect(

if (ap.line > bp.line) return 1;
if (ap.column < bp.column) return -1;
if (ap.column > bp.column) return 1;
if (/** @type {number} */ (ap.column) < /** @type {number} */ (bp.column))
return -1;
if (/** @type {number} */ (ap.column) > /** @type {number} */ (bp.column))
return 1;
} else return -1;

@@ -500,4 +518,6 @@ } else if ("start" in b) return 1;

if ("index" in b) {
if (a.index < b.index) return -1;
if (a.index > b.index) return 1;
if (/** @type {number} */ (a.index) < /** @type {number} */ (b.index))
return -1;
if (/** @type {number} */ (a.index) > /** @type {number} */ (b.index))
return 1;
} else return -1;

@@ -504,0 +524,0 @@ } else if ("index" in b) return 1;

@@ -14,3 +14,4 @@ /*

/**
* @typedef {Object} IStats
* @template T
* @typedef {Object} IStatsBase
* @property {() => boolean} isFile

@@ -23,16 +24,16 @@ * @property {() => boolean} isDirectory

* @property {() => boolean} isSocket
* @property {number | bigint} dev
* @property {number | bigint} ino
* @property {number | bigint} mode
* @property {number | bigint} nlink
* @property {number | bigint} uid
* @property {number | bigint} gid
* @property {number | bigint} rdev
* @property {number | bigint} size
* @property {number | bigint} blksize
* @property {number | bigint} blocks
* @property {number | bigint} atimeMs
* @property {number | bigint} mtimeMs
* @property {number | bigint} ctimeMs
* @property {number | bigint} birthtimeMs
* @property {T} dev
* @property {T} ino
* @property {T} mode
* @property {T} nlink
* @property {T} uid
* @property {T} gid
* @property {T} rdev
* @property {T} size
* @property {T} blksize
* @property {T} blocks
* @property {T} atimeMs
* @property {T} mtimeMs
* @property {T} ctimeMs
* @property {T} birthtimeMs
* @property {Date} atime

@@ -45,3 +46,11 @@ * @property {Date} mtime

/**
* @typedef {Object} IDirent
* @typedef {IStatsBase<number>} IStats
*/
/**
* @typedef {IStatsBase<bigint> & { atimeNs: bigint, mtimeNs: bigint, ctimeNs: bigint, birthtimeNs: bigint }} IBigIntStats
*/
/**
* @typedef {Object} Dirent
* @property {() => boolean} isFile

@@ -54,15 +63,25 @@ * @property {() => boolean} isDirectory

* @property {() => boolean} isSocket
* @property {string | Buffer} name
* @property {string} name
* @property {string} path
*/
/** @typedef {function((NodeJS.ErrnoException | null)=): void} Callback */
/** @typedef {function((NodeJS.ErrnoException | null)=, Buffer=): void} BufferCallback */
/** @typedef {function((NodeJS.ErrnoException | null)=, Buffer|string=): void} BufferOrStringCallback */
/** @typedef {function((NodeJS.ErrnoException | null)=, (string | Buffer)[] | IDirent[]=): void} DirentArrayCallback */
/** @typedef {function((NodeJS.ErrnoException | null)=, string=): void} StringCallback */
/** @typedef {function((NodeJS.ErrnoException | null)=, number=): void} NumberCallback */
/** @typedef {function((NodeJS.ErrnoException | null)=, IStats=): void} StatsCallback */
/** @typedef {function((NodeJS.ErrnoException | Error | null)=, any=): void} ReadJsonCallback */
/** @typedef {function((NodeJS.ErrnoException | Error | null)=, IStats|string=): void} LstatReadlinkAbsoluteCallback */
/** @typedef {string | number | boolean | null} JsonPrimitive */
/** @typedef {JsonValue[]} JsonArray */
/** @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue */
/** @typedef {{[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined}} JsonObject */
/** @typedef {function(NodeJS.ErrnoException | null): void} NoParamCallback */
/** @typedef {function(NodeJS.ErrnoException | null, string=): void} StringCallback */
/** @typedef {function(NodeJS.ErrnoException | null, Buffer=): void} BufferCallback */
/** @typedef {function(NodeJS.ErrnoException | null, (string | Buffer)=): void} StringOrBufferCallback */
/** @typedef {function(NodeJS.ErrnoException | null, (string[])=): void} ReaddirStringCallback */
/** @typedef {function(NodeJS.ErrnoException | null, (Buffer[])=): void} ReaddirBufferCallback */
/** @typedef {function(NodeJS.ErrnoException | null, (string[] | Buffer[])=): void} ReaddirStringOrBufferCallback */
/** @typedef {function(NodeJS.ErrnoException | null, (Dirent[])=): void} ReaddirDirentCallback */
/** @typedef {function(NodeJS.ErrnoException | null, IStats=): void} StatsCallback */
/** @typedef {function(NodeJS.ErrnoException | null, IBigIntStats=): void} BigIntStatsCallback */
/** @typedef {function(NodeJS.ErrnoException | null, (IStats | IBigIntStats)=): void} StatsOrBigIntStatsCallback */
/** @typedef {function(NodeJS.ErrnoException | null, number=): void} NumberCallback */
/** @typedef {function(NodeJS.ErrnoException | Error | null, JsonObject=): void} ReadJsonCallback */
/**

@@ -92,6 +111,6 @@ * @typedef {Object} WatcherInfo

* @param {Iterable<string>} directories watched directories
* @param {Iterable<string>} missing watched exitance entries
* @param {Iterable<string>} missing watched existence entries
* @param {number} startTime timestamp of start time
* @param {WatchOptions} options options object
* @param {function(Error=, Map<string, FileSystemInfoEntry | "ignore">, Map<string, FileSystemInfoEntry | "ignore">, Set<string>, Set<string>): void} callback aggregated callback
* @param {function(Error | null, Map<string, FileSystemInfoEntry | "ignore">, Map<string, FileSystemInfoEntry | "ignore">, Set<string>, Set<string>): void} callback aggregated callback
* @param {function(string, number): void} callbackUndelayed callback when the first change was detected

@@ -101,14 +120,177 @@ * @returns {Watcher} a watcher

// TODO webpack 6 make optional methods required
// TODO webpack 6 make optional methods required and avoid using non standard methods like `join`, `relative`, `dirname`, move IntermediateFileSystemExtras methods to InputFilesystem or OutputFilesystem
/**
* @typedef {Object} OutputFileSystem
* @property {function(string, Buffer|string, Callback): void} writeFile
* @property {function(string, Callback): void} mkdir
* @property {function(string, DirentArrayCallback): void=} readdir
* @property {function(string, Callback): void=} rmdir
* @property {function(string, Callback): void=} unlink
* @property {function(string, StatsCallback): void} stat
* @property {function(string, StatsCallback): void=} lstat
* @property {function(string, BufferOrStringCallback): void} readFile
* @typedef {string | Buffer | URL} PathLike
*/
/**
* @typedef {PathLike | number} PathOrFileDescriptor
*/
/**
* @typedef {Object} ObjectEncodingOptions
* @property {BufferEncoding | null | undefined} [encoding]
*/
/**
* @typedef {{
* (path: PathOrFileDescriptor, options: ({ encoding?: null | undefined, flag?: string | undefined } & import("events").Abortable) | undefined | null, callback: BufferCallback): void;
* (path: PathOrFileDescriptor, options: ({ encoding: BufferEncoding, flag?: string | undefined } & import("events").Abortable) | BufferEncoding, callback: StringCallback): void;
* (path: PathOrFileDescriptor, options: (ObjectEncodingOptions & { flag?: string | undefined } & import("events").Abortable) | BufferEncoding | undefined | null, callback: StringOrBufferCallback): void;
* (path: PathOrFileDescriptor, callback: BufferCallback): void;
* }} ReadFile
*/
/**
* @typedef {{
* (path: PathOrFileDescriptor, options?: { encoding?: null | undefined, flag?: string | undefined } | null): Buffer;
* (path: PathOrFileDescriptor, options: { encoding: BufferEncoding, flag?: string | undefined } | BufferEncoding): string;
* (path: PathOrFileDescriptor, options?: (ObjectEncodingOptions & { flag?: string | undefined }) | BufferEncoding | null): string | Buffer;
* }} ReadFileSync
*/
/**
* @typedef {ObjectEncodingOptions | BufferEncoding | undefined | null} EncodingOption
*/
/**
* @typedef {'buffer'| { encoding: 'buffer' }} BufferEncodingOption
*/
/**
* @typedef {Object} StatOptions
* @property {(boolean | undefined)=} bigint
*/
/**
* @typedef {Object} StatSyncOptions
* @property {(boolean | undefined)=} bigint
* @property {(boolean | undefined)=} throwIfNoEntry
*/
/**
* @typedef {{
* (path: PathLike, options: EncodingOption, callback: StringCallback): void;
* (path: PathLike, options: BufferEncodingOption, callback: BufferCallback): void;
* (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void;
* (path: PathLike, callback: StringCallback): void;
* }} Readlink
*/
/**
* @typedef {{
* (path: PathLike, options?: EncodingOption): string;
* (path: PathLike, options: BufferEncodingOption): Buffer;
* (path: PathLike, options?: EncodingOption): string | Buffer;
* }} ReadlinkSync
*/
/**
* @typedef {{
* (path: PathLike, options: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | undefined | null, callback: ReaddirStringCallback): void;
* (path: PathLike, options: { encoding: 'buffer', withFileTypes?: false | undefined, recursive?: boolean | undefined } | 'buffer', callback: ReaddirBufferCallback): void;
* (path: PathLike, callback: ReaddirStringCallback): void;
* (path: PathLike, options: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | undefined | null, callback: ReaddirStringOrBufferCallback): void;
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }, callback: ReaddirDirentCallback): void;
* }} Readdir
*/
/**
* @typedef {{
* (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[];
* (path: PathLike, options?: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | null): string[] | Buffer[];
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }): Dirent[];
* }} ReaddirSync
*/
/**
* @typedef {{
* (path: PathLike, callback: StatsCallback): void;
* (path: PathLike, options: (StatOptions & { bigint?: false | undefined }) | undefined, callback: StatsCallback): void;
* (path: PathLike, options: StatOptions & { bigint: true }, callback: BigIntStatsCallback): void;
* (path: PathLike, options: StatOptions | undefined, callback: StatsOrBigIntStatsCallback): void;
* }} Stat
*/
/**
* @typedef {{
* (path: PathLike, options?: undefined): IStats;
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined;
* (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined;
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats;
* (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;
* }} StatSync
*/
/**
* @typedef {{
* (path: PathLike, callback: StatsCallback): void;
* (path: PathLike, options: (StatOptions & { bigint?: false | undefined }) | undefined, callback: StatsCallback): void;
* (path: PathLike, options: StatOptions & { bigint: true }, callback: BigIntStatsCallback): void;
* (path: PathLike, options: StatOptions | undefined, callback: StatsOrBigIntStatsCallback): void;
* }} LStat
*/
/**
* @typedef {{
* (path: PathLike, options?: undefined): IStats;
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined;
* (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined;
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats;
* (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;
* }} LStatSync
*/
/**
* @typedef {{
* (path: PathLike, options: EncodingOption, callback: StringCallback): void;
* (path: PathLike, options: BufferEncodingOption, callback: BufferCallback): void;
* (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void;
* (path: PathLike, callback: StringCallback): void;
* }} RealPath
*/
/**
* @typedef {{
* (path: PathLike, options?: EncodingOption): string;
* (path: PathLike, options: BufferEncodingOption): Buffer;
* (path: PathLike, options?: EncodingOption): string | Buffer;
* }} RealPathSync
*/
/**
* @typedef {function(PathOrFileDescriptor, ReadJsonCallback): void} ReadJson
*/
/**
* @typedef {function(PathOrFileDescriptor): JsonObject} ReadJsonSync
*/
/**
* @typedef {function((string | string[] | Set<string>)=): void} Purge
*/
/**
* @typedef {Object} InputFileSystem
* @property {ReadFile} readFile
* @property {ReadFileSync=} readFileSync
* @property {Readlink} readlink
* @property {ReadlinkSync=} readlinkSync
* @property {Readdir} readdir
* @property {ReaddirSync=} readdirSync
* @property {Stat} stat
* @property {StatSync=} statSync
* @property {LStat=} lstat
* @property {LStatSync=} lstatSync
* @property {RealPath=} realpath
* @property {RealPathSync=} realpathSync
* @property {ReadJson=} readJson
* @property {ReadJsonSync=} readJsonSync
* @property {Purge=} purge
* @property {(function(string, string): string)=} join

@@ -120,11 +302,54 @@ * @property {(function(string, string): string)=} relative

/**
* @typedef {Object} InputFileSystem
* @property {function(string, BufferOrStringCallback): void} readFile
* @property {(function(string, ReadJsonCallback): void)=} readJson
* @property {function(string, BufferOrStringCallback): void} readlink
* @property {function(string, DirentArrayCallback): void} readdir
* @property {function(string, StatsCallback): void} stat
* @property {function(string, StatsCallback): void=} lstat
* @property {(function(string, BufferOrStringCallback): void)=} realpath
* @property {(function(string=): void)=} purge
* @typedef {number | string} Mode
*/
/**
* @typedef {(ObjectEncodingOptions & import("events").Abortable & { mode?: Mode | undefined, flag?: string | undefined, flush?: boolean | undefined }) | BufferEncoding | null} WriteFileOptions
*/
/**
* @typedef {{
* (file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void;
* (file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void;
* }} WriteFile
*/
/**
* @typedef {{ recursive?: boolean | undefined, mode?: Mode | undefined }} MakeDirectoryOptions
*/
/**
* @typedef {{
* (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 | null | undefined, callback: StringCallback): void;
* (file: PathLike, callback: NoParamCallback): void;
* }} Mkdir
*/
/**
* @typedef {{ maxRetries?: number | undefined, recursive?: boolean | undefined, retryDelay?: number | undefined }} RmDirOptions
*/
/**
* @typedef {{
* (file: PathLike, callback: NoParamCallback): void;
* (file: PathLike, options: RmDirOptions, callback: NoParamCallback): void;
* }} Rmdir
*/
/**
* @typedef {function(PathLike, NoParamCallback): void} Unlink
*/
/**
* @typedef {Object} OutputFileSystem
* @property {WriteFile} writeFile
* @property {Mkdir} mkdir
* @property {Readdir=} readdir
* @property {Rmdir=} rmdir
* @property {Unlink=} unlink
* @property {Stat} stat
* @property {LStat=} lstat
* @property {ReadFile} readFile
* @property {(function(string, string): string)=} join

@@ -141,9 +366,92 @@ * @property {(function(string, string): string)=} relative

/**
* @typedef {{
* (path: PathLike, options: MakeDirectoryOptions & { recursive: true }): string | undefined;
* (path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false | undefined }) | null): void;
* (path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined;
* }} MkdirSync
*/
/**
* @typedef {Object} StreamOptions
* @property {(string | undefined)=} flags
* @property {(BufferEncoding | undefined)} encoding
* @property {(number | any | undefined)=} fd
* @property {(number | undefined)=} mode
* @property {(boolean | undefined)=} autoClose
* @property {(boolean | undefined)=} emitClose
* @property {(number | undefined)=} start
* @property {(AbortSignal | null | undefined)=} signal
*/
/**
* @typedef {Object} FSImplementation
* @property {((...args: any[]) => any)=} open
* @property {((...args: any[]) => any)=} close
*/
/**
* @typedef {FSImplementation & { write: (...args: any[]) => any; close?: (...args: any[]) => any }} CreateWriteStreamFSImplementation
*/
/**
* @typedef {StreamOptions & { fs?: CreateWriteStreamFSImplementation | null | undefined }} WriteStreamOptions
*/
/**
* @typedef {function(PathLike, (BufferEncoding | WriteStreamOptions)=): NodeJS.WritableStream} CreateWriteStream
*/
/**
* @typedef {number | string} OpenMode
*/
/**
* @typedef {{
* (file: PathLike, flags: OpenMode | undefined, mode: Mode | undefined | null, callback: NumberCallback): void;
* (file: PathLike, flags: OpenMode | undefined, callback: NumberCallback): void;
* (file: PathLike, callback: NumberCallback): void;
* }} Open
*/
/**
* @typedef {number | bigint} ReadPosition
*/
/**
* @typedef {Object} ReadSyncOptions
* @property {(number | undefined)=} offset
* @property {(number | undefined)=} length
* @property {(ReadPosition | null | undefined)=} position
*/
/**
* @template {NodeJS.ArrayBufferView} TBuffer
* @typedef {Object} ReadAsyncOptions
* @property {(number | undefined)=} offset
* @property {(number | undefined)=} length
* @property {(ReadPosition | null | undefined)=} position
* @property {TBuffer=} buffer
*/
/**
* @template {NodeJS.ArrayBufferView} [TBuffer=Buffer]
* @typedef {{
* (fd: number, buffer: TBuffer, offset: number, length: number, position: ReadPosition | null, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void): void;
* (fd: number, options: ReadAsyncOptions<TBuffer>, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void): void;
* (fd: number, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void): void;
* }} Read
*/
/** @typedef {function(number, NoParamCallback): void} Close */
/** @typedef {function(PathLike, PathLike, NoParamCallback): void} Rename */
/**
* @typedef {Object} IntermediateFileSystemExtras
* @property {function(string): void} mkdirSync
* @property {function(string): NodeJS.WritableStream} createWriteStream
* @property {function(string, string, NumberCallback): void} open
* @property {function(number, Buffer, number, number, number, NumberCallback): void} read
* @property {function(number, Callback): void} close
* @property {function(string, string, Callback): void} rename
* @property {MkdirSync} mkdirSync
* @property {CreateWriteStream} createWriteStream
* @property {Open} open
* @property {Read} read
* @property {Close} close
* @property {Rename} rename
*/

@@ -271,3 +579,3 @@

if (err) {
if (err.code === "ENOENT") {
if (/** @type {NodeJS.ErrnoException} */ (err).code === "ENOENT") {
const dir = dirname(fs, p);

@@ -280,3 +588,3 @@ if (dir === p) {

return;
} else if (err.code === "EEXIST") {
} else if (/** @type {NodeJS.ErrnoException} */ (err).code === "EEXIST") {
return;

@@ -297,3 +605,6 @@ }

const readJson = (fs, p, callback) => {
if ("readJson" in fs) return fs.readJson(p, callback);
if ("readJson" in fs)
return /** @type {NonNullable<InputFileSystem["readJson"]>} */ (
fs.readJson
)(p, callback);
fs.readFile(p, (err, buf) => {

@@ -303,5 +614,5 @@ if (err) return callback(err);

try {
data = JSON.parse(buf.toString("utf-8"));
data = JSON.parse(/** @type {Buffer} */ (buf).toString("utf-8"));
} catch (e) {
return callback(e);
return callback(/** @type {Error} */ (e));
}

@@ -316,3 +627,3 @@ return callback(null, data);

* @param {string} p an absolute path
* @param {ReadJsonCallback} callback callback
* @param {function(NodeJS.ErrnoException | Error | null, (IStats | string)=): void} callback callback
* @returns {void}

@@ -336,9 +647,12 @@ */

if ("lstat" in fs) {
return fs.lstat(p, (err, stats) => {
if (err) return callback(err);
if (stats.isSymbolicLink()) {
return doReadLink();
return /** @type {NonNullable<InputFileSystem["lstat"]>} */ (fs.lstat)(
p,
(err, stats) => {
if (err) return callback(err);
if (/** @type {IStats} */ (stats).isSymbolicLink()) {
return doReadLink();
}
callback(null, stats);
}
callback(null, stats);
});
);
} else {

@@ -345,0 +659,0 @@ return fs.stat(p, callback);

@@ -12,2 +12,5 @@ /*

class BatchedHash extends Hash {
/**
* @param {Hash} hash hash
*/
constructor(hash) {

@@ -14,0 +17,0 @@ super();

@@ -13,4 +13,4 @@ /*

Buffer.from(
// 1168 bytes
"AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrAIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEDIAQgASkDEELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEEIAUgASkDGELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEFIAFBIGoiASAASQ0ACyACJAAgAyQBIAQkAiAFJAMLpgYCAn8EfiMEQgBSBH4jACIDQgGJIwEiBEIHiXwjAiIFQgyJfCMDIgZCEol8IANCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0gBELP1tO+0ser2UJ+Qh+JQoeVr6+Ytt6bnn9+hUKHla+vmLbem55/fkKdo7Xqg7GNivoAfSAFQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IAZCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0FQsXP2bLx5brqJwsjBCAArXx8IQMDQCABQQhqIgIgAE0EQCADIAEpAwBCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCG4lCh5Wvr5i23puef35CnaO16oOxjYr6AH0hAyACIQEMAQsLIAFBBGoiAiAATQRAIAMgATUCAEKHla+vmLbem55/foVCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMgAiEBCwNAIAAgAUcEQCADIAExAABCxc/ZsvHluuonfoVCC4lCh5Wvr5i23puef34hAyABQQFqIQEMAQsLQQAgAyADQiGIhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFIgNCIIgiBEL//wODQiCGIARCgID8/w+DQhCIhCIEQv+BgIDwH4NCEIYgBEKA/oOAgOA/g0IIiIQiBEKPgLyA8IHAB4NCCIYgBELwgcCHgJ6A+ACDQgSIhCIEQoaMmLDgwIGDBnxCBIhCgYKEiJCgwIABg0InfiAEQrDgwIGDhoyYMIR8NwMAQQggA0L/////D4MiA0L//wODQiCGIANCgID8/w+DQhCIhCIDQv+BgIDwH4NCEIYgA0KA/oOAgOA/g0IIiIQiA0KPgLyA8IHAB4NCCIYgA0LwgcCHgJ6A+ACDQgSIhCIDQoaMmLDgwIGDBnxCBIhCgYKEiJCgwIABg0InfiADQrDgwIGDhoyYMIR8NwMACw==",
// 1160 bytes
"AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACqgIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEDIAQgASkDEELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEEIAUgASkDGELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEFIAFBIGoiASAASQ0ACyACJAAgAyQBIAQkAiAFJAMLngYCAn8CfiMEQgBSBH4jAEIBiSMBQgeJfCMCQgyJfCMDQhKJfCMAQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IwFCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0jAkLP1tO+0ser2UJ+Qh+JQoeVr6+Ytt6bnn9+hUKHla+vmLbem55/fkKdo7Xqg7GNivoAfSMDQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9BULFz9my8eW66icLIwQgAK18fCEDA0AgAUEIaiICIABNBEAgAyABKQMAQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQhuJQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IQMgAiEBDAELCyABQQRqIgIgAE0EQCADIAE1AgBCh5Wvr5i23puef36FQheJQs/W077Sx6vZQn5C+fPd8Zn2masWfCEDIAIhAQsDQCAAIAFHBEAgAyABMQAAQsXP2bLx5brqJ36FQguJQoeVr6+Ytt6bnn9+IQMgAUEBaiEBDAELC0EAIAMgA0IhiIVCz9bTvtLHq9lCfiIDQh2IIAOFQvnz3fGZ9pmrFn4iA0IgiCADhSIDQiCIIgRC//8Dg0IghiAEQoCA/P8Pg0IQiIQiBEL/gYCA8B+DQhCGIARCgP6DgIDgP4NCCIiEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEIIANC/////w+DIgNC//8Dg0IghiADQoCA/P8Pg0IQiIQiA0L/gYCA8B+DQhCGIANCgP6DgIDgP4NCCIiEIgNCj4C8gPCBwAeDQgiGIANC8IHAh4CegPgAg0IEiIQiA0KGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gA0Kw4MCBg4aMmDCEfDcDAAs=",
"base64"

@@ -17,0 +17,0 @@ )

@@ -233,3 +233,3 @@ /*

/**
* @param {RuntimeSpec[]} runtimes first
* @param {RuntimeSpec[] | undefined} runtimes first
* @param {RuntimeSpec} runtime second

@@ -236,0 +236,0 @@ * @returns {RuntimeSpec} merged

@@ -11,2 +11,25 @@ /*

* @template V
*
* The StackedCacheMap is a data structure designed as an alternative to a Map
* in situations where you need to handle multiple item additions and
* frequently access the largest map.
*
* It is particularly optimized for efficiently adding multiple items
* at once, which can be achieved using the `addAll` method.
*
* It has a fallback Map that is used when the map to be added is mutable.
*
* Note: `delete` and `has` are not supported for performance reasons.
*
* @example
* ```js
* const map = new StackedCacheMap();
* map.addAll(new Map([["a", 1], ["b", 2]]), true);
* map.addAll(new Map([["c", 3], ["d", 4]]), true);
* map.get("a"); // 1
* map.get("d"); // 4
* for (const [key, value] of map) {
* console.log(key, value);
* }
* ```
*/

@@ -22,2 +45,5 @@ class StackedCacheMap {

/**
* If `immutable` is true, the map can be referenced by the StackedCacheMap
* and should not be changed afterwards. If the map is mutable, all items
* are copied into a fallback Map.
* @param {ReadonlyMap<K, V>} map map to add

@@ -24,0 +50,0 @@ * @param {boolean=} immutable if 'map' is immutable and StackedCacheMap can keep referencing it

@@ -8,2 +8,17 @@ /*

/**
* @template {any[]} T
* @template V
* @typedef {Map<object, WeakTupleMap<T, V>>} M
*/
/**
* @template {any[]} T
* @template V
* @typedef {WeakMap<object, WeakTupleMap<T, V>>} W
*/
/**
* @param {any} thing thing
* @returns {boolean} true if is weak
*/
const isWeakKey = thing => typeof thing === "object" && thing !== null;

@@ -19,7 +34,16 @@

this.f = 0;
/** @private @type {any} */
/**
* @private
* @type {any}
**/
this.v = undefined;
/** @private @type {Map<object, WeakTupleMap<T, V>> | undefined} */
/**
* @private
* @type {M<T, V> | undefined}
**/
this.m = undefined;
/** @private @type {WeakMap<object, WeakTupleMap<T, V>> | undefined} */
/**
* @private
* @type {W<T, V> | undefined}
**/
this.w = undefined;

@@ -46,3 +70,3 @@ }

has(...args) {
/** @type {WeakTupleMap<T, V>} */
/** @type {WeakTupleMap<T, V> | undefined} */
let node = this;

@@ -58,6 +82,6 @@ for (let i = 0; i < args.length; i++) {

* @param {T} args tuple
* @returns {V} the value
* @returns {V | undefined} the value
*/
get(...args) {
/** @type {WeakTupleMap<T, V>} */
/** @type {WeakTupleMap<T, V> | undefined} */
let node = this;

@@ -93,3 +117,3 @@ for (let i = 0; i < args.length; i++) {

delete(...args) {
/** @type {WeakTupleMap<T, V>} */
/** @type {WeakTupleMap<T, V> | undefined} */
let node = this;

@@ -121,2 +145,6 @@ for (let i = 0; i < args.length; i++) {

/**
* @param {any} v value
* @private
*/
_setValue(v) {

@@ -132,12 +160,22 @@ this.f |= 1;

/**
* @param {any} thing thing
* @returns {WeakTupleMap<T, V> | undefined} thing
* @private
*/
_peek(thing) {
if (isWeakKey(thing)) {
if ((this.f & 4) !== 4) return undefined;
return this.w.get(thing);
return /** @type {W<T, V>} */ (this.w).get(thing);
} else {
if ((this.f & 2) !== 2) return undefined;
return this.m.get(thing);
return /** @type {M<T, V>} */ (this.m).get(thing);
}
}
/**
* @private
* @param {any} thing thing
* @returns {WeakTupleMap<T, V>} value
*/
_get(thing) {

@@ -152,3 +190,5 @@ if (isWeakKey(thing)) {

}
const entry = this.w.get(thing);
const entry =
/** @type {W<T, V>} */
(this.w).get(thing);
if (entry !== undefined) {

@@ -158,3 +198,4 @@ return entry;

const newNode = new WeakTupleMap();
this.w.set(thing, newNode);
/** @type {W<T, V>} */
(this.w).set(thing, newNode);
return newNode;

@@ -169,3 +210,5 @@ } else {

}
const entry = this.m.get(thing);
const entry =
/** @type {M<T, V>} */
(this.m).get(thing);
if (entry !== undefined) {

@@ -175,3 +218,4 @@ return entry;

const newNode = new WeakTupleMap();
this.m.set(thing, newNode);
/** @type {M<T, V>} */
(this.m).set(thing, newNode);
return newNode;

@@ -178,0 +222,0 @@ }

@@ -80,3 +80,3 @@ /*

if (dep instanceof WebAssemblyImportDependency) {
const module = moduleGraph.getModule(dep);
const module = /** @type {Module} */ (moduleGraph.getModule(dep));
if (!depModules.has(module)) {

@@ -124,3 +124,5 @@ depModules.set(module, {

const exportItems = deps.map(dep => {
const importedModule = moduleGraph.getModule(dep);
const importedModule =
/** @type {Module} */
(moduleGraph.getModule(dep));
const importVar =

@@ -127,0 +129,0 @@ /** @type {ImportObjRequestItem} */

@@ -18,2 +18,3 @@ /*

/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
/** @typedef {import("../ModuleGraph")} ModuleGraph */

@@ -65,2 +66,3 @@ /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */

const moduleGraph = chunkGraph.moduleGraph;
/** @type {Map<string, string | number>} */
const waitForInstances = new Map();

@@ -90,3 +92,6 @@ const properties = [];

const instanceVar = `m${waitForInstances.size}`;
waitForInstances.set(instanceVar, chunkGraph.getModuleId(importedModule));
waitForInstances.set(
instanceVar,
chunkGraph.getModuleId(/** @type {Module} */ (importedModule))
);
properties.push({

@@ -105,3 +110,3 @@ module,

const mod = `${RuntimeGlobals.moduleCache}[${JSON.stringify(
chunkGraph.getModuleId(importedModule)
chunkGraph.getModuleId(/** @type {Module} */ (importedModule))
)}]`;

@@ -113,2 +118,8 @@ const modExports = `${mod}.exports`;

const modCode =
/** @type {Module} */
(importedModule).type.startsWith("webassembly")
? `${mod} ? ${modExports}[${JSON.stringify(usedName)}] : `
: "";
properties.push({

@@ -118,5 +129,3 @@ module,

value: Template.asString([
(importedModule.type.startsWith("webassembly")
? `${mod} ? ${modExports}[${JSON.stringify(usedName)}] : `
: "") + `function(${params}) {`,
modCode + `function(${params}) {`,
Template.indent([

@@ -214,3 +223,3 @@ `if(${cache} === undefined) ${cache} = ${modExports};`,

* @property {boolean} [mangleImports]
* @property {Set<string>} runtimeRequirements
* @property {ReadOnlyRuntimeRequirements} runtimeRequirements
*/

@@ -217,0 +226,0 @@

@@ -28,2 +28,10 @@ /*

/** @typedef {import("./WebAssemblyUtils").UsedWasmDependency} UsedWasmDependency */
/** @typedef {import("@webassemblyjs/ast").Instruction} Instruction */
/** @typedef {import("@webassemblyjs/ast").ModuleImport} ModuleImport */
/** @typedef {import("@webassemblyjs/ast").ModuleExport} ModuleExport */
/** @typedef {import("@webassemblyjs/ast").Global} Global */
/**
* @template T
* @typedef {import("@webassemblyjs/ast").NodePath<T>} NodePath
*/

@@ -36,3 +44,3 @@ /**

* @template T
* @param {Function[]} fns transforms
* @param {((prev: ArrayBuffer) => ArrayBuffer)[]} fns transforms
* @returns {Function} composed transform

@@ -52,3 +60,4 @@ */

*
* @param {Object} state unused state
* @param {Object} state state
* @param {Object} state.ast Module's ast
* @returns {ArrayBufferTransform} transform

@@ -124,3 +133,3 @@ */

*
* The Func section metadata provide informations for implemented funcs
* The Func section metadata provide information for implemented funcs
* in order to have the correct index we shift the index by number of external

@@ -176,3 +185,5 @@ * functions.

*
* @param {Object} state unused state
* @param {Object} state transformation state
* @param {Object} state.ast Module's ast
* @param {t.Instruction[]} state.additionalInitCode list of addition instructions for the init function
* @returns {ArrayBufferTransform} transform

@@ -188,3 +199,3 @@ */

if (t.isGlobalType(path.node.descr)) {
const globalType = path.node.descr;
const globalType = /** @type {TODO} */ (path.node.descr);

@@ -206,2 +217,5 @@ globalType.mutability = "var";

// those as well
/**
* @param {NodePath<Global>} path path
*/
Global(path) {

@@ -256,2 +270,5 @@ const { node } = path;

return editWithAST(ast, bin, {
/**
* @param {NodePath<ModuleExport>} path path
*/
ModuleExport(path) {

@@ -270,3 +287,3 @@ const isExternal = externalExports.has(path.node.name);

}
path.node.name = usedName;
path.node.name = /** @type {string} */ (usedName);
}

@@ -287,2 +304,5 @@ });

return editWithAST(ast, bin, {
/**
* @param {NodePath<ModuleImport>} path path
*/
ModuleImport(path) {

@@ -339,2 +359,3 @@ const result = usedDependencyMap.get(

/** @type {Instruction[]} */
const funcBody = [];

@@ -341,0 +362,0 @@ importedGlobals.forEach((importedGlobal, index) => {

@@ -100,4 +100,5 @@ /*

const exports = [];
let jsIncompatibleExports = (state.module.buildMeta.jsIncompatibleExports =
undefined);
const buildMeta = /** @type {BuildMeta} */ (state.module.buildMeta);
/** @type {Record<string, string> | undefined} */
let jsIncompatibleExports = (buildMeta.jsIncompatibleExports = undefined);

@@ -122,3 +123,4 @@ /** @type {TODO[]} */

jsIncompatibleExports =
state.module.buildMeta.jsIncompatibleExports = {};
/** @type {BuildMeta} */
(state.module.buildMeta).jsIncompatibleExports = {};
}

@@ -132,3 +134,4 @@ jsIncompatibleExports[node.name] = incompatibleType;

if (node.descr && node.descr.exportType === "Global") {
const refNode = importedGlobals[node.descr.id.value];
const refNode =
importedGlobals[/** @type {TODO} */ (node.descr.id.value)];
if (refNode) {

@@ -135,0 +138,0 @@ const dep = new WebAssemblyExportImportedDependency(

@@ -16,2 +16,3 @@ /*

/** @typedef {import("./logging/Logger").Logger} Logger */
/** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */

@@ -21,3 +22,3 @@ /**

* @callback Callback
* @param {(Error | null)=} err
* @param {Error | null} err
* @param {T=} result

@@ -176,4 +177,12 @@ */

if (err) return this._done(err);
const onCompiled = (err, compilation) => {
if (err) return this._done(err, compilation);
/**
* @param {Error | null} err error
* @param {Compilation=} _compilation compilation
* @returns {void}
*/
const onCompiled = (err, _compilation) => {
if (err) return this._done(err, _compilation);
const compilation = /** @type {Compilation} */ (_compilation);
if (this.invalid) return this._done(null, compilation);

@@ -201,3 +210,5 @@

compilation.startTime = this.startTime;
compilation.startTime = /** @type {number} */ (
this.startTime
);
compilation.endTime = Date.now();

@@ -246,6 +257,8 @@ logger.time("done hook");

const logger = compilation && compilation.getLogger("webpack.Watching");
const logger =
/** @type {Logger} */
(compilation && compilation.getLogger("webpack.Watching"));
/** @type {Stats | null} */
let stats = null;
/** @type {Stats | undefined} */
let stats = undefined;

@@ -275,9 +288,7 @@ /**

if (compilation) {
/** @type {Logger} */
(logger).time("storeBuildDependencies");
logger.time("storeBuildDependencies");
this.compiler.cache.storeBuildDependencies(
compilation.buildDependencies,
err => {
/** @type {Logger} */
(logger).timeEnd("storeBuildDependencies");
logger.timeEnd("storeBuildDependencies");
if (err) return handleError(err);

@@ -294,3 +305,3 @@ this._go();

if (compilation) {
compilation.startTime = this.startTime;
compilation.startTime = /** @type {number} */ (this.startTime);
compilation.endTime = Date.now();

@@ -304,11 +315,8 @@ stats = new Stats(compilation);

this.callbacks = [];
/** @type {Logger} */
(logger).time("done hook");
logger.time("done hook");
this.compiler.hooks.done.callAsync(/** @type {Stats} */ (stats), err => {
/** @type {Logger} */
(logger).timeEnd("done hook");
logger.timeEnd("done hook");
if (err) return handleError(err, cbs);
this.handler(null, /** @type {Stats} */ (stats));
/** @type {Logger} */
(logger).time("storeBuildDependencies");
this.handler(null, stats);
logger.time("storeBuildDependencies");
this.compiler.cache.storeBuildDependencies(

@@ -318,11 +326,8 @@ /** @type {Compilation} */

err => {
/** @type {Logger} */
(logger).timeEnd("storeBuildDependencies");
logger.timeEnd("storeBuildDependencies");
if (err) return handleError(err, cbs);
/** @type {Logger} */
(logger).time("beginIdle");
logger.time("beginIdle");
this.compiler.cache.beginIdle();
this.compiler.idle = true;
/** @type {Logger} */
(logger).timeEnd("beginIdle");
logger.timeEnd("beginIdle");
process.nextTick(() => {

@@ -355,24 +360,12 @@ if (!this.closed) {

this.pausedWatcher = null;
this.watcher = this.compiler.watchFileSystem.watch(
files,
dirs,
missing,
this.lastWatcherStartTime,
this.watchOptions,
(
err,
fileTimeInfoEntries,
contextTimeInfoEntries,
changedFiles,
removedFiles
) => {
if (err) {
this.compiler.modifiedFiles = undefined;
this.compiler.removedFiles = undefined;
this.compiler.fileTimestamps = undefined;
this.compiler.contextTimestamps = undefined;
this.compiler.fsStartTime = undefined;
return this.handler(err);
}
this._invalidate(
this.watcher =
/** @type {WatchFileSystem} */
(this.compiler.watchFileSystem).watch(
files,
dirs,
missing,
/** @type {number} */ (this.lastWatcherStartTime),
this.watchOptions,
(
err,
fileTimeInfoEntries,

@@ -382,13 +375,27 @@ contextTimeInfoEntries,

removedFiles
);
this._onChange();
},
(fileName, changeTime) => {
if (!this._invalidReported) {
this._invalidReported = true;
this.compiler.hooks.invalid.call(fileName, changeTime);
) => {
if (err) {
this.compiler.modifiedFiles = undefined;
this.compiler.removedFiles = undefined;
this.compiler.fileTimestamps = undefined;
this.compiler.contextTimestamps = undefined;
this.compiler.fsStartTime = undefined;
return this.handler(err);
}
this._invalidate(
fileTimeInfoEntries,
contextTimeInfoEntries,
changedFiles,
removedFiles
);
this._onChange();
},
(fileName, changeTime) => {
if (!this._invalidReported) {
this._invalidReported = true;
this.compiler.hooks.invalid.call(fileName, changeTime);
}
this._onInvalid();
}
this._onInvalid();
}
);
);
}

@@ -466,3 +473,3 @@

/**
* @param {(WebpackError | null)=} err error if any
* @param {WebpackError | null} err error if any
* @param {Compilation=} compilation compilation if any

@@ -481,3 +488,3 @@ */

/**
* @param {(WebpackError | null)=} err error if any
* @param {WebpackError | null} err error if any
*/

@@ -524,3 +531,3 @@ const shutdown = err => {

} else {
finalCallback();
finalCallback(null);
}

@@ -527,0 +534,0 @@ }

@@ -18,2 +18,3 @@ /*

/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */

@@ -52,3 +53,3 @@ /**

/**
* @param {Set<string>} runtimeRequirements runtime requirements
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
*/

@@ -55,0 +56,0 @@ constructor(runtimeRequirements) {

@@ -34,3 +34,3 @@ /*

* @callback Callback
* @param {(Error | null)=} err
* @param {Error | null} err
* @param {T=} stats

@@ -117,3 +117,3 @@ * @returns {void}

* @param {Callback<Stats> & Callback<MultiStats>=} callback callback
* @returns {Compiler | MultiCompiler} Compiler or MultiCompiler
* @returns {Compiler | MultiCompiler | null} Compiler or MultiCompiler
*/

@@ -161,3 +161,7 @@ (options, callback) => {

compiler.close(err2 => {
callback(err || err2, stats);
callback(
err || err2,
/** @type {options extends WebpackOptions ? Stats : MultiStats} */
(stats)
);
});

@@ -164,0 +168,0 @@ });

@@ -25,13 +25,13 @@ /*

/** @type {string | undefined} */
/** @type {string=} */
this.details = undefined;
/** @type {Module | undefined | null} */
/** @type {(Module | null)=} */
this.module = undefined;
/** @type {DependencyLocation | undefined} */
/** @type {DependencyLocation=} */
this.loc = undefined;
/** @type {boolean | undefined} */
/** @type {boolean=} */
this.hideStack = undefined;
/** @type {Chunk | undefined} */
/** @type {Chunk=} */
this.chunk = undefined;
/** @type {string | undefined} */
/** @type {string=} */
this.file = undefined;

@@ -38,0 +38,0 @@ }

@@ -60,2 +60,4 @@ /*

/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
/** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */

@@ -459,3 +461,6 @@ class WebpackOptionsApply extends OptionsApply {

const RuntimeChunkPlugin = require("./optimize/RuntimeChunkPlugin");
new RuntimeChunkPlugin(options.optimization.runtimeChunk).apply(compiler);
new RuntimeChunkPlugin(
/** @type {{ name?: (entrypoint: { name: string }) => string }} */
(options.optimization.runtimeChunk)
).apply(compiler);
}

@@ -654,3 +659,5 @@ if (!options.optimization.emitOnErrors) {

compiler,
fs: compiler.intermediateFileSystem,
fs: /** @type {IntermediateFileSystem} */ (
compiler.intermediateFileSystem
),
context: options.context,

@@ -700,3 +707,5 @@ cacheLocation: cacheOptions.cacheLocation,

resolveOptions = cleverMerge(options.resolve, resolveOptions);
resolveOptions.fileSystem = compiler.inputFileSystem;
resolveOptions.fileSystem =
/** @type {InputFileSystem} */
(compiler.inputFileSystem);
return resolveOptions;

@@ -708,3 +717,5 @@ });

resolveOptions = cleverMerge(options.resolve, resolveOptions);
resolveOptions.fileSystem = compiler.inputFileSystem;
resolveOptions.fileSystem =
/** @type {InputFileSystem} */
(compiler.inputFileSystem);
resolveOptions.resolveToContext = true;

@@ -717,3 +728,5 @@ return resolveOptions;

resolveOptions = cleverMerge(options.resolveLoader, resolveOptions);
resolveOptions.fileSystem = compiler.inputFileSystem;
resolveOptions.fileSystem =
/** @type {InputFileSystem} */
(compiler.inputFileSystem);
return resolveOptions;

@@ -720,0 +733,0 @@ });

@@ -21,6 +21,7 @@ /*

/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
/**
* @param {Set<string>} runtimeRequirements runtime requirements
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
* @param {boolean} withCreateScriptUrl with createScriptUrl support

@@ -27,0 +28,0 @@ */

{
"name": "webpack",
"version": "5.90.3",
"version": "5.91.0",
"author": "Tobias Koppers @sokra",

@@ -10,5 +10,5 @@ "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.",

"@types/estree": "^1.0.5",
"@webassemblyjs/ast": "^1.11.5",
"@webassemblyjs/wasm-edit": "^1.11.5",
"@webassemblyjs/wasm-parser": "^1.11.5",
"@webassemblyjs/ast": "^1.12.1",
"@webassemblyjs/wasm-edit": "^1.12.1",
"@webassemblyjs/wasm-parser": "^1.12.1",
"acorn": "^8.7.1",

@@ -18,3 +18,3 @@ "acorn-import-assertions": "^1.9.0",

"chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.15.0",
"enhanced-resolve": "^5.16.0",
"es-module-lexer": "^1.2.1",

@@ -24,3 +24,3 @@ "eslint-scope": "5.1.1",

"glob-to-regexp": "^0.4.1",
"graceful-fs": "^4.2.9",
"graceful-fs": "^4.2.11",
"json-parse-even-better-errors": "^2.3.1",

@@ -33,3 +33,3 @@ "loader-runner": "^4.2.0",

"terser-webpack-plugin": "^5.3.10",
"watchpack": "^2.4.0",
"watchpack": "^2.4.1",
"webpack-sources": "^3.2.3"

@@ -45,5 +45,6 @@ },

"@babel/preset-react": "^7.23.3",
"@types/glob-to-regexp": "^0.4.4",
"@types/jest": "^29.5.11",
"@types/mime-types": "^2.1.4",
"@types/node": "^20.1.7",
"@types/node": "^20.11.27",
"assemblyscript": "^0.27.22",

@@ -57,3 +58,3 @@ "babel-loader": "^8.1.0",

"coveralls": "^3.1.0",
"cspell": "^6.31.1",
"cspell": "^8.6.0",
"css-loader": "^5.0.1",

@@ -70,5 +71,5 @@ "date-fns": "^3.2.0",

"file-loader": "^6.0.0",
"fork-ts-checker-webpack-plugin": "^8.0.0",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"hash-wasm": "^4.9.0",
"husky": "^8.0.3",
"husky": "^9.0.11",
"is-ci": "^3.0.0",

@@ -86,12 +87,12 @@ "istanbul": "^0.4.5",

"less-loader": "^8.0.0",
"lint-staged": "^13.2.1",
"lint-staged": "^15.2.2",
"lodash": "^4.17.19",
"lodash-es": "^4.17.15",
"memfs": "^3.5.0",
"memfs": "^4.7.7",
"mini-css-extract-plugin": "^1.6.1",
"mini-svg-data-uri": "^1.2.3",
"nyc": "^15.1.0",
"open-cli": "^7.2.0",
"open-cli": "^8.0.0",
"prettier": "^3.2.1",
"prettier-2": "npm:prettier@^2",
"prettier": "^3.2.1",
"pretty-format": "^29.5.0",

@@ -110,7 +111,7 @@ "pug": "^3.0.0",

"toml": "^3.0.0",
"tooling": "webpack/tooling#v1.23.1",
"ts-loader": "^9.4.2",
"typescript": "^5.0.4",
"tooling": "webpack/tooling#v1.23.3",
"ts-loader": "^9.5.1",
"typescript": "^5.4.2",
"url-loader": "^4.1.0",
"wast-loader": "^1.11.5",
"wast-loader": "^1.12.1",
"webassembly-feature": "1.3.0",

@@ -166,8 +167,8 @@ "webpack-cli": "^5.0.1",

"module-typings-test": "tsc -p tsconfig.module.test.json",
"spellcheck": "cspell --no-progress \"**\"",
"spellcheck": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
"special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
"special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
"fix": "yarn code-lint --fix && yarn special-lint-fix && yarn pretty-lint-fix",
"prepare": "husky install",
"pretty-lint-base": "node node_modules/prettier/bin/prettier.cjs --cache .",
"prepare": "husky",
"pretty-lint-base": "node node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
"pretty-lint-fix": "yarn pretty-lint-base --loglevel warn --write",

@@ -195,8 +196,6 @@ "pretty-lint": "yarn pretty-lint-base --check",

"*": [
"prettier --cache --ignore-unknown"
],
"*.md|{.github,benchmark,bin,examples,hot,lib,schemas,setup,tooling}/**/*.{md,yml,yaml,js,json}": [
"cspell"
"prettier --cache --write --ignore-unknown",
"cspell --cache --no-must-find-files"
]
}
}

@@ -6,2 +6,2 @@ /*

*/
"use strict";function n(t,{instancePath:l="",parentData:e,parentDataProperty:s,rootData:a=t}={}){let r=null,o=0;const u=o;let i=!1;const p=o;if(o===p)if(Array.isArray(t)){const n=t.length;for(let l=0;l<n;l++){let n=t[l];const e=o,s=o;let a=!1,u=null;const i=o,p=o;let f=!1;const h=o;if(!(n instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var c=h===o;if(f=f||c,!f){const t=o;if(o===t)if("string"==typeof n){if(n.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}c=t===o,f=f||c}if(f)o=p,null!==r&&(p?r.length=p:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}if(i===o&&(a=!0,u=0),a)o=s,null!==r&&(s?r.length=s:r=null);else{const n={params:{passingSchemas:u}};null===r?r=[n]:r.push(n),o++}if(e!==o)break}}else{const n={params:{type:"array"}};null===r?r=[n]:r.push(n),o++}var f=p===o;if(i=i||f,!i){const n=o,l=o;let e=!1;const s=o;if(!(t instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var h=s===o;if(e=e||h,!e){const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}h=n===o,e=e||h}if(e)o=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}f=n===o,i=i||f}if(!i){const t={params:{}};return null===r?r=[t]:r.push(t),o++,n.errors=r,!1}return o=u,null!==r&&(u?r.length=u:r=null),n.errors=r,0===o}function t(l,{instancePath:e="",parentData:s,parentDataProperty:a,rootData:r=l}={}){let o=null,u=0;const i=u;let p=!1;const c=u;if(u===c)if("string"==typeof l){if(l.length<1){const n={params:{}};null===o?o=[n]:o.push(n),u++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var f=c===u;if(p=p||f,!p){const t=u;if(u===t)if(l&&"object"==typeof l&&!Array.isArray(l)){let t;if(void 0===l.banner&&(t="banner")){const n={params:{missingProperty:t}};null===o?o=[n]:o.push(n),u++}else{const t=u;for(const n in l)if("banner"!==n&&"entryOnly"!==n&&"exclude"!==n&&"footer"!==n&&"include"!==n&&"raw"!==n&&"test"!==n){const t={params:{additionalProperty:n}};null===o?o=[t]:o.push(t),u++;break}if(t===u){if(void 0!==l.banner){let n=l.banner;const t=u,e=u;let s=!1;const a=u;if("string"!=typeof n){const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var h=a===u;if(s=s||h,!s){const t=u;if(!(n instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}h=t===u,s=s||h}if(s)u=e,null!==o&&(e?o.length=e:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),u++}var y=t===u}else y=!0;if(y){if(void 0!==l.entryOnly){const n=u;if("boolean"!=typeof l.entryOnly){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}y=n===u}else y=!0;if(y){if(void 0!==l.exclude){const t=u,s=u;let a=!1,i=null;const p=u;if(n(l.exclude,{instancePath:e+"/exclude",parentData:l,parentDataProperty:"exclude",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}y=t===u}else y=!0;if(y){if(void 0!==l.footer){const n=u;if("boolean"!=typeof l.footer){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}y=n===u}else y=!0;if(y){if(void 0!==l.include){const t=u,s=u;let a=!1,i=null;const p=u;if(n(l.include,{instancePath:e+"/include",parentData:l,parentDataProperty:"include",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}y=t===u}else y=!0;if(y){if(void 0!==l.raw){const n=u;if("boolean"!=typeof l.raw){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}y=n===u}else y=!0;if(y)if(void 0!==l.test){const t=u,s=u;let a=!1,i=null;const p=u;if(n(l.test,{instancePath:e+"/test",parentData:l,parentDataProperty:"test",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}y=t===u}else y=!0}}}}}}}}else{const n={params:{type:"object"}};null===o?o=[n]:o.push(n),u++}if(f=t===u,p=p||f,!p){const n=u;if(!(l instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}f=n===u,p=p||f}}if(!p){const n={params:{}};return null===o?o=[n]:o.push(n),u++,t.errors=o,!1}return u=i,null!==o&&(i?o.length=i:o=null),t.errors=o,0===u}module.exports=t,module.exports.default=t;
"use strict";function n(t,{instancePath:e="",parentData:s,parentDataProperty:l,rootData:a=t}={}){let r=null,o=0;const u=o;let i=!1;const p=o;if(o===p)if(Array.isArray(t)){const n=t.length;for(let e=0;e<n;e++){let n=t[e];const s=o,l=o;let a=!1,u=null;const i=o,p=o;let f=!1;const h=o;if(!(n instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var c=h===o;if(f=f||c,!f){const t=o;if(o===t)if("string"==typeof n){if(n.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}c=t===o,f=f||c}if(f)o=p,null!==r&&(p?r.length=p:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}if(i===o&&(a=!0,u=0),a)o=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{passingSchemas:u}};null===r?r=[n]:r.push(n),o++}if(s!==o)break}}else{const n={params:{type:"array"}};null===r?r=[n]:r.push(n),o++}var f=p===o;if(i=i||f,!i){const n=o,e=o;let s=!1;const l=o;if(!(t instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var h=l===o;if(s=s||h,!s){const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}h=n===o,s=s||h}if(s)o=e,null!==r&&(e?r.length=e:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}f=n===o,i=i||f}if(!i){const t={params:{}};return null===r?r=[t]:r.push(t),o++,n.errors=r,!1}return o=u,null!==r&&(u?r.length=u:r=null),n.errors=r,0===o}function t(e,{instancePath:s="",parentData:l,parentDataProperty:a,rootData:r=e}={}){let o=null,u=0;const i=u;let p=!1;const c=u;if(u===c)if("string"==typeof e){if(e.length<1){const n={params:{}};null===o?o=[n]:o.push(n),u++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var f=c===u;if(p=p||f,!p){const t=u;if(u===t)if(e&&"object"==typeof e&&!Array.isArray(e)){let t;if(void 0===e.banner&&(t="banner")){const n={params:{missingProperty:t}};null===o?o=[n]:o.push(n),u++}else{const t=u;for(const n in e)if("banner"!==n&&"entryOnly"!==n&&"exclude"!==n&&"footer"!==n&&"include"!==n&&"raw"!==n&&"stage"!==n&&"test"!==n){const t={params:{additionalProperty:n}};null===o?o=[t]:o.push(t),u++;break}if(t===u){if(void 0!==e.banner){let n=e.banner;const t=u,s=u;let l=!1;const a=u;if("string"!=typeof n){const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var h=a===u;if(l=l||h,!l){const t=u;if(!(n instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}h=t===u,l=l||h}if(l)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),u++}var m=t===u}else m=!0;if(m){if(void 0!==e.entryOnly){const n=u;if("boolean"!=typeof e.entryOnly){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==e.exclude){const t=u,l=u;let a=!1,i=null;const p=u;if(n(e.exclude,{instancePath:s+"/exclude",parentData:e,parentDataProperty:"exclude",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==e.footer){const n=u;if("boolean"!=typeof e.footer){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==e.include){const t=u,l=u;let a=!1,i=null;const p=u;if(n(e.include,{instancePath:s+"/include",parentData:e,parentDataProperty:"include",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==e.raw){const n=u;if("boolean"!=typeof e.raw){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==e.stage){const n=u;if("number"!=typeof e.stage){const n={params:{type:"number"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m)if(void 0!==e.test){const t=u,l=u;let a=!1,i=null;const p=u;if(n(e.test,{instancePath:s+"/test",parentData:e,parentDataProperty:"test",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0}}}}}}}}}else{const n={params:{type:"object"}};null===o?o=[n]:o.push(n),u++}if(f=t===u,p=p||f,!p){const n=u;if(!(e instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}f=n===u,p=p||f}}if(!p){const n={params:{}};return null===o?o=[n]:o.push(n),u++,t.errors=o,!1}return u=i,null!==o&&(i?o.length=i:o=null),t.errors=o,0===u}module.exports=t,module.exports.default=t;

@@ -6,3 +6,3 @@ {

"instanceof": "Function",
"tsType": "(data: { hash: string, chunk: import('../../lib/Chunk'), filename: string }) => string"
"tsType": "(data: { hash?: string, chunk: import('../../lib/Chunk'), filename: string }) => string"
},

@@ -93,2 +93,6 @@ "Rule": {

},
"stage": {
"description": "Specifies the banner.",
"type": "number"
},
"test": {

@@ -95,0 +99,0 @@ "description": "Include all modules that pass test assertion.",

@@ -6,2 +6,2 @@ /*

*/
"use strict";function r(t,{instancePath:a="",parentData:e,parentDataProperty:o,rootData:n=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const a=0;for(const a in t)if("exportsOnly"!==a)return r.errors=[{params:{additionalProperty:a}}],!1;if(0===a&&void 0!==t.exportsOnly&&"boolean"!=typeof t.exportsOnly)return r.errors=[{params:{type:"boolean"}}],!1}return r.errors=null,!0}function t(a,{instancePath:e="",parentData:o,parentDataProperty:n,rootData:s=a}={}){let p=null,l=0;return r(a,{instancePath:e,parentData:o,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),l=p.length),t.errors=p,0===l}module.exports=t,module.exports.default=t;
"use strict";function t(r,{instancePath:e="",parentData:n,parentDataProperty:o,rootData:a=r}={}){let s=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return t.errors=[{params:{type:"object"}}],!1;{const e=l;for(const e in r)if("exportsConvention"!==e&&"exportsOnly"!==e&&"localIdentName"!==e)return t.errors=[{params:{additionalProperty:e}}],!1;if(e===l){if(void 0!==r.exportsConvention){let e=r.exportsConvention;const n=l,o=l;let a=!1;const c=l;if("as-is"!==e&&"camel-case"!==e&&"camel-case-only"!==e&&"dashes"!==e&&"dashes-only"!==e){const t={params:{}};null===s?s=[t]:s.push(t),l++}var i=c===l;if(a=a||i,!a){const t=l;if(!(e instanceof Function)){const t={params:{}};null===s?s=[t]:s.push(t),l++}i=t===l,a=a||i}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),l++,t.errors=s,!1}l=o,null!==s&&(o?s.length=o:s=null);var p=n===l}else p=!0;if(p){if(void 0!==r.exportsOnly){const e=l;if("boolean"!=typeof r.exportsOnly)return t.errors=[{params:{type:"boolean"}}],!1;p=e===l}else p=!0;if(p)if(void 0!==r.localIdentName){const e=l;if("string"!=typeof r.localIdentName)return t.errors=[{params:{type:"string"}}],!1;p=e===l}else p=!0}}}}return t.errors=s,0===l}function r(e,{instancePath:n="",parentData:o,parentDataProperty:a,rootData:s=e}={}){let l=null,i=0;return t(e,{instancePath:n,parentData:o,parentDataProperty:a,rootData:s})||(l=null===l?t.errors:l.concat(t.errors),i=l.length),r.errors=l,0===i}module.exports=r,module.exports.default=r;

@@ -6,2 +6,2 @@ /*

*/
"use strict";function r(t,{instancePath:a="",parentData:e,parentDataProperty:o,rootData:n=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const a=0;for(const a in t)if("exportsOnly"!==a)return r.errors=[{params:{additionalProperty:a}}],!1;if(0===a&&void 0!==t.exportsOnly&&"boolean"!=typeof t.exportsOnly)return r.errors=[{params:{type:"boolean"}}],!1}return r.errors=null,!0}function t(a,{instancePath:e="",parentData:o,parentDataProperty:n,rootData:s=a}={}){let p=null,l=0;return r(a,{instancePath:e,parentData:o,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),l=p.length),t.errors=p,0===l}module.exports=t,module.exports.default=t;
"use strict";function r(t,{instancePath:e="",parentData:n,parentDataProperty:o,rootData:a=t}={}){let s=null,l=0;if(0===l){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const e=l;for(const e in t)if("exportsConvention"!==e&&"exportsOnly"!==e)return r.errors=[{params:{additionalProperty:e}}],!1;if(e===l){if(void 0!==t.exportsConvention){let e=t.exportsConvention;const n=l,o=l;let a=!1;const c=l;if("as-is"!==e&&"camel-case"!==e&&"camel-case-only"!==e&&"dashes"!==e&&"dashes-only"!==e){const r={params:{}};null===s?s=[r]:s.push(r),l++}var p=c===l;if(a=a||p,!a){const r=l;if(!(e instanceof Function)){const r={params:{}};null===s?s=[r]:s.push(r),l++}p=r===l,a=a||p}if(!a){const t={params:{}};return null===s?s=[t]:s.push(t),l++,r.errors=s,!1}l=o,null!==s&&(o?s.length=o:s=null);var i=n===l}else i=!0;if(i)if(void 0!==t.exportsOnly){const e=l;if("boolean"!=typeof t.exportsOnly)return r.errors=[{params:{type:"boolean"}}],!1;i=e===l}else i=!0}}}return r.errors=s,0===l}function t(e,{instancePath:n="",parentData:o,parentDataProperty:a,rootData:s=e}={}){let l=null,p=0;return r(e,{instancePath:n,parentData:o,parentDataProperty:a,rootData:s})||(l=null===l?r.errors:l.concat(r.errors),p=l.length),t.errors=l,0===p}module.exports=t,module.exports.default=t;

@@ -6,2 +6,2 @@ /*

*/
"use strict";function r(t,{instancePath:a="",parentData:e,parentDataProperty:o,rootData:n=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const a=0;for(const a in t)if("exportsOnly"!==a)return r.errors=[{params:{additionalProperty:a}}],!1;if(0===a&&void 0!==t.exportsOnly&&"boolean"!=typeof t.exportsOnly)return r.errors=[{params:{type:"boolean"}}],!1}return r.errors=null,!0}function t(a,{instancePath:e="",parentData:o,parentDataProperty:n,rootData:s=a}={}){let p=null,l=0;return r(a,{instancePath:e,parentData:o,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),l=p.length),t.errors=p,0===l}module.exports=t,module.exports.default=t;
"use strict";function t(r,{instancePath:e="",parentData:n,parentDataProperty:o,rootData:a=r}={}){let s=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return t.errors=[{params:{type:"object"}}],!1;{const e=l;for(const e in r)if("exportsConvention"!==e&&"exportsOnly"!==e&&"localIdentName"!==e)return t.errors=[{params:{additionalProperty:e}}],!1;if(e===l){if(void 0!==r.exportsConvention){let e=r.exportsConvention;const n=l,o=l;let a=!1;const c=l;if("as-is"!==e&&"camel-case"!==e&&"camel-case-only"!==e&&"dashes"!==e&&"dashes-only"!==e){const t={params:{}};null===s?s=[t]:s.push(t),l++}var i=c===l;if(a=a||i,!a){const t=l;if(!(e instanceof Function)){const t={params:{}};null===s?s=[t]:s.push(t),l++}i=t===l,a=a||i}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),l++,t.errors=s,!1}l=o,null!==s&&(o?s.length=o:s=null);var p=n===l}else p=!0;if(p){if(void 0!==r.exportsOnly){const e=l;if("boolean"!=typeof r.exportsOnly)return t.errors=[{params:{type:"boolean"}}],!1;p=e===l}else p=!0;if(p)if(void 0!==r.localIdentName){const e=l;if("string"!=typeof r.localIdentName)return t.errors=[{params:{type:"string"}}],!1;p=e===l}else p=!0}}}}return t.errors=s,0===l}function r(e,{instancePath:n="",parentData:o,parentDataProperty:a,rootData:s=e}={}){let l=null,i=0;return t(e,{instancePath:n,parentData:o,parentDataProperty:a,rootData:s})||(l=null===l?t.errors:l.concat(t.errors),i=l.length),r.errors=l,0===i}module.exports=r,module.exports.default=r;

@@ -6,2 +6,2 @@ /*

*/
"use strict";function r(t,{instancePath:a="",parentData:e,parentDataProperty:o,rootData:n=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const a=0;for(const a in t)if("exportsOnly"!==a)return r.errors=[{params:{additionalProperty:a}}],!1;if(0===a&&void 0!==t.exportsOnly&&"boolean"!=typeof t.exportsOnly)return r.errors=[{params:{type:"boolean"}}],!1}return r.errors=null,!0}function t(a,{instancePath:e="",parentData:o,parentDataProperty:n,rootData:s=a}={}){let p=null,l=0;return r(a,{instancePath:e,parentData:o,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),l=p.length),t.errors=p,0===l}module.exports=t,module.exports.default=t;
"use strict";function t(r,{instancePath:e="",parentData:n,parentDataProperty:o,rootData:a=r}={}){let s=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return t.errors=[{params:{type:"object"}}],!1;{const e=l;for(const e in r)if("exportsConvention"!==e&&"exportsOnly"!==e&&"localIdentName"!==e)return t.errors=[{params:{additionalProperty:e}}],!1;if(e===l){if(void 0!==r.exportsConvention){let e=r.exportsConvention;const n=l,o=l;let a=!1;const c=l;if("as-is"!==e&&"camel-case"!==e&&"camel-case-only"!==e&&"dashes"!==e&&"dashes-only"!==e){const t={params:{}};null===s?s=[t]:s.push(t),l++}var i=c===l;if(a=a||i,!a){const t=l;if(!(e instanceof Function)){const t={params:{}};null===s?s=[t]:s.push(t),l++}i=t===l,a=a||i}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),l++,t.errors=s,!1}l=o,null!==s&&(o?s.length=o:s=null);var p=n===l}else p=!0;if(p){if(void 0!==r.exportsOnly){const e=l;if("boolean"!=typeof r.exportsOnly)return t.errors=[{params:{type:"boolean"}}],!1;p=e===l}else p=!0;if(p)if(void 0!==r.localIdentName){const e=l;if("string"!=typeof r.localIdentName)return t.errors=[{params:{type:"string"}}],!1;p=e===l}else p=!0}}}}return t.errors=s,0===l}function r(e,{instancePath:n="",parentData:o,parentDataProperty:a,rootData:s=e}={}){let l=null,i=0;return t(e,{instancePath:n,parentData:o,parentDataProperty:a,rootData:s})||(l=null===l?t.errors:l.concat(t.errors),i=l.length),r.errors=l,0===i}module.exports=r,module.exports.default=r;

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc