Skip to content

Commit f3df3b1

Browse files
committed
fix(@angular-devkit/build-webpack): rewrite ES5 polyfills file name (angular#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.
1 parent 7e7248d commit f3df3b1

File tree

1 file changed

+15
-2
lines changed
  • packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs

1 file changed

+15
-2
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,21 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
284284
new (class {
285285
apply(compiler: Compiler) {
286286
compiler.hooks.emit.tap('angular-cli-stats', compilation => {
287-
const data = JSON.stringify(compilation.getStats().toJson('verbose'));
288-
compilation.assets[`stats${targetInFileName}.json`] = new RawSource(data);
287+
const data = compilation.getStats().toJson('verbose');
288+
289+
// HACK: Rewrite polyfills asset to remove `es2015` from name, as it was renamed after
290+
// compilation from Webpack. Otherwise bundle analyzers are not able to find the file.
291+
// See: https://github.com/angular/angular-cli/issues/15915.
292+
const updatedAssets = !data.assets ? undefined : data.assets.map(({ name, ...rest }) => ({
293+
name: name.replace('polyfills-es5-es2015', 'polyfills-es5'),
294+
...rest,
295+
}));
296+
const updatedData = {
297+
...data,
298+
assets: updatedAssets,
299+
};
300+
301+
compilation.assets[`stats${targetInFileName}.json`] = new RawSource(JSON.stringify(updatedData));
289302
});
290303
}
291304
})(),

0 commit comments

Comments
 (0)