* Updates asset using the provided file. * @param {string} file file name * @param {Source | ((source: Source) => Source)} newSourceOrFunction new asset source or function converting old to new * @param {(AssetInfo | ((assetInfo?: AssetInfo) => AssetInfo | undefined)) | undefined} assetInfoUpd
( file, newSourceOrFunction, assetInfoUpdateOrFunction = undefined )
| 5232 | * @param {(AssetInfo | ((assetInfo?: AssetInfo) => AssetInfo | undefined)) | undefined} assetInfoUpdateOrFunction new asset info or function converting old to new |
| 5233 | */ |
| 5234 | updateAsset( |
| 5235 | file, |
| 5236 | newSourceOrFunction, |
| 5237 | assetInfoUpdateOrFunction = undefined |
| 5238 | ) { |
| 5239 | if (!this.assets[file]) { |
| 5240 | throw new Error( |
| 5241 | `Called Compilation.updateAsset for not existing filename ${file}` |
| 5242 | ); |
| 5243 | } |
| 5244 | this.assets[file] = |
| 5245 | typeof newSourceOrFunction === class="st">"function" |
| 5246 | ? newSourceOrFunction(this.assets[file]) |
| 5247 | : newSourceOrFunction; |
| 5248 | if (assetInfoUpdateOrFunction !== undefined) { |
| 5249 | const oldInfo = this.assetsInfo.get(file) || EMPTY_ASSET_INFO; |
| 5250 | if (typeof assetInfoUpdateOrFunction === class="st">"function") { |
| 5251 | this._setAssetInfo(file, assetInfoUpdateOrFunction(oldInfo), oldInfo); |
| 5252 | } else { |
| 5253 | this._setAssetInfo( |
| 5254 | file, |
| 5255 | cachedCleverMerge(oldInfo, assetInfoUpdateOrFunction), |
| 5256 | oldInfo |
| 5257 | ); |
| 5258 | } |
| 5259 | } |
| 5260 | } |
| 5261 | |
| 5262 | /** |
| 5263 | * Processes the provided file. |
no test coverage detected