-
Notifications
You must be signed in to change notification settings - Fork 12k
Output files' filename for scripts hashes are incorrect #22906
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
Comments
Hi @JoshuaEN, I am unable to replicate with the above steps. I got 2 different file hashes as expected.
|
Hi @alan-agius4, Thanks for the quick reply! The output hash that remains the same is for the 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. |
@JoshuaEN, the Using JavaScript files in the scripts will result in correct behaviour. |
@alan-agius4, I see the same behavior when changing the script to a .js file (
I also see this on 14.0.0-next.6 ( Are there more changes planned for v14 that will address this? |
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. |
@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.). |
… for scripts which are changed during the optimization phase Instead of generating the content hash based on the content of scripts BEFORE the optimization phase, the content hash is generated AFTER the optimization phase. Prevents caching issues where browsers block execution of scripts due to the integrity hash not matching with the cached script in case of a script being optimized differently than in a previous build, where it would previously result in the same content hash. Fixes angular#22906
… for scripts which are changed during the optimization phase Instead of generating the content hash based on the content of scripts BEFORE the optimization phase, the content hash is generated AFTER the optimization phase. Prevents caching issues where browsers block execution of scripts due to the integrity hash not matching with the cached script in case of a script being optimized differently than in a previous build, where it would previously result in the same content hash. Fixes angular#22906
… for scripts which are changed during the optimization phase Instead of generating the content hash based on the content of scripts BEFORE the optimization phase, the content hash is generated AFTER the optimization phase. Prevents caching issues where browsers block execution of scripts due to the integrity hash not matching with the cached script in case of a script being optimized differently than in a previous build, where it would previously result in the same content hash. Fixes angular#22906
… for scripts which are changed during the optimization phase Instead of generating the content hash based on the content of scripts BEFORE the optimization phase, the content hash is generated AFTER the optimization phase. Prevents caching issues where browsers block execution of scripts due to the integrity hash not matching with the cached script in case of a script being optimized differently than in a previous build, where it would previously result in the same content hash. Fixes angular#22906
… for scripts which are changed during the optimization phase Instead of generating the content hash based on the content of scripts BEFORE the optimization phase, the content hash is generated AFTER the optimization phase. Prevents caching issues where browsers block execution of scripts due to the integrity hash not matching with the cached script in case of a script being optimized differently than in a previous build, where it would previously result in the same content hash. Fixes #22906
… for scripts which are changed during the optimization phase Instead of generating the content hash based on the content of scripts BEFORE the optimization phase, the content hash is generated AFTER the optimization phase. Prevents caching issues where browsers block execution of scripts due to the integrity hash not matching with the cached script in case of a script being optimized differently than in a previous build, where it would previously result in the same content hash. Fixes #22906 (cherry picked from commit 357c45e)
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. |
🐞 Bug report
Command (mark with an
x
)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)
npm ci
to install dependencies.ng build --configuration=production
(with the default es2017 target in tsconfig.json).dist/angular-filename-hashing-bug-reproduction/scripts.{revhash_1}.js
file to betry{console.log()}catch(c){}
.compilerOptions.target
toes2019
(ores2020
ores2021
) fromes2017
in tsconfig.json.ng build --configuration=production
.dist/angular-filename-hashing-bug-reproduction/scripts.{revhash_2}.js
file to betry{console.log()}catch{}
(different from the output from step 4).🌍 Your Environment
The text was updated successfully, but these errors were encountered: