MCPcopy
hub / github.com/webpack/webpack / processChunk

Method processChunk

lib/Compilation.js:4992–5062  ·  view source on GitHub ↗
(chunk)

Source from the content-addressed store, hash-verified

4990 * @param {Chunk} chunk chunk
4991 */
4992 const processChunk = (chunk) => {
4993 // Last minute module hash generation for modules that depend on chunk hashes
4994 this.logger.time("hashing: hash runtime modules");
4995 const runtime = chunk.runtime;
4996 for (const module of chunkGraph.getChunkModulesIterable(chunk)) {
4997 if (!chunkGraph.hasModuleHashes(module, runtime)) {
4998 const hash = this._createModuleHash(
4999 module,
5000 chunkGraph,
5001 runtime,
5002 hashFunction,
5003 runtimeTemplate,
5004 hashDigest,
5005 hashDigestLength,
5006 errors
5007 );
5008 let hashMap = codeGenerationJobsMap.get(hash);
5009 if (hashMap) {
5010 const moduleJob = hashMap.get(module);
5011 if (moduleJob) {
5012 moduleJob.runtimes.push(runtime);
5013 continue;
5014 }
5015 } else {
5016 hashMap = new Map();
5017 codeGenerationJobsMap.set(hash, hashMap);
5018 }
5019 const job = {
5020 module,
5021 hash,
5022 runtime,
5023 runtimes: [runtime]
5024 };
5025 hashMap.set(module, job);
5026 codeGenerationJobs.push(job);
5027 }
5028 }
5029 this.logger.timeAggregate("hashing: hash runtime modules");
5030 try {
5031 this.logger.time("hashing: hash chunks");
5032 const chunkHash = createHash(hashFunction);
5033 if (outputOptions.hashSalt) {
5034 chunkHash.update(outputOptions.hashSalt);
5035 }
5036 chunk.updateHash(chunkHash, chunkGraph);
5037 this.hooks.chunkHash.call(chunk, chunkHash, {
5038 chunkGraph,
5039 codeGenerationResults:
5040 /** @type {CodeGenerationResults} */
5041 (this.codeGenerationResults),
5042 moduleGraph: this.moduleGraph,
5043 runtimeTemplate: this.runtimeTemplate
5044 });
5045 const chunkHashDigest = chunkHash.digest(hashDigest);
5046 hash.update(chunkHashDigest);
5047 chunk.hash = chunkHashDigest;
5048 chunk.renderedHash = chunk.hash.slice(0, hashDigestLength);
5049 const fullHashModules =

Callers

nothing calls this directly

Calls 15

_createModuleHashMethod · 0.95
createHashFunction · 0.85
timeMethod · 0.80
hasModuleHashesMethod · 0.80
timeAggregateMethod · 0.80
sliceMethod · 0.80
getMethod · 0.45
pushMethod · 0.45
setMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected