Skip to content

fix(angular-rspack): keep incremental rebuild state warm when skipTypeChecking is enabled - #36972

Merged
leosvelperez merged 2 commits into
nrwl:masterfrom
skrtheboss:fix/angular-rspack-skip-type-checking-incremental-rebuild
Sep 10, 2026
Merged

fix(angular-rspack): keep incremental rebuild state warm when skipTypeChecking is enabled#36972
leosvelperez merged 2 commits into
nrwl:masterfrom
skrtheboss:fix/angular-rspack-skip-type-checking-incremental-rebuild

Conversation

@skrtheboss

Copy link
Copy Markdown
Contributor

Current Behavior

With skipTypeChecking: true set on @nx/angular-rspack's AngularRspackPlugin, every incremental rebuild re-emits the entire program instead of only the changed file(s), no matter how small the edit is. On a real-world app (~6000 source files) this makes single-file rebuilds take 20-55 seconds instead of the expected 1-3 seconds.

This happens because skipTypeChecking: true strips the Semantic diagnostic mode from what's passed to AngularCompilation#diagnoseFiles(). Semantic mode is the only path that reaches NgCompiler#ensureAnalyzed()recordSuccessfulAnalysis(), which is the only place the compiler's incremental state advances from Fresh to Analyzed. Without that transition, IncrementalCompilation#safeToSkipEmit() always returns false, forcing a full re-emit on every rebuild.

See #36970 for the full root-cause trace with source references.

Expected Behavior

skipTypeChecking: true should only suppress surfacing Semantic (type-checking) diagnostics - it should not disable the Angular compiler's incremental-emit optimization. Incremental rebuilds should re-emit only the files actually affected by a change, same as when skipTypeChecking is false.

#createDiagnosticsPromise() now always fires a second, silent diagnoseFiles(DiagnosticModes.Semantic) call whenever skipTypeChecking is true, purely for its incremental-state side effect. Its result is fully discarded and can never surface or fail the build - the diagnostics actually surfaced to users (Option/Syntactic) are unchanged. Both calls run concurrently via Promise.all, verified safe since they touch disjoint internal state (the surfaced call never requests Semantic, so it never touches the diagnosticCache/getDiagnosticsForFile path the silent call exercises).

Validated against a real ~6000-file app: cold builds are unaffected (as expected), and every subsequent incremental rebuild dropped from 20-55s to 2-4s, with the correct "affected files" count reported.

Related Issue(s)

Fixes #36970

@skrtheboss
skrtheboss requested a review from a team as a code owner September 9, 2026 17:09
@netlify

netlify Bot commented Sep 9, 2026

Copy link
Copy Markdown

👷 Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b1cbbff

@netlify

netlify Bot commented Sep 9, 2026

Copy link
Copy Markdown

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b1cbbff

@nx-cloud

nx-cloud Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit b1cbbff

Command Status Duration Result
nx affected --targets=lint,oxlint,test,build,e2... ✅ Succeeded 21m 29s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 29s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 13s View ↗
nx-cloud record -- nx format:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-10 12:04:12 UTC

@leosvelperez leosvelperez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Change looks good, but let's simplify the added comments.

Comment thread packages/angular-rspack/src/lib/plugins/angular-rspack-plugin.ts Outdated
Comment thread packages/angular-rspack/src/lib/plugins/angular-rspack-plugin.spec.ts Outdated
Comment thread packages/angular-rspack/src/lib/plugins/angular-rspack-plugin.spec.ts Outdated
@leosvelperez leosvelperez self-assigned this Sep 10, 2026
…eChecking is enabled

Problem:
`skipTypeChecking: true` strips the Semantic diagnostic mode from
`AngularCompilation#diagnoseFiles()`. Semantic mode is the only path that
reaches `NgCompiler#ensureAnalyzed()`, which is the only place the Angular
compiler's incremental state advances from `Fresh` to `Analyzed`. Without
that transition, `IncrementalCompilation#safeToSkipEmit()` always returns
false, so every incremental rebuild re-emits the entire program instead of
only the changed files - regardless of how small the edit is. On larger
apps this turns single-file rebuilds into 20s+ full re-emits.

Solution:
`#createDiagnosticsPromise()` now always fires a second, silent
`diagnoseFiles(DiagnosticModes.Semantic)` call whenever `skipTypeChecking`
is true, purely for its incremental-state side effect. Its result (and any
errors) are fully discarded and can never surface or fail the build - the
surfaced diagnostics (`Option`/`Syntactic`) are unchanged from before. Both
calls run concurrently via `Promise.all`, since they're verified to touch
disjoint internal state.

Closes nrwl#36970
@skrtheboss
skrtheboss force-pushed the fix/angular-rspack-skip-type-checking-incremental-rebuild branch from 8c801d6 to b1cbbff Compare September 10, 2026 11:15
@skrtheboss

Copy link
Copy Markdown
Contributor Author

@leosvelperez Thank you for the review. I have applied your suggestions, let me know if there is anything else I should adjust 👍

@leosvelperez leosvelperez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@leosvelperez
leosvelperez merged commit c5ca8c3 into nrwl:master Sep 10, 2026
17 checks passed
@skrtheboss
skrtheboss deleted the fix/angular-rspack-skip-type-checking-incremental-rebuild branch September 10, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

skipTypeChecking: true disables Angular incremental rebuild optimization, causing full re-emit on every rebuild

2 participants