MCPcopy
hub / github.com/webpack/webpack / _resolveContextHash

Method _resolveContextHash

lib/FileSystemInfo.js:4133–4169  ·  view source on GitHub ↗

* Resolve context hash. * @private * @param {ContextHash} entry context hash * @param {(err: WebpackError | null, contextHash?: string) => void} callback callback * @returns {void}

(entry, callback)

Source from the content-addressed store, hash-verified

4131 * @returns {void}
4132 */
4133 _resolveContextHash(entry, callback) {
4134 /** @type {string[]} */
4135 const hashes = [];
4136 // Skip already-visited symlink targets so cyclic pnpm/peer-variant graphs terminate (#21084).
4137 const seen = new Set(entry.symlinks);
4138 processAsyncTree(
4139 /** @type {NonNullable<ContextHash["symlinks"]>} */ (entry.symlinks),
4140 10,
4141 (target, push, callback) => {
4142 this._getUnresolvedContextHash(target, (err, hash) => {
4143 if (err) return callback(err);
4144 if (hash) {
4145 hashes.push(hash.hash);
4146 if (hash.symlinks !== undefined) {
4147 for (const target of hash.symlinks) {
4148 if (!seen.has(target)) {
4149 seen.add(target);
4150 push(target);
4151 }
4152 }
4153 }
4154 }
4155 callback();
4156 });
4157 },
4158 (err) => {
4159 if (err) return callback(/** @type {WebpackError} */ (err));
4160 const hash = createHash(this._hashFunction);
4161 hash.update(entry.hash);
4162 hashes.sort();
4163 for (const h of hashes) {
4164 hash.update(h);
4165 }
4166 callback(null, (entry.resolved = hash.digest("hex")));
4167 }
4168 );
4169 }
4170
4171 /**
4172 * @private

Callers 3

getContextHashMethod · 0.95

Calls 11

processAsyncTreeFunction · 0.85
createHashFunction · 0.85
sortMethod · 0.80
callbackFunction · 0.50
pushFunction · 0.50
pushMethod · 0.45
hasMethod · 0.45
addMethod · 0.45
updateMethod · 0.45
digestMethod · 0.45

Tested by

no test coverage detected