Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): don't override asset info when up…
Browse files Browse the repository at this point in the history
…dating assets

Currently, we are overriding asset info instead of appending additional data to it.
  • Loading branch information
alan-agius4 committed Mar 30, 2022
1 parent f2598a4 commit fac9cca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ export class CssOptimizerPlugin {

if (cachedOutput) {
await this.addWarnings(compilation, cachedOutput.warnings);
compilation.updateAsset(name, cachedOutput.source, {
compilation.updateAsset(name, cachedOutput.source, (assetInfo) => ({
...assetInfo,
minimized: true,
});
}));
continue;
}
}
Expand All @@ -93,7 +94,10 @@ export class CssOptimizerPlugin {
const optimizedAsset = map
? new SourceMapSource(code, name, map)
: new OriginalSource(code, name);
compilation.updateAsset(name, optimizedAsset, { minimized: true });
compilation.updateAsset(name, optimizedAsset, (assetInfo) => ({
...assetInfo,
minimized: true,
}));

await cacheItem?.storePromise({
source: optimizedAsset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ export class JavaScriptOptimizerPlugin {
>();

if (cachedOutput) {
compilation.updateAsset(name, cachedOutput.source, {
compilation.updateAsset(name, cachedOutput.source, (assetInfo) => ({
...assetInfo,
minimized: true,
});
}));
continue;
}
}
Expand Down Expand Up @@ -209,7 +210,10 @@ export class JavaScriptOptimizerPlugin {
const optimizedAsset = map
? new SourceMapSource(code, name, map)
: new OriginalSource(code, name);
compilation.updateAsset(name, optimizedAsset, { minimized: true });
compilation.updateAsset(name, optimizedAsset, (assetInfo) => ({
...assetInfo,
minimized: true,
}));

return cacheItem?.storePromise({
source: optimizedAsset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ export class TransferSizePlugin {
actions.push(
brotliCompressAsync(scriptAsset.source.source())
.then((result) => {
compilation.updateAsset(assetName, (s) => s, {
estimatedTransferSize: result.length,
});
compilation.updateAsset(
assetName,
(s) => s,
(assetInfo) => ({
...assetInfo,
estimatedTransferSize: result.length,
}),
);
})
.catch((error) => {
compilation.warnings.push(
Expand Down

0 comments on commit fac9cca

Please sign in to comment.