MCPcopy
hub / github.com/webpack/webpack / createChunkHashHandler

Function createChunkHashHandler

lib/javascript/ChunkFormatHelpers.js:44–66  ·  view source on GitHub ↗

* Creates a chunk hash handler * @param {string} name The name of the chunk * @returns {(chunk: Chunk, hash: Hash, { chunkGraph }: ChunkHashContext) => void} The chunk hash handler

(name)

Source from the content-addressed store, hash-verified

42 * @returns {(chunk: Chunk, hash: Hash, { chunkGraph }: ChunkHashContext) => void} The chunk hash handler
43 */
44function createChunkHashHandler(name) {
45 /**
46 * Processes the provided chunk.
47 * @param {Chunk} chunk The chunk to get information for
48 * @param {Hash} hash The hash to update
49 * @param {ChunkHashContext} chunkHashContext The chunk hash context
50 * @returns {void}
51 */
52 return (chunk, hash, { chunkGraph }) => {
53 if (chunk.hasRuntime()) return;
54 const { entries, runtimeChunk } = getChunkInfo(chunk, chunkGraph);
55 hash.update(name);
56 hash.update("1");
57 if (runtimeChunk && runtimeChunk.hash) {
58 // https://github.com/webpack/webpack/issues/19439
59 // Any change to runtimeChunk should trigger a hash update,
60 // we shouldn't depend on or inspect its internal implementation.
61 // import __webpack_require__ from "./runtime-main.e9400aee33633a3973bd.js";
62 hash.update(runtimeChunk.hash);
63 }
64 updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
65 };
66}
67
68module.exports = {
69 createChunkHashHandler,

Callers 2

applyMethod · 0.85
applyMethod · 0.85

Calls 3

getChunkInfoFunction · 0.85
hasRuntimeMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected