MCPcopy
hub / github.com/webpack/webpack / emitAsset

Method emitAsset

lib/Compilation.js:5128–5156  ·  lib/Compilation.js::Compilation.emitAsset

* Processes the provided file. * @param {string} file file name * @param {Source} source asset source * @param {AssetInfo} assetInfo extra asset information * @returns {void}

(file, source, assetInfo = {})

Source from the content-addressed store, hash-verified

5126 * @returns {void}
5127 */
5128 emitAsset(file, source, assetInfo = {}) {
5129 class="cm">// A file may be attached to a chunk right after any emit (including the
5130 class="cm">// re-emit path for assets shared across chunks in createChunkAssets), so
5131 class="cm">// the lazily-built reverse index is stale after every emitAsset.
5132 this._assetToChunkIndex = undefined;
5133 this._assetToChunkAuxiliaryIndex = undefined;
5134 if (this.assets[file]) {
5135 if (!isSourceEqual(this.assets[file], source)) {
5136 this.errors.push(
5137 new WebpackError(
5138 `Conflict: Multiple assets emit different content to the same filename ${file}${
5139 assetInfo.sourceFilename
5140 ? `. Original source ${assetInfo.sourceFilename}`
5141 : class="st">""
5142 }`
5143 )
5144 );
5145 this.assets[file] = source;
5146 this._setAssetInfo(file, assetInfo);
5147 return;
5148 }
5149 const oldInfo = this.assetsInfo.get(file);
5150 const newInfo = { ...oldInfo, ...assetInfo };
5151 this._setAssetInfo(file, newInfo, oldInfo);
5152 return;
5153 }
5154 this.assets[file] = source;
5155 this._setAssetInfo(file, assetInfo, undefined);
5156 }
5157
5158 /**
5159 * Processes the provided file.

Callers 15

createModuleAssetsMethod · 0.95
createChunkAssetsMethod · 0.95
applyMethod · 0.80
applyMethod · 0.80
runAsChildMethod · 0.80
applyMethod · 0.80
applyFunction · 0.80
applyFunction · 0.80
applyFunction · 0.80
applyFunction · 0.80
applyFunction · 0.80

Calls 4

_setAssetInfoMethod · 0.95
isSourceEqualFunction · 0.85
pushMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected