refactor(@angular/build): avoid loading localize tools and babel in i18n inliner worker - #34194
Merged
clydin merged 2 commits intoSep 29, 2026
Merged
Conversation
…18n inliner worker Previously, `i18n-inliner-worker.ts` dynamically loaded `@angular/localize/tools` to invoke its `translate()` function and `Diagnostics` class. Importing `@angular/localize/tools` eagerly pulls in `@babel/core`, `@angular/compiler-cli`, and `@angular/compiler`, consuming ~180 ms of CPU latency and ~32 MB of heap per worker thread upon first translation. Since the inliner only performs string translation replacements using AST locations already discovered via OXC, the full Babel transformation and compiler tooling bundle is unnecessary. This updates `i18n-inliner-worker.ts` to directly import low-level runtime functions (`ɵtranslate`, `ɵisMissingTranslationError`, `ɵmakeTemplateObject`) from `@angular/localize` and manage diagnostics via a direct message array. This completely avoids loading `@angular/localize/tools` and its heavy transitive dependencies.
There was a problem hiding this comment.
Code Review
This pull request refactors the i18n inliner worker to remove the dependency on @angular/localize/tools by directly utilizing low-level runtime functions from @angular/localize for message translation. Feedback on the changes suggests improving error handling in the new translateMessage function by verifying that the caught error is an instance of Error before accessing its message property, preventing potential runtime issues.
…el in i18n inliner worker
alan-agius4
approved these changes
Sep 29, 2026
Member
Author
|
This PR was merged into the repository. The changes were merged into the following branches:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously,
i18n-inliner-worker.tsdynamically loaded@angular/localize/toolsto invoke itstranslate()function andDiagnosticsclass. Importing@angular/localize/toolseagerly pulls in@babel/core,@angular/compiler-cli, and@angular/compiler, consuming ~180 ms of CPU latency and ~32 MB of heap per worker thread upon first translation.Since the inliner only performs string translation replacements using AST locations already discovered via OXC, the full Babel transformation and compiler tooling bundle is unnecessary.
This updates
i18n-inliner-worker.tsto directly import low-level runtime functions (ɵtranslate,ɵisMissingTranslationError,ɵmakeTemplateObject) from@angular/localizeand manage diagnostics via a direct message array. This completely avoids loading@angular/localize/toolsand its heavy transitive dependencies.