Skip to content

refactor(@angular/build): optimize unmodified file and locale handling in i18n inliner - #33950

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:perf/i18n-inliner-unmodified-fast-path
Aug 27, 2026
Merged

refactor(@angular/build): optimize unmodified file and locale handling in i18n inliner#33950
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:perf/i18n-inliner-unmodified-fast-path

Conversation

@clydin

@clydin clydin commented Aug 27, 2026

Copy link
Copy Markdown
Member

When AST analysis determines that a file has zero $localize call sites and zero locale insert sites, the worker returns a lightweight unmodified batch result immediately, skipping per-locale loops, translation dictionary queries, and sourcemap parsing.

For files where transformations occur but a specific locale produces no text modifications, code and sourcemap strings are omitted from the worker result, avoiding redundant serialization over worker IPC. The main thread falls back directly to the existing BuildOutputFile contents and cloned sourcemaps.

@clydin clydin added the target: minor This PR is targeted for the next minor release label Aug 27, 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 introduces a fast path in the i18n inliner to skip processing for files that do not contain any active $localize call sites or locale insert sites, improving build performance. It updates the worker and main inliner to handle unmodified files, returning undefined code and maps, and caching them efficiently. The review feedback suggests a further optimization in i18n-inliner.ts to clone the original file directly instead of calling createOutputFile when the file is unmodified, which avoids redundant content hash calculations.

Comment thread packages/angular/build/src/tools/esbuild/i18n-inliner.ts Outdated
…g in i18n inliner

When AST analysis determines that a file has zero $localize call sites and zero
locale insert sites, the worker returns a lightweight unmodified batch result
immediately, skipping per-locale loops, translation dictionary queries, and
sourcemap parsing.

For files where transformations occur but a specific locale produces no text
modifications, code and sourcemap strings are omitted from the worker result,
avoiding redundant serialization over worker IPC. The main thread falls back
directly to the existing BuildOutputFile contents and cloned sourcemaps.
@clydin
clydin force-pushed the perf/i18n-inliner-unmodified-fast-path branch from 8dae1af to e3a9d38 Compare August 27, 2026 14:15
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 27, 2026
@clydin
clydin requested a review from alan-agius4 August 27, 2026 14:40
@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 27, 2026
@alan-agius4
alan-agius4 merged commit 7634b27 into angular:main Aug 27, 2026
67 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:

@clydin
clydin deleted the perf/i18n-inliner-unmodified-fast-path branch August 27, 2026 16:53
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