| | |
| | | /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */ |
| | | |
| | | /** |
| | | * Defines the queue item type used by this module. |
| | | * @typedef {object} QueueItem |
| | | * @property {number} action |
| | | * @property {DependenciesBlock} block |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Defines the chunk group info type used by this module. |
| | | * @typedef {object} ChunkGroupInfo |
| | | * @property {ChunkGroup} chunkGroup the chunk group |
| | | * @property {RuntimeSpec} runtime the runtimes |
| | |
| | | * @property {number} postOrderIndex next post order index |
| | | * @property {boolean} chunkLoading has a chunk loading mechanism |
| | | * @property {boolean} asyncChunks create async chunks |
| | | * @property {Module | null} depModule the module that is the dependency of the block |
| | | * @property {boolean} circular Whether to deduplicate to avoid circular references |
| | | */ |
| | | |
| | | /** |
| | | * Defines the block chunk group connection type used by this module. |
| | | * @typedef {object} BlockChunkGroupConnection |
| | | * @property {ChunkGroupInfo} originChunkGroupInfo origin chunk group |
| | | * @property {ChunkGroup} chunkGroup referenced chunk group |
| | |
| | | const ONE_BIGINT = BigInt(1); |
| | | |
| | | /** |
| | | * Checks whether this object is ordinal set in mask. |
| | | * @param {bigint} mask The mask to test |
| | | * @param {number} ordinal The ordinal of the bit to test |
| | | * @returns {boolean} If the ordinal-th bit is set in the mask |
| | |
| | | BigInt.asUintN(1, mask >> BigInt(ordinal)) !== ZERO_BIGINT; |
| | | |
| | | /** |
| | | * Gets active state of connections. |
| | | * @param {ModuleGraphConnection[]} connections list of connections |
| | | * @param {RuntimeSpec} runtime for which runtime |
| | | * @returns {ConnectionState} connection state |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Extract block modules. |
| | | * @param {Module} module module |
| | | * @param {ModuleGraph} moduleGraph module graph |
| | | * @param {RuntimeSpec} runtime runtime |
| | |
| | | |
| | | for (const modules of arrays) { |
| | | if (modules.length === 0) continue; |
| | | /** @type {undefined | Map<Module | ModuleGraphConnection | ConnectionState, number>} */ |
| | | let indexMap; |
| | | let length = 0; |
| | | outer: for (let j = 0; j < modules.length; j += 3) { |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Processes the provided logger. |
| | | * @param {Logger} logger a logger |
| | | * @param {Compilation} compilation the compilation |
| | | * @param {InputEntrypointsAndModules} inputEntrypointsAndModules chunk groups which are processed with the modules |
| | |
| | | const ordinalByModule = new Map(); |
| | | |
| | | /** |
| | | * Gets module ordinal. |
| | | * @param {Module} module The module to look up |
| | | * @returns {number} The ordinal of the module in masks |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets block modules. |
| | | * @param {DependenciesBlock} block block |
| | | * @param {RuntimeSpec} runtime runtime |
| | | * @returns {BlockModulesInFlattenTuples | undefined} block modules in flatten tuples |
| | |
| | | /** @type {Map<ChunkGroupInfo, Set<DependenciesBlock>>} */ |
| | | const blocksByChunkGroups = new Map(); |
| | | |
| | | /** @type {Map<string, ChunkGroupInfo>} */ |
| | | /** @typedef {Map<string, ChunkGroupInfo>} NamedChunkGroup */ |
| | | |
| | | /** @type {NamedChunkGroup} */ |
| | | const namedChunkGroups = new Map(); |
| | | |
| | | /** @type {Map<string, ChunkGroupInfo>} */ |
| | | /** @type {NamedChunkGroup} */ |
| | | const namedAsyncEntrypoints = new Map(); |
| | | |
| | | /** @type {Map<Module, ChunkGroupInfo>} */ |
| | | const depModuleAsyncEntrypoints = new Map(); |
| | | |
| | | /** @type {Set<ChunkGroupInfo>} */ |
| | | const outdatedOrderIndexChunkGroups = new Set(); |
| | |
| | | /** @type {QueueItem[]} */ |
| | | let queue = []; |
| | | |
| | | /** @type {Map<ChunkGroupInfo, Set<[ChunkGroupInfo, QueueItem | null]>>} */ |
| | | /** @typedef {Set<[ChunkGroupInfo, QueueItem | null]>} ConnectList */ |
| | | /** @type {Map<ChunkGroupInfo, ConnectList>} */ |
| | | const queueConnect = new Map(); |
| | | /** @type {Set<ChunkGroupInfo>} */ |
| | | const chunkGroupsForCombining = new Set(); |
| | |
| | | ); |
| | | /** @type {ChunkGroupInfo} */ |
| | | const chunkGroupInfo = { |
| | | depModule: null, |
| | | circular: false, |
| | | initialized: false, |
| | | chunkGroup, |
| | | runtime, |
| | |
| | | |
| | | // For each async Block in graph |
| | | /** |
| | | * Processes the provided b. |
| | | * @param {AsyncDependenciesBlock} b iterating over each Async DepBlock |
| | | * @returns {void} |
| | | */ |
| | |
| | | let c; |
| | | /** @type {Entrypoint | undefined} */ |
| | | let entrypoint; |
| | | /** @type {Module | null} */ |
| | | const depModule = moduleGraph.getModule(b.dependencies[0]); |
| | | const entryOptions = b.groupOptions && b.groupOptions.entryOptions; |
| | | if (cgi === undefined) { |
| | | const chunkName = (b.groupOptions && b.groupOptions.name) || b.chunkName; |
| | | if (entryOptions) { |
| | | cgi = namedAsyncEntrypoints.get(/** @type {string} */ (chunkName)); |
| | | if (!cgi && !b.circular && depModule) { |
| | | cgi = depModuleAsyncEntrypoints.get(depModule); |
| | | } |
| | | if (!cgi) { |
| | | entrypoint = compilation.addAsyncEntrypoint( |
| | | entryOptions, |
| | |
| | | maskByChunk.set(entrypoint.chunks[0], ZERO_BIGINT); |
| | | entrypoint.index = nextChunkGroupIndex++; |
| | | cgi = { |
| | | depModule, |
| | | circular: b.circular, |
| | | chunkGroup: entrypoint, |
| | | initialized: false, |
| | | runtime: |
| | |
| | | chunkName, |
| | | /** @type {ChunkGroupInfo} */ |
| | | (cgi) |
| | | ); |
| | | } |
| | | if (!b.circular && depModule) { |
| | | depModuleAsyncEntrypoints.set( |
| | | depModule, |
| | | /** @type {ChunkGroupInfo} */ (cgi) |
| | | ); |
| | | } |
| | | } else { |
| | |
| | | maskByChunk.set(c.chunks[0], ZERO_BIGINT); |
| | | c.index = nextChunkGroupIndex++; |
| | | cgi = { |
| | | depModule, |
| | | circular: b.circular, |
| | | initialized: false, |
| | | chunkGroup: c, |
| | | runtime: chunkGroupInfo.runtime, |
| | |
| | | // 3. We enqueue the chunk group info creation/updating |
| | | let connectList = queueConnect.get(chunkGroupInfo); |
| | | if (connectList === undefined) { |
| | | /** @type {ConnectList} */ |
| | | connectList = new Set(); |
| | | queueConnect.set(chunkGroupInfo, connectList); |
| | | } |
| | |
| | | chunkGroupInfo: /** @type {ChunkGroupInfo} */ (cgi) |
| | | } |
| | | ]); |
| | | } else if (entrypoint !== undefined) { |
| | | } else if ( |
| | | entrypoint !== undefined && |
| | | (chunkGroupInfo.circular || chunkGroupInfo.depModule !== depModule) |
| | | ) { |
| | | chunkGroupInfo.chunkGroup.addAsyncEntrypoint(entrypoint); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * Processes the provided block. |
| | | * @param {DependenciesBlock} block the block |
| | | * @returns {void} |
| | | */ |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Process entry block. |
| | | * @param {DependenciesBlock} block the block |
| | | * @returns {void} |
| | | */ |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Calculate resulting available modules. |
| | | * @param {ChunkGroupInfo} chunkGroupInfo The info object for the chunk group |
| | | * @returns {bigint} The mask of available modules after the chunk group |
| | | */ |
| | |
| | | for (const cgi of info.children) { |
| | | let connectList = queueConnect.get(info); |
| | | if (connectList === undefined) { |
| | | /** @type {ConnectList} */ |
| | | connectList = new Set(); |
| | | queueConnect.set(info, connectList); |
| | | } |
| | |
| | | let preOrderIndex = 0; |
| | | let postOrderIndex = 0; |
| | | /** |
| | | * Processes the provided current. |
| | | * @param {DependenciesBlock} current current |
| | | * @param {BlocksWithNestedBlocks} visited visited dependencies blocks |
| | | */ |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Connects chunk groups. |
| | | * @param {Compilation} compilation the compilation |
| | | * @param {BlocksWithNestedBlocks} blocksWithNestedBlocks flag for blocks that have nested blocks |
| | | * @param {BlockConnections} blockConnections connection for blocks |