-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(@angular-devkit/build-angular): prevent webpack from adding suffixes to polyfill files #16181
Conversation
5325f97
to
f76fed6
Compare
…xes to polyfills files The ES5 polyfills file was erroneously being suffixed with `es2015`. The webpack configuration does not support conditional customization per chunk for the output filenames (`chunkFilename` option schema only supports string values). This change adds an additional small webpack plugin that allows the chunk filenames to be adjusted based on the chunk name. The plugin is only added when differential loading is enabled as this is the only time that a chunk currently requires its filename to be adjusted. Closes angular#15915
f76fed6
to
30756f0
Compare
const isMap = filename && filename.endsWith('.map'); | ||
|
||
return data.chunk && data.chunk.name === 'polyfills-es5' | ||
? `polyfills-es5${hashFormat.chunk}.js${isMap ? '.map' : ''}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused here, this doesn't seem to change the name of polyfills-es5-es2015.js
, instead it seems to target polyfills-es5.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assetPath
hook is used by webpack to create the output filename/path for each chunk. The filename that is passed as an argument to the hook is actually the filename template from the webpack configuration (defined here in the CLI). Chunk names are defined via the entry point configuration (polyfills-es5
is defined here).
This plugin allows the template for the output filename to be altered on a per chunk basis. In this case, the polyfills-es5
chunk's filename template is changed to remove the targetInFileName
segment (-es2015
in the differential loading case). This causes webpack to generate the correct name and removes the need to patch the stats file and clean up the filenames after the fact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I see now, thank you. The logic is a bit circuitous and I worry about someone else altering this code. Can you add it as a comment please?
Merged to patch branch 9.0.x: https://github.com/angular/angular-cli/commits/9.0.x |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The ES5 polyfills file was erroneously being suffixed with
es2015
. The webpack configuration does not support conditional customization per chunk for the output filenames (chunkFilename
option schema only supports string values). This change adds an additional small webpack plugin that allows the chunk filenames to be adjusted based on the chunk name. The plugin is only added when differential loading is enabled as this is the only time that a chunk currently requires its filename to be adjusted.Closes #15915