Skip to content

Commit

Permalink
fix(@angular-devkit/build-webpack): rewrite ES5 polyfills file name (a…
Browse files Browse the repository at this point in the history
…ngular#15915)

The name is incorrect because the file is renamed after generation by Webpack, so the stats file contains a broken link. This hacks together a quick rewrite to the asset list to use the new filename.
  • Loading branch information
dgp1130 committed Nov 12, 2019
1 parent 7e7248d commit f3df3b1
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,21 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
new (class {
apply(compiler: Compiler) {
compiler.hooks.emit.tap('angular-cli-stats', compilation => {
const data = JSON.stringify(compilation.getStats().toJson('verbose'));
compilation.assets[`stats${targetInFileName}.json`] = new RawSource(data);
const data = compilation.getStats().toJson('verbose');

// HACK: Rewrite polyfills asset to remove `es2015` from name, as it was renamed after
// compilation from Webpack. Otherwise bundle analyzers are not able to find the file.
// See: https://github.com/angular/angular-cli/issues/15915.
const updatedAssets = !data.assets ? undefined : data.assets.map(({ name, ...rest }) => ({
name: name.replace('polyfills-es5-es2015', 'polyfills-es5'),
...rest,
}));
const updatedData = {
...data,
assets: updatedAssets,
};

compilation.assets[`stats${targetInFileName}.json`] = new RawSource(JSON.stringify(updatedData));
});
}
})(),
Expand Down

0 comments on commit f3df3b1

Please sign in to comment.