Repository navigation
Description
Command
build
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
The same gap exists since #34583, but it shows up on a toolchain update: 22.2.6 → 22.3.0.
Description
#34583 made the chunk optimizer's augmentChunkHash include the hashes of the input source maps of a chunk's modules, so that a change that only affects the source map renames the chunk (#34574). The //# debugId= comment injected after naming is derived from the output source map, though, and the output map can change while every input map stays the same.
Updating @angular/build from 22.2.6 to 22.3.0 does exactly that for vendor-only lazy chunks. In our production build, two lazy chunks that hold only third-party code (SheetJS and jsPDF, loaded with import()) kept their file names, and their JavaScript was byte-for-byte identical apart from the trailing comment:
-//# debugId=e8aee844-1ba7-543c-be31-811b9fc51bb2
+//# debugId=fb140939-ab0f-576a-a399-540d2ee6737b
In the chunks' .map files, sources and sourcesContent are identical; only names and mappings differ (the newer minifier maps the same output differently). The input maps are unchanged, so augmentChunkHash returns the same value, Rolldown's code hash is the same, and the file name is the same while the bytes differ.
With subresourceIntegrity on, a browser or CDN that holds the old copy under that name fails the integrity check against the new index.html, and the lazy import fails. The same applies to any update that changes only how the output is mapped (minifier, Rolldown, or the debug ID computation), so every toolchain bump can reintroduce it.
Related: #34674 reports the same symptom for main and polyfills, and proposes naming files from their final bytes after debug IDs are injected. That approach would also cover this case; hashing the output map (or the final file contents) in augmentChunkHash would cover it for optimized lazy chunks.
Minimal Reproduction
- An application with source maps on for scripts,
subresourceIntegrity: true, and enough lazy chunks for the chunk optimizer to run (3 or more), including at least one lazy chunk that holds only a third-party library loaded withimport('<package>'). - Build with
@angular/build22.2.6 and keepdist/. - Update
@angular/buildand@angular/clito 22.3.0 without changing application code, and build again. - Compare the two
dist/folders: list files that exist in both with the same name and different contents. The vendor-only lazy chunk is among them, anddiffshows only the//# debugId=line changed.
Exception or Error
Failed to find a valid digest in the 'integrity' attribute for resource '<origin>/chunk-XXXXXXXX.js' with computed SHA-384 integrity '...'. The resource has been blocked.
Your Environment
Angular CLI : 22.3.0
@angular/build : 22.3.0 (previous build: 22.2.6)
@angular/core : 22.3.0
TypeScript : 6.0.3
Node.js : 24.22.1
Package manager : npm 11.19
OS : macOS and Linux (CI)
Build options: `sourceMap: true`, `subresourceIntegrity: true`, `outputHashing: all`, production configuration.
Build options: sourceMap: true, subresourceIntegrity: true, outputHashing: all, production configuration.
Anything else relevant?
(The error above is the shape of the browser error when a stale cached copy is served; our CI caught the name collision before deploy, so we did not ship it.)
Workaround we used: change what the app imports from each library (a local module that re-exports only the used members), which changes the rendered chunk code and so its name. namedChunks: true only changes the readable prefix; the [hash] part is computed the same way, so it does not prevent this.
Activity