-
Notifications
You must be signed in to change notification settings - Fork 12k
fix(@angular-devkit/build-angular): generate different content hashes for scripts which are changed during the optimization phase #23531
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
Conversation
packages/angular_devkit/build_angular/src/webpack/plugins/scripts-webpack-plugin.ts
Outdated
Show resolved
Hide resolved
packages/angular_devkit/build_angular/src/webpack/plugins/scripts-webpack-plugin.ts
Outdated
Show resolved
Hide resolved
packages/angular_devkit/build_angular/src/webpack/plugins/scripts-webpack-plugin.ts
Outdated
Show resolved
Hide resolved
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.
Thanks for your contribution.
Couple of small changes.
227d306
to
2eca3e7
Compare
@alan-agius4 You're welcome, thanks a lot for the quick and thorough review! I agree with all of your suggestions and addressed all of your comments and pushed the changes, can you please have a look again? |
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.
LGTM. one small NIT
Thanks for this.
2eca3e7
to
c006b0c
Compare
@alan-agius4 You're welcome, thanks as well for the quick handling! Addressed your nit now and pushed it. |
@martinfrancois, it looks like angular-cli/packages/angular_devkit/build_angular/src/builders/browser/specs/scripts-array_spec.ts Lines 78 to 101 in 68358f0
Let me know if you need any help with this. |
It looks like the sourcemaps are not renamed. In this case there is also another problem. This also highlights a bigger problem. Since the sourcemaps are being renamed afterwards the sourcemaps comment would point to an invalid sourcemap file. I think one way to fix this would be to change the hook to maybe |
@alan-agius4 I just noticed it as well and came to the same conclusion as you, I tried to run the tests locally but so far I was not able to, when I run them using |
I do recall @clydin had problems running on Mac M1. Bazel is to only way to run these tests. |
@alan-agius4 I'm not using an M1 Mac, just an Intel one, that's the strange part about it... Is there a way to restrict the tests to only test |
… 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
c006b0c
to
b22089d
Compare
@alan-agius4 Your intuition seems to have been correct, changing the hook to |
@alan-agius4 Tests are passing now! 🎉 |
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.
LGTM
@martinfrancois thanks for the fix. @alan-agius4 thanks for your quick response on this issue. |
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. |
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
Test case is based on the reproduction example as specified in #22906 (thanks!).