Skip to content

perf(@angular/build): reuse inline stylesheet BundlerContext across component edits - #34435

Closed
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:perf/dedup-inline-component-styles
Closed

alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:perf/dedup-inline-component-styles

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Key #inlineContexts in ComponentStylesheetBundler.bundleInline() by path.dirname(filename) when sourcemaps are disabled (!this.options.sourcemap), allowing components in the same directory with identical inline styles to share a BundlerContext.
  • In ComponentStylesheetBundler.invalidate(), invoke bundler.invalidate(normalizedFiles) on #inlineContexts values rather than deleting the entry and disposing the BundlerContext whenever the component .ts file is edited. This preserves the BundlerContext across component edits when the inline style content hash is unchanged while still invalidating any watched dependencies.

Benchmark

Metric main Branch Delta
Runs (ms) 11975, 11548, 11719, 11800, 11615 11896, 11531, 11696, 11956, 11748
Median (ms) 11719 ms 11748 ms 0.25%
Mean (ms) 11731 ms 11765 ms 0.29%
Min (ms) 11548 ms 11531 ms -0.15%

…omponent edits

Key `#inlineContexts` in `ComponentStylesheetBundler.bundleInline()` by `path.dirname(filename)` when sourcemaps are disabled so identical inline styles across components in the same directory share a `BundlerContext`.

In `ComponentStylesheetBundler.invalidate()`, call `bundler.invalidate(normalizedFiles)` on `#inlineContexts` values instead of deleting and disposing the `BundlerContext` whenever the component `.ts` file changes, preserving the `BundlerContext` (and cached output when the inline style content hash is unchanged) while still invalidating watched dependencies.
@angular-robot angular-robot Bot added area: performance Issues related to performance area: @angular/build labels Oct 20, 2026
@angular-automatic-lock-bot

Copy link
Copy Markdown

This pull request 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.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Nov 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: @angular/build area: performance Issues related to performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant