MCPcopy
hub / github.com/webpack/webpack / createChunkAssets

Method createChunkAssets

lib/Compilation.js:5544–5704  ·  lib/Compilation.js::Compilation.createChunkAssets

* Creates a chunk assets. * @param {Callback} callback signals when the call finishes * @returns {void}

(callback)

Source from the content-addressed store, hash-verified

5542 * @returns {void}
5543 */
5544 createChunkAssets(callback) {
5545 const outputOptions = this.outputOptions;
5546 /** @type {WeakMap<Source, CachedSource>} */
5547 const cachedSourceMap = new WeakMap();
5548 /** @type {Map<string, { hash: string, source: Source, chunk: Chunk }>} */
5549 const alreadyWrittenFiles = new Map();
5550
5551 asyncLib.forEachLimit(
5552 this.chunks,
5553 15,
5554 (chunk, callback) => {
5555 /** @type {RenderManifestEntry[]} */
5556 let manifest;
5557 try {
5558 manifest = this.getRenderManifest({
5559 chunk,
5560 hash: /** @type {string} */ (this.hash),
5561 fullHash: /** @type {string} */ (this.fullHash),
5562 outputOptions,
5563 codeGenerationResults:
5564 /** @type {CodeGenerationResults} */
5565 (this.codeGenerationResults),
5566 moduleTemplates: this.moduleTemplates,
5567 dependencyTemplates: this.dependencyTemplates,
5568 chunkGraph: this.chunkGraph,
5569 moduleGraph: this.moduleGraph,
5570 runtimeTemplate: this.runtimeTemplate
5571 });
5572 } catch (err) {
5573 this.errors.push(
5574 new ChunkRenderError(chunk, class="st">"", /** @type {Error} */ (err))
5575 );
5576 return callback();
5577 }
5578 asyncLib.each(
5579 manifest,
5580 (fileManifest, callback) => {
5581 const ident = fileManifest.identifier;
5582 const usedHash = /** @type {string} */ (fileManifest.hash);
5583
5584 const assetCacheItem = this._assetsCache.getItemCache(
5585 ident,
5586 usedHash
5587 );
5588
5589 assetCacheItem.get((err, sourceFromCache) => {
5590 /** @type {string | import(class="st">"./TemplatedPathPlugin").TemplatePathFn<EXPECTED_ANY>} */
5591 let filenameTemplate;
5592 /** @type {string} */
5593 let file;
5594 /** @type {AssetInfo} */
5595 let assetInfo;
5596
5597 let inTry = true;
5598 /**
5599 * Error and callback.
5600 * @param {Error} err error
5601 * @returns {void}

Callers 1

sealMethod · 0.95

Calls 12

getRenderManifestMethod · 0.95
getPathWithInfoMethod · 0.95
emitAssetMethod · 0.95
getItemCacheMethod · 0.80
callbackFunction · 0.50
pushMethod · 0.45
getMethod · 0.45
renderMethod · 0.45
setMethod · 0.45
addMethod · 0.45
callMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected