refactor(@angular/build): bypass worker dispatch for non-Angular files with byte-level linker pre-check - #33825
Open
clydin wants to merge 1 commit into
Open
refactor(@angular/build): bypass worker dispatch for non-Angular files with byte-level linker pre-check#33825clydin wants to merge 1 commit into
clydin wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request optimizes the JavaScript transformation process by moving the requiresLinking check from the worker thread to the main thread, allowing the build to bypass worker communication overhead when linking is not required. Feedback is provided regarding a potential issue in the regular expression used to exclude certain paths (like @angular/core and @angular/compiler), where the low precedence of the alternation operator could cause false positives on packages like @angular/compiler-cli.
…s with byte-level linker pre-check In AOT compilation mode, JavaScript files loaded from node_modules are processed with `skipLinker: false`. Previously, `requiresLinking` was only evaluated inside worker threads after string decoding, forcing every 3rd-party dependency to be dispatched to the Piscina worker pool even when no linking or transformations were needed (such as during development server runs). This commit introduces a fast byte-level pre-check for the Angular partial declaration prefix (`ɵɵngDeclare`) directly in `JavaScriptTransformer.transformData` on the main thread. By scanning incoming raw buffers with `Buffer.indexOf` before thread dispatch, files that do not require linking (and have no advanced optimizations or coverage enabled) can bypass worker thread scheduling, message serialization, and string decoding entirely.
clydin
force-pushed
the
perf/linker-byte-precheck
branch
from
August 10, 2026 19:27
b1ff4b6 to
c943b89
Compare
alan-agius4
reviewed
Aug 11, 2026
| ? data | ||
| : Buffer.from(data.buffer, data.byteOffset, data.byteLength); | ||
|
|
||
| return dataBuffer.indexOf(LINKER_DECLARATION_PREFIX_BYTES) !== -1; |
Collaborator
There was a problem hiding this comment.
NIT:
Suggested change
| return dataBuffer.indexOf(LINKER_DECLARATION_PREFIX_BYTES) !== -1; | |
| return dataBuffer.includes(LINKER_DECLARATION_PREFIX_BYTES); |
alan-agius4
approved these changes
Aug 11, 2026
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.
In AOT compilation mode, JavaScript files loaded from node_modules are processed with
skipLinker: false. Previously,requiresLinkingwas only evaluated inside worker threads after string decoding, forcing every 3rd-party dependency to be dispatched to the Piscina worker pool even when no linking or transformations were needed (such as during development server runs).This commit introduces a fast byte-level pre-check for the Angular partial declaration prefix (
ɵɵngDeclare) directly inJavaScriptTransformer.transformDataon the main thread. By scanning incoming raw buffers withBuffer.indexOfbefore thread dispatch, files that do not require linking (and have no advanced optimizations or coverage enabled) can bypass worker thread scheduling, message serialization, and string decoding entirely.