Skip to content

perf(@angular/build): optimize sourcemap stripping and loading with buffer fast path - #33816

Merged
clydin merged 1 commit into
angular:mainfrom
clydin:perf/buffer-sourcemap-fast-path
Aug 10, 2026
Merged

perf(@angular/build): optimize sourcemap stripping and loading with buffer fast path#33816
clydin merged 1 commit into
angular:mainfrom
clydin:perf/buffer-sourcemap-fast-path

Conversation

@clydin

@clydin clydin commented Aug 7, 2026

Copy link
Copy Markdown
Member

Optimize sourcemap detection, loading, and stripping during JavaScript transformations by inspecting incoming raw Uint8Array/Buffer data directly before decoding into strings.

Files without sourcemap comments are identified via fast Buffer.indexOf() and skip comment removal entirely. For single trailing comments, the sourcemap is parsed directly from the trailing URL slice and the raw code buffer is sliced using a zero-copy subarray view to avoid large string allocations and trailing state-machine scans. Line-start boundaries and end-of-file trailing whitespace are validated to prevent false positives with template strings, safely falling back to full string state-machine parsing when necessary.

@angular-robot angular-robot Bot added area: performance Issues related to performance area: @angular/build labels Aug 7, 2026
@clydin
clydin marked this pull request as ready for review August 10, 2026 13:44

@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 the JavaScript transformer worker by parsing and stripping trailing sourcemaps directly from raw buffers, avoiding full string decodes and regex scans for the fast path. The reviewer suggests tracking the original sourcemap URL (inputSourceMapUrl) throughout the transformation pipeline to prevent sourcemaps from being silently discarded when no transformations are applied.

@clydin
clydin force-pushed the perf/buffer-sourcemap-fast-path branch from 175c787 to 3d45d7c Compare August 10, 2026 14:08
@clydin clydin added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels Aug 10, 2026
…uffer fast path

Optimize sourcemap detection, loading, and stripping during JavaScript transformations by inspecting incoming raw Uint8Array/Buffer data directly before decoding into strings.

Files without sourcemap comments are identified via fast Buffer.indexOf() and skip comment removal entirely. For single trailing comments, the sourcemap is parsed directly from the trailing URL slice and the raw code buffer is sliced using a zero-copy subarray view to avoid large string allocations and trailing state-machine scans. Line-start boundaries and end-of-file trailing whitespace are validated to prevent false positives with template strings, safely falling back to full string state-machine parsing when necessary.
@clydin
clydin force-pushed the perf/buffer-sourcemap-fast-path branch from 3d45d7c to d616b57 Compare August 10, 2026 14:14
@clydin
clydin requested a review from alan-agius4 August 10, 2026 15:03
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 10, 2026
@clydin
clydin merged commit 1c00edc into angular:main Aug 10, 2026
40 checks passed
@clydin

clydin commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

This PR was merged into the repository. The changes were merged into the following branches:

@clydin
clydin deleted the perf/buffer-sourcemap-fast-path branch August 10, 2026 17:38
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 area: performance Issues related to performance target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants