Skip to content

refactor(@angular/build): use standalone Instrumenter API for code coverage#33571

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:feat/istanbul-standalone-instrument
Open

refactor(@angular/build): use standalone Instrumenter API for code coverage#33571
clydin wants to merge 1 commit into
angular:mainfrom
clydin:feat/istanbul-standalone-instrument

Conversation

@clydin

@clydin clydin commented Jul 15, 2026

Copy link
Copy Markdown
Member

This refactors the code coverage instrumentation in the esbuild pipeline to bypass Babel and use the standalone Instrumenter API from istanbul-lib-instrument directly. The instrumenter is only used by the Karma/Jasmine testing implementation.

Since first-party code coverage instrumentation and third-party Angular linking are almost always mutually exclusive for any given file, we do not benefit from composing them into a single Babel pass. Using the high-level standalone API simplifies the transformer worker and allows us to completely remove the custom add-code-coverage.ts Babel plugin.

@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 refactors code coverage instrumentation by removing the custom Babel plugin and instead using istanbul-lib-instrument's createInstrumenter directly in javascript-transformer-worker.ts before Babel transformations. The review feedback highlights a critical issue where the input source map is not passed to instrumentSync, which breaks source-mapped code coverage reports, and provides a code suggestion to extract and pass the inline source map.

Comment thread packages/angular/build/src/tools/esbuild/javascript-transformer-worker.ts Outdated
…verage

This refactors the code coverage instrumentation in the esbuild pipeline to bypass Babel and use the standalone `Instrumenter` API from `istanbul-lib-instrument` directly.
The instrumenter is only used by the Karma/Jasmine testing implementation.

Since first-party code coverage instrumentation and third-party Angular linking are almost always mutually exclusive for any given file, we do not benefit from composing them into a single Babel pass. Using the high-level standalone API simplifies the transformer worker and allows us to completely remove the custom `add-code-coverage.ts` Babel plugin.
@clydin clydin force-pushed the feat/istanbul-standalone-instrument branch from 609c25d to 7d5d0cf Compare July 15, 2026 14:21
@clydin clydin added the target: minor This PR is targeted for the next minor release label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant