refactor(@angular/build): add fast path for untranslated messages in i18n inliner worker - #34214
Merged
Merged
Conversation
…i18n inliner worker When inlining a locale without translations (such as the source locale or when a translation dictionary is undefined), calls to translateMessage() previously invoked ɵtranslate() with an empty dictionary. This caused @angular/localize to throw a MissingTranslationError for every single $localize message site in the application, catching it to retrieve the original message parts from the parsed message. Throwing and catching thousands of Error instances incurs significant V8 stack trace capturing and exception handling overhead. translateMessage() now provides an early fast path when translations is undefined: it directly calls ɵparseMessage(messageParts, substitutions) to parse and strip metadata/placeholder markers without throwing or catching exceptions.
There was a problem hiding this comment.
Code Review
This pull request introduces a fast path for untranslated locales in the i18n inliner, allowing messages to be processed without triggering translation logic when no translation dictionary is provided. This is achieved by using ɵparseMessage to strip metadata and placeholders directly. I have included the reviewer's suggestion to further optimize this path by bypassing parsing for simple messages that do not contain metadata markers.
Adds a new benchmark scenario modeling a very large application workload: - 800 chunks total (~150 MB JS): 1 main bundle (6 MB) + 250 small chunks (40 KB) + 549 feature chunks (245 KB). - 8 locales, 5,000 translations, sourcemaps ON. This exercises worker thread pool queue capacity, task dispatch throughput, IPC messaging, and memory reclamation across hundreds of files in parallel.
alan-agius4
approved these changes
Sep 30, 2026
Member
Author
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.
When inlining a locale without translations (such as the source locale or when a translation dictionary is undefined), calls to translateMessage() previously invoked ɵtranslate() with an empty dictionary. This caused @angular/localize to throw a MissingTranslationError for every single $localize message site in the application, catching it to retrieve the original message parts from the parsed message.
Throwing and catching thousands of Error instances incurs significant V8 stack trace capturing and exception handling overhead.
translateMessage() now provides an early fast path when translations is undefined: it directly calls ɵparseMessage(messageParts, substitutions) to parse and strip metadata/placeholder markers without throwing or catching exceptions.