MCPcopy
hub / github.com/webpack/webpack / getChunkModuleIdMap

Method getChunkModuleIdMap

lib/ChunkGraph.js:824–849  ·  view source on GitHub ↗

* 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 * @returns {ChunkModuleIdMap} chunk to module ids object

(chunk, filterFn, includeAllChunks = false)

Source from the content-addressed store, hash-verified

822 * @returns {ChunkModuleIdMap} chunk to module ids object
823 */
824 getChunkModuleIdMap(chunk, filterFn, includeAllChunks = false) {
825 /** @type {ChunkModuleIdMap} */
826 const chunkModuleIdMap = Object.create(null);
827
828 for (const asyncChunk of includeAllChunks
829 ? chunk.getAllReferencedChunks()
830 : chunk.getAllAsyncChunks()) {
831 /** @type {ModuleId[] | undefined} */
832 let array;
833 for (const module of this.getOrderedChunkModulesIterable(
834 asyncChunk,
835 compareModulesById(this)
836 )) {
837 if (filterFn(module)) {
838 if (array === undefined) {
839 array = [];
840 chunkModuleIdMap[/** @type {ChunkId} */ (asyncChunk.id)] = array;
841 }
842 const moduleId = /** @type {ModuleId} */ (this.getModuleId(module));
843 array.push(moduleId);
844 }
845 }
846 }
847
848 return chunkModuleIdMap;
849 }
850
851 /**
852 * Gets chunk module rendered hash map.

Callers 1

generateMethod · 0.80

Calls 7

getModuleIdMethod · 0.95
compareModulesByIdFunction · 0.85
getAllAsyncChunksMethod · 0.80
createMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected