| | |
| | | /** @typedef {import("./Chunk").Entrypoints} Entrypoints */ |
| | | /** @typedef {import("./Chunk").ChunkId} ChunkId */ |
| | | /** @typedef {import("./ChunkGroup")} ChunkGroup */ |
| | | /** @typedef {import("./Generator").SourceTypes} SourceTypes */ |
| | | /** @typedef {import("./Module")} Module */ |
| | | /** @typedef {import("./Module").SourceType} SourceType */ |
| | | /** @typedef {import("./Module").SourceTypes} SourceTypes */ |
| | | /** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */ |
| | | /** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */ |
| | | /** @typedef {import("./ModuleGraph")} ModuleGraph */ |
| | | /** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */ |
| | | /** @typedef {import("./RuntimeModule")} RuntimeModule */ |
| | | /** @typedef {typeof import("./util/Hash")} Hash */ |
| | | /** @typedef {import("./util/Hash").HashFunction} HashFunction */ |
| | | /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */ |
| | | |
| | | /** @type {ReadonlySet<string>} */ |
| | |
| | | /** @typedef {[Module, Entrypoint | undefined]} EntryModuleWithChunkGroup */ |
| | | |
| | | /** |
| | | * Represents the module hash info runtime component. |
| | | * @typedef {object} ChunkSizeOptions |
| | | * @property {number=} chunkOverhead constant overhead for a chunk |
| | | * @property {number=} entryChunkMultiplicator multiplicator for initial chunks |
| | |
| | | |
| | | class ModuleHashInfo { |
| | | /** |
| | | * Creates an instance of ModuleHashInfo. |
| | | * @param {string} hash hash |
| | | * @param {string} renderedHash rendered hash |
| | | */ |
| | | constructor(hash, renderedHash) { |
| | | /** @type {string} */ |
| | | this.hash = hash; |
| | | /** @type {string} */ |
| | | this.renderedHash = renderedHash; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns set as array. |
| | | * @template T |
| | | * @param {SortableSet<T>} set the set |
| | | * @returns {T[]} set as array |
| | |
| | | const getArray = (set) => [...set]; |
| | | |
| | | /** |
| | | * Gets module runtimes. |
| | | * @param {SortableChunks} chunks the chunks |
| | | * @returns {RuntimeSpecSet} runtimes |
| | | */ |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Modules by source type. |
| | | * @param {SourceTypesByModule | undefined} sourceTypesByModule sourceTypesByModule |
| | | * @returns {(set: SortableSet<Module>) => Map<string, SortableSet<Module>>} modules by source type |
| | | * @returns {ModulesBySourceType} modules by source type |
| | | */ |
| | | const modulesBySourceType = (sourceTypesByModule) => (set) => { |
| | | /** @type {Map<string, SortableSet<Module>>} */ |
| | | /** @typedef {SortableSet<Module>} ModuleSortableSet */ |
| | | /** @type {Map<SourceType, ModuleSortableSet>} */ |
| | | const map = new Map(); |
| | | for (const module of set) { |
| | | const sourceTypes = |
| | |
| | | for (const sourceType of sourceTypes) { |
| | | let innerSet = map.get(sourceType); |
| | | if (innerSet === undefined) { |
| | | /** @type {ModuleSortableSet} */ |
| | | innerSet = new SortableSet(); |
| | | map.set(sourceType, innerSet); |
| | | } |
| | |
| | | } |
| | | return map; |
| | | }; |
| | | |
| | | /** @typedef {(set: SortableSet<Module>) => Map<string, SortableSet<Module>>} ModulesBySourceType */ |
| | | |
| | | /** @type {ModulesBySourceType} */ |
| | | const defaultModulesBySourceType = modulesBySourceType(undefined); |
| | | |
| | | /** |
| | | * Defines the module set to array function type used by this module. |
| | | * @typedef {(set: SortableSet<Module>) => Module[]} ModuleSetToArrayFunction |
| | | */ |
| | | |
| | |
| | | const createOrderedArrayFunctionMap = new WeakMap(); |
| | | |
| | | /** |
| | | * Creates an ordered array function. |
| | | * @template T |
| | | * @param {ModuleComparator} comparator comparator function |
| | | * @returns {ModuleSetToArrayFunction} set as ordered array |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns the size of the modules. |
| | | * @param {Iterable<Module>} modules the modules to get the count/size of |
| | | * @returns {number} the size of the modules |
| | | */ |
| | |
| | | return size; |
| | | }; |
| | | |
| | | /** @typedef {Record<string, number>} SizesOfModules */ |
| | | |
| | | /** |
| | | * Gets modules sizes. |
| | | * @param {Iterable<Module>} modules the sortable Set to get the size of |
| | | * @returns {Record<string, number>} the sizes of the modules |
| | | * @returns {SizesOfModules} the sizes of the modules |
| | | */ |
| | | const getModulesSizes = (modules) => { |
| | | /** @type {SizesOfModules} */ |
| | | const sizes = Object.create(null); |
| | | for (const module of modules) { |
| | | for (const type of module.getSourceTypes()) { |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Checks whether this module hash info is available chunk. |
| | | * @param {Chunk} a chunk |
| | | * @param {Chunk} b chunk |
| | | * @returns {boolean} true, if a is always a parent of b |
| | |
| | | /** @typedef {Set<Chunk>} EntryInChunks */ |
| | | /** @typedef {Set<Chunk>} RuntimeInChunks */ |
| | | /** @typedef {string | number} ModuleId */ |
| | | /** @typedef {RuntimeSpecMap<Set<string>, RuntimeRequirements>} ChunkGraphRuntimeRequirements */ |
| | | |
| | | class ChunkGraphModule { |
| | | constructor() { |
| | |
| | | this.hashes = undefined; |
| | | /** @type {ModuleId | null} */ |
| | | this.id = null; |
| | | /** @type {RuntimeSpecMap<Set<string>, RuntimeRequirements> | undefined} */ |
| | | /** @type {ChunkGraphRuntimeRequirements | undefined} */ |
| | | this.runtimeRequirements = undefined; |
| | | /** @type {RuntimeSpecMap<string, bigint> | undefined} */ |
| | | this.graphHashes = undefined; |
| | |
| | | } |
| | | } |
| | | |
| | | /** @typedef {WeakMap<Module, Set<string>>} SourceTypesByModule */ |
| | | /** @typedef {WeakMap<Module, SourceTypes>} SourceTypesByModule */ |
| | | /** @typedef {Map<Module, Entrypoint>} EntryModules */ |
| | | |
| | | class ChunkGraphChunk { |
| | |
| | | this.runtimeRequirements = undefined; |
| | | /** @type {Set<string>} */ |
| | | this.runtimeRequirementsInTree = new Set(); |
| | | |
| | | /** @type {ModulesBySourceType} */ |
| | | this._modulesBySourceType = defaultModulesBySourceType; |
| | | } |
| | | } |
| | |
| | | /** @typedef {Record<ModuleId, string>} IdToHashMap */ |
| | | /** @typedef {Record<ChunkId, IdToHashMap>} ChunkModuleHashMap */ |
| | | /** @typedef {Record<ChunkId, ModuleId[]>} ChunkModuleIdMap */ |
| | | /** @typedef {Record<ChunkId, boolean>} ChunkConditionMap */ |
| | | |
| | | /** @typedef {(a: Module, b: Module) => -1 | 0 | 1} ModuleComparator */ |
| | | |
| | | class ChunkGraph { |
| | | /** |
| | | * Creates an instance of ChunkGraph. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @param {string | Hash} hashFunction the hash function to use |
| | | * @param {HashFunction} hashFunction the hash function to use |
| | | */ |
| | | constructor(moduleGraph, hashFunction = DEFAULTS.HASH_FUNCTION) { |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get chunk graph module. |
| | | * @private |
| | | * @param {Module} module the module |
| | | * @returns {ChunkGraphModule} internal module |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get chunk graph chunk. |
| | | * @private |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {ChunkGraphChunk} internal chunk |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the graph roots. |
| | | * @param {SortableSet<Module>} set the sortable Set to get the roots of |
| | | * @returns {Module[]} the graph roots |
| | | */ |
| | |
| | | /** @type {Set<Module>} */ |
| | | const set = new Set(); |
| | | /** |
| | | * Adds the provided module to the chunk graph. |
| | | * @param {Module} module module |
| | | */ |
| | | const addDependencies = (module) => { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Connects chunk and module. |
| | | * @param {Chunk} chunk the new chunk |
| | | * @param {Module} module the module |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Disconnects chunk and module. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {Module} module the module |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided chunk. |
| | | * @param {Chunk} chunk the chunk which will be disconnected |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided chunk. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {Iterable<Module>} modules the modules |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Attach runtime modules. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {Iterable<RuntimeModule>} modules the runtime modules |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Attach full hash modules. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {Iterable<RuntimeModule>} modules the modules that require a full hash |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Attach dependent hash modules. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {Iterable<RuntimeModule>} modules the modules that require a full hash |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided old module. |
| | | * @param {Module} oldModule the replaced module |
| | | * @param {Module} newModule the replacing module |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this chunk graph is module in chunk. |
| | | * @param {Module} module the checked module |
| | | * @param {Chunk} chunk the checked chunk |
| | | * @returns {boolean} true, if the chunk contains the module |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this chunk graph is module in chunk group. |
| | | * @param {Module} module the checked module |
| | | * @param {ChunkGroup} chunkGroup the checked chunk group |
| | | * @returns {boolean} true, if the chunk contains the module |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this chunk graph is entry module. |
| | | * @param {Module} module the checked module |
| | | * @returns {boolean} true, if the module is entry of any chunk |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets module chunks iterable. |
| | | * @param {Module} module the module |
| | | * @returns {Iterable<Chunk>} iterable of chunks (do not modify) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets ordered module chunks iterable. |
| | | * @param {Module} module the module |
| | | * @param {(a: Chunk, b: Chunk) => -1 | 0 | 1} sortFn sort function |
| | | * @returns {Iterable<Chunk>} iterable of chunks (do not modify) |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets module chunks. |
| | | * @param {Module} module the module |
| | | * @returns {Chunk[]} array of chunks (cached, do not modify) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets number of module chunks. |
| | | * @param {Module} module the module |
| | | * @returns {number} the number of chunk which contain the module |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets module runtimes. |
| | | * @param {Module} module the module |
| | | * @returns {RuntimeSpecSet} runtimes |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets number of chunk modules. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {number} the number of modules which are contained in this chunk |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets number of chunk full hash modules. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {number} the number of full hash modules which are contained in this chunk |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk modules iterable. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {Iterable<Module>} return the modules for this chunk |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk modules iterable by source type. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {string} sourceType source type |
| | | * @returns {Iterable<Module> | undefined} return the modules for this chunk |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets chunk module source types. |
| | | * @param {Chunk} chunk chunk |
| | | * @param {Module} module chunk module |
| | | * @param {Set<string>} sourceTypes source types |
| | | * @param {SourceTypes} sourceTypes source types |
| | | */ |
| | | setChunkModuleSourceTypes(chunk, module, sourceTypes) { |
| | | const cgc = this._getChunkGraphChunk(chunk); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk module source types. |
| | | * @param {Chunk} chunk chunk |
| | | * @param {Module} module chunk module |
| | | * @returns {SourceTypes} source types |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets module source types. |
| | | * @param {Module} module module |
| | | * @returns {SourceTypes} source types |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get overwritten module source types. |
| | | * @param {Module} module module |
| | | * @returns {Set<string> | undefined} source types |
| | | * @returns {SourceTypes | undefined} source types |
| | | */ |
| | | _getOverwrittenModuleSourceTypes(module) { |
| | | let newSet = false; |
| | | /** @type {Set<SourceType> | undefined} */ |
| | | let sourceTypes; |
| | | for (const chunk of this.getModuleChunksIterable(module)) { |
| | | const cgc = this._getChunkGraphChunk(chunk); |
| | |
| | | const st = cgc.sourceTypesByModule.get(module); |
| | | if (st === undefined) return; |
| | | if (!sourceTypes) { |
| | | sourceTypes = st; |
| | | sourceTypes = /** @type {Set<SourceType>} */ (st); |
| | | } else if (!newSet) { |
| | | for (const type of st) { |
| | | if (!newSet) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets ordered chunk modules iterable. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {ModuleComparator} comparator comparator function |
| | | * @returns {Iterable<Module>} return the modules for this chunk |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets ordered chunk modules iterable by source type. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {string} sourceType source type |
| | | * @param {ModuleComparator} comparator comparator function |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk modules. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {Module[]} return the modules for this chunk (cached, do not modify) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets ordered chunk modules. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {ModuleComparator} comparator comparator function |
| | | * @returns {Module[]} return the modules for this chunk (cached, do not modify) |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk module id map. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {ModuleFilterPredicate} filterFn function used to filter modules |
| | | * @param {boolean} includeAllChunks all chunks or only async chunks |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk module rendered hash map. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {ModuleFilterPredicate} filterFn function used to filter modules |
| | | * @param {number} hashLength length of the hash |
| | |
| | | )) { |
| | | if (filterFn(module)) { |
| | | if (idToHashMap === undefined) { |
| | | /** @type {IdToHashMap} */ |
| | | idToHashMap = Object.create(null); |
| | | chunkModuleHashMap[/** @type {ChunkId} */ (asyncChunk.id)] = |
| | | /** @type {IdToHashMap} */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk condition map. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {ChunkFilterPredicate} filterFn function used to filter chunks |
| | | * @returns {Record<ChunkId, boolean>} chunk map |
| | | * @returns {ChunkConditionMap} chunk condition map |
| | | */ |
| | | getChunkConditionMap(chunk, filterFn) { |
| | | /** @type {ChunkConditionMap} */ |
| | | const map = Object.create(null); |
| | | for (const c of chunk.getAllReferencedChunks()) { |
| | | map[/** @type {ChunkId} */ (c.id)] = filterFn(c, this); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this chunk graph contains the chunk. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {ModuleFilterPredicate} filterFn predicate function used to filter modules |
| | | * @param {ChunkFilterPredicate=} filterChunkFn predicate function used to filter chunks |
| | |
| | | */ |
| | | hasModuleInGraph(chunk, filterFn, filterChunkFn) { |
| | | const queue = new Set(chunk.groupsIterable); |
| | | /** @type {Set<Chunk>} */ |
| | | const chunksProcessed = new Set(); |
| | | |
| | | for (const chunkGroup of queue) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Compares the provided values and returns their ordering. |
| | | * @param {Chunk} chunkA first chunk |
| | | * @param {Chunk} chunkB second chunk |
| | | * @returns {-1|0|1} this is a comparator function like sort and returns -1, 0, or 1 based on sort order |
| | | * @returns {-1 | 0 | 1} this is a comparator function like sort and returns -1, 0, or 1 based on sort order |
| | | */ |
| | | compareChunks(chunkA, chunkB) { |
| | | const cgcA = this._getChunkGraphChunk(chunkA); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk modules size. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {number} total size of all modules in the chunk |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk modules sizes. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {Record<string, number>} total sizes of all modules in the chunk by source type |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk root modules. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {Module[]} root modules of the chunks (ordered by identifier) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns total size of the chunk. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {ChunkSizeOptions} options options object |
| | | * @returns {number} total size of the chunk |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets integrated chunks size. |
| | | * @param {Chunk} chunkA chunk |
| | | * @param {Chunk} chunkB chunk |
| | | * @param {ChunkSizeOptions} options options object |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether it can chunks be integrated. |
| | | * @param {Chunk} chunkA chunk |
| | | * @param {Chunk} chunkB chunk |
| | | * @returns {boolean} true, if chunks could be integrated |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided chunk a. |
| | | * @param {Chunk} chunkA the target chunk |
| | | * @param {Chunk} chunkB the chunk to integrate |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Upgrade dependent to full hash modules. |
| | | * @param {Chunk} chunk the chunk to upgrade |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this chunk graph is entry module in chunk. |
| | | * @param {Module} module the checked module |
| | | * @param {Chunk} chunk the checked chunk |
| | | * @returns {boolean} true, if the chunk contains the module as entry |
| | |
| | | } |
| | | |
| | | /** |
| | | * Connects chunk and entry module. |
| | | * @param {Chunk} chunk the new chunk |
| | | * @param {Module} module the entry module |
| | | * @param {Entrypoint} entrypoint the chunk group which must be loaded before the module is executed |
| | |
| | | } |
| | | |
| | | /** |
| | | * Connects chunk and runtime module. |
| | | * @param {Chunk} chunk the new chunk |
| | | * @param {RuntimeModule} module the runtime module |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds full hash module to chunk. |
| | | * @param {Chunk} chunk the new chunk |
| | | * @param {RuntimeModule} module the module that require a full hash |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds dependent hash module to chunk. |
| | | * @param {Chunk} chunk the new chunk |
| | | * @param {RuntimeModule} module the module that require a full hash |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Disconnects chunk and entry module. |
| | | * @param {Chunk} chunk the new chunk |
| | | * @param {Module} module the entry module |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Disconnects chunk and runtime module. |
| | | * @param {Chunk} chunk the new chunk |
| | | * @param {RuntimeModule} module the runtime module |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Disconnects entry module. |
| | | * @param {Module} module the entry module, it will no longer be entry |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Disconnects entries. |
| | | * @param {Chunk} chunk the chunk, for which all entries will be removed |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets number of entry modules. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {number} the amount of entry modules in chunk |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets number of runtime modules. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {number} the amount of entry modules in chunk |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk entry modules iterable. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {Iterable<Module>} iterable of modules (do not modify) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk entry dependent chunks iterable. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {Iterable<Chunk>} iterable of chunks |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets runtime chunk dependent chunks iterable. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {Iterable<Chunk>} iterable of chunks and include chunks from children entrypoints |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this chunk graph contains the chunk. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {boolean} true, when it has dependent chunks |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk runtime modules iterable. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {Iterable<RuntimeModule>} iterable of modules (do not modify) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk runtime modules in order. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {RuntimeModule[]} array of modules in order of execution |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk full hash modules iterable. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {Iterable<RuntimeModule> | undefined} iterable of modules (do not modify) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk full hash modules set. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {ReadonlySet<RuntimeModule> | undefined} set of modules (do not modify) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk dependent hash modules iterable. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {Iterable<RuntimeModule> | undefined} iterable of modules (do not modify) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk entry modules with chunk group iterable. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {Iterable<EntryModuleWithChunkGroup>} iterable of modules (do not modify) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets block chunk group. |
| | | * @param {AsyncDependenciesBlock} depBlock the async block |
| | | * @returns {ChunkGroup | undefined} the chunk group |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Connects block and chunk group. |
| | | * @param {AsyncDependenciesBlock} depBlock the async block |
| | | * @param {ChunkGroup} chunkGroup the chunk group |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Disconnects chunk group. |
| | | * @param {ChunkGroup} chunkGroup the chunk group |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the id of the module. |
| | | * @param {Module} module the module |
| | | * @returns {ModuleId | null} the id of the module |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates module id using the provided module. |
| | | * @param {Module} module the module |
| | | * @param {ModuleId} id the id of the module |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the id of the runtime. |
| | | * @param {string} runtime runtime |
| | | * @returns {RuntimeId} the id of the runtime |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates runtime id using the provided runtime. |
| | | * @param {string} runtime runtime |
| | | * @param {RuntimeId} id the id of the runtime |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get module hash info. |
| | | * @template T |
| | | * @param {Module} module the module |
| | | * @param {RuntimeSpecMap<T>} hashes hashes data |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this chunk graph contains the module. |
| | | * @param {Module} module the module |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {boolean} true, if the module has hashes for this runtime |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns hash. |
| | | * @param {Module} module the module |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {string} hash |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets rendered module hash. |
| | | * @param {Module} module the module |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {string} hash |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets module hashes. |
| | | * @param {Module} module the module |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @param {string} hash the full hash |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds module runtime requirements. |
| | | * @param {Module} module the module |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @param {RuntimeRequirements} items runtime requirements to be added (ownership of this Set is given to ChunkGraph when transferOwnership not false) |
| | |
| | | const cgm = this._getChunkGraphModule(module); |
| | | const runtimeRequirementsMap = cgm.runtimeRequirements; |
| | | if (runtimeRequirementsMap === undefined) { |
| | | /** @type {ChunkGraphRuntimeRequirements} */ |
| | | const map = new RuntimeSpecMap(); |
| | | // TODO avoid cloning item and track ownership instead |
| | | map.set(runtime, transferOwnership ? items : new Set(items)); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds chunk runtime requirements. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {RuntimeRequirements} items runtime requirements to be added (ownership of this Set is given to ChunkGraph) |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds tree runtime requirements. |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {Iterable<string>} items runtime requirements to be added |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets module runtime requirements. |
| | | * @param {Module} module the module |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {ReadOnlyRuntimeRequirements} runtime requirements |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets chunk runtime requirements. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {ReadOnlyRuntimeRequirements} runtime requirements |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets module graph hash. |
| | | * @param {Module} module the module |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @param {boolean} withConnections include connections |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets module graph hash big int. |
| | | * @param {Module} module the module |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @param {boolean} withConnections include connections |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get module graph hash big int. |
| | | * @param {ChunkGraphModule} cgm the ChunkGraphModule |
| | | * @param {Module} module the module |
| | | * @param {RuntimeSpec} runtime the runtime |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get module graph hash with connections. |
| | | * @param {ChunkGraphModule} cgm the ChunkGraphModule |
| | | * @param {Module} module the module |
| | | * @param {RuntimeSpec} runtime the runtime |
| | |
| | | } |
| | | |
| | | /** |
| | | * Active state to string. |
| | | * @param {ConnectionState} state state |
| | | * @returns {"F" | "T" | "O"} result |
| | | */ |
| | |
| | | /** @type {Map<string, Module | Set<Module>>} */ |
| | | const connectedModules = new Map(); |
| | | /** |
| | | * Process connection. |
| | | * @param {ModuleGraphConnection} connection connection |
| | | * @param {string} stateInfo state info |
| | | */ |
| | |
| | | } else { |
| | | // cspell:word Tnamespace |
| | | for (const connection of connections) { |
| | | /** @type {Set<ConnectionState>} */ |
| | | const states = new Set(); |
| | | let stateInfo = ""; |
| | | forEachRuntime( |
| | |
| | | if (states.size === 1) { |
| | | const state = first(states); |
| | | if (state === false) continue; |
| | | stateInfo = activeStateToString(state); |
| | | stateInfo = activeStateToString( |
| | | /** @type {ConnectionState} */ |
| | | (state) |
| | | ); |
| | | } |
| | | processConnection(connection, stateInfo); |
| | | } |
| | |
| | | : connectedModules; |
| | | const hash = createHash(this._hashFunction); |
| | | /** |
| | | * Adds module to hash. |
| | | * @param {Module} module module |
| | | */ |
| | | const addModuleToHash = (module) => { |
| | |
| | | ); |
| | | }; |
| | | /** |
| | | * Adds modules to hash. |
| | | * @param {Set<Module>} modules modules |
| | | */ |
| | | const addModulesToHash = (modules) => { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets tree runtime requirements. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {ReadOnlyRuntimeRequirements} runtime requirements |
| | | */ |
| | |
| | | |
| | | // TODO remove in webpack 6 |
| | | /** |
| | | * Gets chunk graph for module. |
| | | * @deprecated |
| | | * @param {Module} module the module |
| | | * @param {string} deprecateMessage message for the deprecation message |
| | | * @param {string} deprecationCode code for the deprecation |
| | |
| | | if (fn) return fn(module); |
| | | const newFn = util.deprecate( |
| | | /** |
| | | * Handles the callback logic for this hook. |
| | | * @param {Module} module the module |
| | | * @returns {ChunkGraph} the chunk graph |
| | | */ |
| | |
| | | } |
| | | |
| | | // TODO remove in webpack 6 |
| | | // BACKWARD-COMPAT START |
| | | /** |
| | | * Sets chunk graph for module. |
| | | * @deprecated |
| | | * @param {Module} module the module |
| | | * @param {ChunkGraph} chunkGraph the chunk graph |
| | | * @returns {void} |
| | |
| | | chunkGraphForModuleMap.set(module, chunkGraph); |
| | | } |
| | | |
| | | // TODO remove in webpack 6 |
| | | /** |
| | | * Clear chunk graph for module. |
| | | * @deprecated |
| | | * @param {Module} module the module |
| | | * @returns {void} |
| | | */ |
| | |
| | | chunkGraphForModuleMap.delete(module); |
| | | } |
| | | |
| | | // TODO remove in webpack 6 |
| | | /** |
| | | * Gets chunk graph for chunk. |
| | | * @deprecated |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {string} deprecateMessage message for the deprecation message |
| | | * @param {string} deprecationCode code for the deprecation |
| | |
| | | if (fn) return fn(chunk); |
| | | const newFn = util.deprecate( |
| | | /** |
| | | * Handles the callback logic for this hook. |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {ChunkGraph} the chunk graph |
| | | */ |
| | |
| | | return newFn(chunk); |
| | | } |
| | | |
| | | // TODO remove in webpack 6 |
| | | /** |
| | | * Sets chunk graph for chunk. |
| | | * @deprecated |
| | | * @param {Chunk} chunk the chunk |
| | | * @param {ChunkGraph} chunkGraph the chunk graph |
| | | * @returns {void} |
| | |
| | | chunkGraphForChunkMap.set(chunk, chunkGraph); |
| | | } |
| | | |
| | | // TODO remove in webpack 6 |
| | | /** |
| | | * Clear chunk graph for chunk. |
| | | * @deprecated |
| | | * @param {Chunk} chunk the chunk |
| | | * @returns {void} |
| | | */ |
| | | static clearChunkGraphForChunk(chunk) { |
| | | chunkGraphForChunkMap.delete(chunk); |
| | | } |
| | | // BACKWARD-COMPAT END |
| | | } |
| | | |
| | | // TODO remove in webpack 6 |