Closed
Labels
area: @angular-devkit/build-angulardevkit/build-angular:browserfreq1: lowOnly reported by a handful of users who observe it rarelyseverity5: regressiontype: bug/fix
Milestone
Description
🐞 Bug report
Command (mark with an x)
- new
- build
- serve
- test
- e2e
- generate
- add
- update
- lint
- extract-i18n
- run
- config
- help
- version
- doc
Is this a regression?
Yes, the previous version in which this bug was not present was: Angular 11 (per original bug report, I did not test this)
Description
Reopening #22602
If I understand correctly, per https://github.com/angular/angular-cli/blob/master/CHANGELOG.md#1322-2022-02-02, this should be fixed in 13.2.2 and higher (since the main PR [#22612] associated with ff54b49e7 closed #22602 ) . However, I see the issue in 13.2.2, 13.3.0, and 14.0.0-next.6.
🔬 Minimal Reproduction
(copied from original bug, except for updated clone link to a fork with 13.3.0)
- Clone https://github.com/JoshuaEN/angular-filename-hashing-bug-reproduction
- Run
npm cito install dependencies. - Run
ng build --configuration=production(with the default es2017 target in tsconfig.json). - Observe the contents of the output
dist/angular-filename-hashing-bug-reproduction/scripts.{revhash_1}.jsfile to betry{console.log()}catch(c){}. - Change the
compilerOptions.targettoes2019(ores2020ores2021) fromes2017in tsconfig.json. - Run
ng build --configuration=production. - Observe the contents of the output
dist/angular-filename-hashing-bug-reproduction/scripts.{revhash_2}.jsfile to betry{console.log()}catch{}(different from the output from step 4). - Observe that revhash_1 equals revhash_2.
🌍 Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 13.3.0
Node: 16.14.2
Package Manager: npm 8.5.0
OS: win32 x64
Angular: 13.3.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1303.0
@angular-devkit/build-angular 13.3.0
@angular-devkit/core 13.3.0
@angular-devkit/schematics 13.3.0
@schematics/angular 13.3.0
rxjs 7.4.0
typescript 4.5.5
Metadata
Metadata
Assignees
Labels
area: @angular-devkit/build-angulardevkit/build-angular:browserfreq1: lowOnly reported by a handful of users who observe it rarelyseverity5: regressiontype: bug/fix
Activity
alan-agius4 commentedon Mar 29, 2022
Hi @JoshuaEN,
I am unable to replicate with the above steps. I got 2 different file hashes as expected.
JoshuaEN commentedon Mar 29, 2022
Hi @alan-agius4,
Thanks for the quick reply!
The output hash that remains the same is for the
scripts.{hash}.jsfile.In your build output, the scripts file name remains the same but the size changes:

Combined with 1 year caches for static files and script tag integrity attributes, this causes the browser to use the previously cached version (if present) and then reject the script because the integrity hash does not match.
alan-agius4 commentedon Mar 29, 2022
@JoshuaEN, the
scriptsoption is only meant to be used for static JavaScript files. The fact that is allowing TypeScript files is a bug that will be addressed in version 14.Using JavaScript files in the scripts will result in correct behaviour.
JoshuaEN commentedon Mar 29, 2022
@alan-agius4, I see the same behavior when changing the script to a .js file (
script-jsbranch on example repository).I also see this on 14.0.0-next.6 (
script-js-nextbranch on example repository). The real-world case we saw this in was using only .js script files as well.Are there more changes planned for v14 that will address this?
alan-agius4 commentedon Mar 30, 2022
What is happening here is that the filename is being generated prior to the optimization phase where the content is being changed.
We are not currently actively looking into addressing this issue since it's rather an edge case.
[-]Output files' filename hashes are incorrect (reopening #22602)[/-][+]Output files' filename for scripts hashes are incorrect [/+]martinfrancois commentedon Jul 6, 2022
@alan-agius4 Would you be open to take into consideration a contribution to address this issue, or is generating the filename after the optimization phase something you do not want by design?
In case you are open to it, could you give a rough estimation on the amount of effort required to do this (for the change only, disregarding code review etc.).
fix(@angular-devkit/build-angular): generate different content hashes…
fix(@angular-devkit/build-angular): generate different content hashes…
angular-automatic-lock-bot commentedon Aug 12, 2022
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.