Skip to content

refactor(@angular/build): support direct builds and shared load cache in BundlerContext - #33914

Merged
alan-agius4 merged 2 commits into
angular:mainfrom
clydin:bundler-context-shared-cache
Aug 25, 2026
Merged

refactor(@angular/build): support direct builds and shared load cache in BundlerContext#33914
alan-agius4 merged 2 commits into
angular:mainfrom
clydin:bundler-context-shared-cache

Conversation

@clydin

@clydin clydin commented Aug 24, 2026

Copy link
Copy Markdown
Member

Enhance BundlerContext to allow incremental result caching without requiring a persistent esbuild context instance. The useContext constructor parameter defaults to incremental for backward compatibility while allowing callers to disable persistent contexts. Also support passing an external LoadResultCache instance to share load caches across contexts, and add an optional invalidate method to the LoadResultCache interface.

@clydin clydin added the target: minor This PR is targeted for the next minor release label Aug 24, 2026

@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 BundlerContext to support a shared load cache (sharedLoadCache) and introduces an optional invalidate method to the LoadResultCache interface. The feedback highlights two key issues: first, making invalidate optional in LoadResultCache could lead to stale cached results during rebuilds if a custom cache doesn't implement it, so it should be made required; second, sharing a single cache across multiple contexts can cause cross-contamination of watch files, triggering unnecessary rebuilds and degrading performance.

Comment thread packages/angular/build/src/tools/esbuild/load-result-cache.ts Outdated
Comment thread packages/angular/build/src/tools/esbuild/bundler-context.ts
Comment thread packages/angular/build/src/tools/esbuild/bundler-context.ts Outdated
@clydin
clydin force-pushed the bundler-context-shared-cache branch 2 times, most recently from 098dc50 to 36c71cb Compare August 24, 2026 23:59
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 25, 2026
@clydin
clydin force-pushed the bundler-context-shared-cache branch 3 times, most recently from 46cfeb0 to ceef82e Compare August 25, 2026 01:15
… in BundlerContext

Enhance BundlerContext to allow incremental result caching without requiring a persistent esbuild context instance. The useContext constructor parameter defaults to incremental for backward compatibility while allowing callers to disable persistent contexts. Also support passing an external LoadResultCache instance to share load caches across contexts, and add an optional invalidate method to the LoadResultCache interface.
@clydin
clydin force-pushed the bundler-context-shared-cache branch 2 times, most recently from faa8b1d to 58095a9 Compare August 25, 2026 04:49
…undler contexts

Update setupBundlerContexts to instantiate a single MemoryLoadResultCache and share it across initial and non-initial global stylesheet BundlerContext instances. This allows global stylesheet contexts to share load cache state without instantiating multiple separate cache instances.
@clydin
clydin force-pushed the bundler-context-shared-cache branch from 58095a9 to c3293d7 Compare August 25, 2026 04:59
@clydin
clydin requested a review from alan-agius4 August 25, 2026 05:17
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 25, 2026
@alan-agius4
alan-agius4 merged commit 643942b into angular:main Aug 25, 2026
40 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

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

@clydin
clydin deleted the bundler-context-shared-cache branch August 25, 2026 14:05
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: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants