MCPcopy
hub / github.com/webpack/webpack / computeContentHash

Method computeContentHash

lib/html/HtmlModulesPlugin.js:107–119  ·  view source on GitHub ↗

* `output.hashFunction`/`hashSalt`/`hashDigest`/`hashDigestLength` * digest of `content`, with `nonNumericOnlyHash` applied — webpack's * standard `[contenthash]` recipe. * @param {string | Buffer} content content to hash * @param {import("../../declarations/WebpackOptions").Output} outputOp

(content, outputOptions)

Source from the content-addressed store, hash-verified

105 * @returns {string} content hash
106 */
107 static computeContentHash(content, outputOptions) {
108 const hash = createHash(
109 /** @type {import("../../declarations/WebpackOptions").HashFunction} */
110 (outputOptions.hashFunction)
111 );
112 if (outputOptions.hashSalt) hash.update(outputOptions.hashSalt);
113 hash.update(content);
114 return digestNonNumericOnly(
115 hash,
116 /** @type {string} */ (outputOptions.hashDigest),
117 /** @type {number} */ (outputOptions.hashDigestLength)
118 );
119 }
120
121 /**
122 * Applies the plugin by registering its hooks on the compiler.

Callers 1

applyMethod · 0.80

Calls 3

createHashFunction · 0.85
digestNonNumericOnlyFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected