Repository navigation
[22.2.x]refactor(@angular/build): avoid loading localize tools and babel in i18n inliner worker - #34213
Merged
clydin merged 2 commits intoSep 30, 2026
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.
…er worker Previously, `@ampproject/remapping` was statically imported at the top level of `i18n-inliner-worker.ts`, eagerly pulling in 5 packages (`@ampproject/remapping` and 4 sub-dependencies) upon worker initialization. In typical workflows or when sourcemaps are not requested for inlining, remapping is never executed. This changes the import of `@ampproject/remapping` to be dynamic so that it is only loaded when a file actually requires sourcemap remapping.
There was a problem hiding this comment.
Code Review
This pull request refactors the i18n inliner worker to use low-level runtime functions from @angular/localize directly, eliminating the need to dynamically load @angular/localize/tools. It also optimizes startup by lazy-loading @ampproject/remapping. Feedback highlights a potential performance regression when translations is undefined; passing an empty object to ɵtranslate throws expensive exceptions for every message. A fast-path implementation is suggested to bypass translation lookup and avoid this overhead.
alan-agius4
approved these changes
Sep 30, 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 its
translate()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 perworker thread upon first translation.