Skip to content

fix(@angular/build): add integrity metadata for all initial chunks beyond the module preload limit - #34400

Merged
alan-agius4 merged 2 commits into
angular:mainfrom
drakeo338:claude/34395-fix
Oct 20, 2026
Merged

alan-agius4 merged 2 commits into
angular:mainfrom
drakeo338:claude/34395-fix

Conversation

@drakeo338

Copy link
Copy Markdown

PR Checklist

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #34395

With subresourceIntegrity, the import map integrity entries skipped every initial file, assuming a modulepreload hint carried its hash. Only the first 10 initial chunks get a hint (none when preloadInitial is off or externalPackages is set), so the remaining initial chunks had no integrity metadata at all.

What is the new behavior?

The import map now skips only entry points and files that actually received a hint, so all other initial chunks are covered. New specs fail before the change and pass after it.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Docs box left unticked: no docs change is needed. Only the new index-html-generator_spec.ts specs were run, not the full suite.

…yond the module preload limit

With subresource integrity enabled, the import map integrity entries skipped every file in the
initial files set. Only the first 10 initial script chunks receive a `modulepreload` hint (and
none do when `preloadInitial` is disabled or `externalPackages` is set), so the remaining initial
chunks ended up without any integrity metadata.

Skip only entry points, which are referenced by their own tag, and files that actually received a
hint. All other initial chunks are now included in the import map integrity entries.

Closes angular#34395

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the subresource integrity (SRI) generation logic in index-html-generator.ts to ensure that entry points and module preload hints carry their own integrity attributes, while other initial chunks are covered by the import map. Additionally, a new test suite index-html-generator_spec.ts has been introduced to verify these changes under different scenarios, such as when chunks exceed the preload limit or when preloads are disabled. There are no review comments, and I have no feedback to provide.

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see inline comments.

Comment thread packages/angular/build/src/builders/application/index-html-generator_spec.ts Outdated
Comment thread packages/angular/build/src/builders/application/index-html-generator_spec.ts Outdated
Comment thread packages/angular/build/src/builders/application/index-html-generator_spec.ts Outdated
Comment thread packages/angular/build/src/builders/application/index-html-generator_spec.ts Outdated
Comment thread packages/angular/build/src/builders/application/index-html-generator_spec.ts Outdated
@alan-agius4 alan-agius4 added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews target: patch This PR is targeted for the next patch release labels Oct 19, 2026
Comment thread packages/angular/build/src/builders/application/index-html-generator_spec.ts Outdated
Comment thread packages/angular/build/src/builders/application/index-html-generator_spec.ts Outdated
Use TEST_TMPDIR for the temporary directory, reuse createOutputFile from
the bundler files module, follow the 'should ...' naming convention and
assert directly on the generated HTML.
@drakeo338

Copy link
Copy Markdown
Author

Applied in 0e685f1: createOutputFile now comes from the bundler files module, and the specs use TEST_TMPDIR, should ... names and direct toContain/not.toContain checks on csrContent instead of regex and JSON parsing.

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Oct 20, 2026

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alan-agius4
alan-agius4 merged commit 342ab4a into angular:main Oct 20, 2026
64 of 68 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

subresourceIntegrity leaves initial chunks beyond the modulepreload cap without any integrity metadata

2 participants