MCPcopy
hub / github.com/webpack/webpack / getFullContentHash

Method getFullContentHash

lib/asset/AssetGenerator.js:257–284  ·  view source on GitHub ↗

* Gets full content hash. * @param {NormalModule} module module * @param {RuntimeTemplate} runtimeTemplate runtime template * @returns {[string, string]} return full hash and non-numeric full hash

(module, runtimeTemplate)

Source from the content-addressed store, hash-verified

255 * @returns {[string, string]} return full hash and non-numeric full hash
256 */
257 static getFullContentHash(module, runtimeTemplate) {
258 const hash = createHash(runtimeTemplate.outputOptions.hashFunction);
259
260 if (runtimeTemplate.outputOptions.hashSalt) {
261 hash.update(runtimeTemplate.outputOptions.hashSalt);
262 }
263
264 const source = module.originalSource();
265
266 if (source) {
267 updateHashFromSource(hash, source);
268 }
269
270 if (module.error) {
271 hash.update(module.error.toString());
272 }
273
274 const fullContentHash = hash.digest(
275 runtimeTemplate.outputOptions.hashDigest
276 );
277
278 const contentHash = nonNumericOnlyHash(
279 fullContentHash,
280 runtimeTemplate.outputOptions.hashDigestLength
281 );
282
283 return [fullContentHash, contentHash];
284 }
285
286 /**
287 * Gets filename with info.

Callers 2

applyMethod · 0.80
generateMethod · 0.80

Calls 7

createHashFunction · 0.85
updateHashFromSourceFunction · 0.85
nonNumericOnlyHashFunction · 0.85
updateMethod · 0.45
originalSourceMethod · 0.45
toStringMethod · 0.45
digestMethod · 0.45

Tested by

no test coverage detected