Skip to content

refactor(@angular/build): optimize JavaScript transformer worker startup and sourcemap generation - #33980

Open
clydin wants to merge 2 commits into
angular:mainfrom
clydin:perf/js-transformer-optimizations
Open

refactor(@angular/build): optimize JavaScript transformer worker startup and sourcemap generation#33980
clydin wants to merge 2 commits into
angular:mainfrom
clydin:perf/js-transformer-optimizations

Conversation

@clydin

@clydin clydin commented Aug 31, 2026

Copy link
Copy Markdown
Member

This PR introduces two targeted performance optimizations to the JavaScript transformation pipeline:

  • Lazy-loading of @babel/core in transformer workers
  • Word-boundary source map resolution in oxc transforms
@clydin clydin added the target: minor This PR is targeted for the next minor release label Aug 31, 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 optimizes dynamic imports in the JavaScript transformer worker by grouping them using Promise.all and updates the source map generation options in the OXC transformer to use 'boundary' instead of true for hires. The review feedback suggests caching the dynamically imported Babel linker dependencies at the module level to avoid the overhead of repeatedly calling import() and creating new promises on every file transformation.

Comment thread packages/angular/build/src/tools/esbuild/javascript-transformer-worker.ts Outdated
clydin added 2 commits August 31, 2026 15:03
… worker

By default, JavaScript transformations use the native OXC engine for Angular linking and advanced optimizations. The Babel-based linker is only utilized when the NG_BUILD_BABEL_LINKER environment variable is explicitly enabled.

Previously, transformAsync was imported statically at the top level of javascript-transformer-worker.ts, causing Node.js to eagerly evaluate @babel/core and all its transitive dependencies on startup across every Piscina worker thread.

Importing @babel/core dynamically only when the Babel linker fallback is active reduces worker thread startup latency and eliminates unnecessary worker idle memory overhead on standard builds.
…ation in oxc transform

Generating high-resolution sourcemap tokens for every character with hires: true produces substantially larger intermediate decoded mappings and increases peak memory consumption during sourcemap remapping.

Using hires: 'boundary' generates tokens only at identifier and word boundaries. This significantly reduces decoded sourcemap memory footprint and remapping time while retaining full debugging accuracy.
@clydin
clydin force-pushed the perf/js-transformer-optimizations branch from 8df7a4f to 33b6676 Compare August 31, 2026 19:04
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Sep 1, 2026
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

2 participants