Problem
Angular's esbuild application builder has an internal instrumentForCoverage filter that drives Istanbul instrumentation, but it's not in the public schema (additionalProperties: false) — only the Karma builder uses it for unit tests. So there's no supported way to instrument the served bundles for E2E, and @cypress/code-coverage can't produce LCOV for Sonar.
The usual workaround patches node_modules/@angular/build directly, which is wiped on every install and pinned to one Angular version.
Proposal
Expose it through the native-federation builder, which already owns both call sites into Angular's builder. Add instrumentForCoverage: boolean (+ optional codeCoverageExclude: string[]) to the adapter schema and inject the filter into:
- the dev-server / E2E path — inside
createInternalAngularBuilder, before buildApplicationInternal (Cypress's path; must go here because serveWithVite re-fetches options as JSON, which can't carry a function);
- the plain build path — spread onto
buildApplication's options.
Opt-in via angular.json, no node_modules patch:
Notes
- Filter logic is copied from
@angular/build's karma/coverage.ts (not imported — those helpers aren't in @angular/build/private and sit on an unstable path). projectSourceRoot comes from context.getProjectMetadata(); excludes use built-in fs.globSync (no new dependency).
- Verified against
@angular/build@22.0.0; internals match the 21.2.x line the original patch targeted.
- Risk:
instrumentForCoverage is a non-SemVer internal option — if Angular drops it, injection becomes a no-op. Worth re-checking on Angular major bumps.
Problem
Angular's esbuild application builder has an internal
instrumentForCoveragefilter that drives Istanbul instrumentation, but it's not in the public schema (additionalProperties: false) — only the Karma builder uses it for unit tests. So there's no supported way to instrument the served bundles for E2E, and@cypress/code-coveragecan't produce LCOV for Sonar.The usual workaround patches
node_modules/@angular/builddirectly, which is wiped on every install and pinned to one Angular version.Proposal
Expose it through the native-federation builder, which already owns both call sites into Angular's builder. Add
instrumentForCoverage: boolean(+ optionalcodeCoverageExclude: string[]) to the adapter schema and inject the filter into:createInternalAngularBuilder, beforebuildApplicationInternal(Cypress's path; must go here becauseserveWithVitere-fetches options as JSON, which can't carry a function);buildApplication's options.Opt-in via
angular.json, nonode_modulespatch:Notes
@angular/build'skarma/coverage.ts(not imported — those helpers aren't in@angular/build/privateand sit on an unstable path).projectSourceRootcomes fromcontext.getProjectMetadata(); excludes use built-infs.globSync(no new dependency).@angular/build@22.0.0; internals match the 21.2.x line the original patch targeted.instrumentForCoverageis a non-SemVer internal option — if Angular drops it, injection becomes a no-op. Worth re-checking on Angular major bumps.