MCPcopy
hub / github.com/webpack/webpack / getChunkModuleRenderedHashMap

Method getChunkModuleRenderedHashMap

lib/ChunkGraph.js:859–896  ·  view source on GitHub ↗

* 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 * @param {boolean} includeAllChunks all chunks or only async chunks * @returns {ChunkModuleHashM

(
		chunk,
		filterFn,
		hashLength = 0,
		includeAllChunks = false
	)

Source from the content-addressed store, hash-verified

857 * @returns {ChunkModuleHashMap} chunk to module id to module hash object
858 */
859 getChunkModuleRenderedHashMap(
860 chunk,
861 filterFn,
862 hashLength = 0,
863 includeAllChunks = false
864 ) {
865 /** @type {ChunkModuleHashMap} */
866 const chunkModuleHashMap = Object.create(null);
867
868 for (const asyncChunk of includeAllChunks
869 ? chunk.getAllReferencedChunks()
870 : chunk.getAllAsyncChunks()) {
871 /** @type {IdToHashMap | undefined} */
872 let idToHashMap;
873 for (const module of this.getOrderedChunkModulesIterable(
874 asyncChunk,
875 compareModulesById(this)
876 )) {
877 if (filterFn(module)) {
878 if (idToHashMap === undefined) {
879 /** @type {IdToHashMap} */
880 idToHashMap = Object.create(null);
881 chunkModuleHashMap[/** @type {ChunkId} */ (asyncChunk.id)] =
882 /** @type {IdToHashMap} */
883 (idToHashMap);
884 }
885 const moduleId = this.getModuleId(module);
886 const hash = this.getRenderedModuleHash(module, asyncChunk.runtime);
887 /** @type {IdToHashMap} */
888 (idToHashMap)[/** @type {ModuleId} */ (moduleId)] = hashLength
889 ? hash.slice(0, hashLength)
890 : hash;
891 }
892 }
893 }
894
895 return chunkModuleHashMap;
896 }
897
898 /**
899 * Gets chunk condition map.

Callers 2

generateMethod · 0.80
hashWithLengthMethod · 0.80

Calls 8

getModuleIdMethod · 0.95
getRenderedModuleHashMethod · 0.95
compareModulesByIdFunction · 0.85
getAllAsyncChunksMethod · 0.80
sliceMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected