Skip to content

fix(vite-plugin-angular): aggregate and locate template diagnostics on the default compilation path#2354

Merged
brandonroberts merged 1 commit into
betafrom
fix/accumulate-template-diagnostics
May 30, 2026
Merged

fix(vite-plugin-angular): aggregate and locate template diagnostics on the default compilation path#2354
brandonroberts merged 1 commit into
betafrom
fix/accumulate-template-diagnostics

Conversation

@brandonroberts

@brandonroberts brandonroberts commented May 30, 2026

Copy link
Copy Markdown
Member

PR Checklist

Diagnostics on the default (non Compilation API) compilation path were reported one file at a time from the transform hook, which threw on the first errored file — so a production build aborted before the remaining files were ever checked, and build mode collected no diagnostics at all. Reported messages also discarded the source location and mishandled ts.DiagnosticMessageChain (warnings rendered as [object Object], error chains were truncated).

Closes #

Affected scope

  • Primary scope: vite-plugin-angular
  • Secondary scopes: none

Recommended merge strategy for maintainer [optional]

  • Squash merge
  • Rebase merge
  • Other

What is the new behavior?

Diagnostics are now accumulated across every emitted file and reported together, at parity with the Compilation API path:

  • Aggregate, don't abort. Per-file diagnostics are collected for every emitted file (no longer watch-only) and reported once in a new buildEnd hook, instead of aborting the build at the first errored module. transform still reports per-module in watch/serve so the dev overlay points at the edited file.
  • Locations. Every diagnostic is formatted as file:line:column: message, mirroring the Compilation API path's groupDiagnosticsByFile. Location-less (program-wide / option) diagnostics fall back to the bare message.
  • Message chains. Both errors and warnings are flattened via flattenDiagnosticMessageText, fixing the [object Object] warning output and truncated error chains.

Reporting is unconditional; which diagnostics exist is still governed by disableTypeChecking inside getDiagnosticsForSourceFile — syntactic-only by default, full semantic + Angular template diagnostics when type checking is enabled. So with the default config, builds now surface syntax errors with file:line:column, and the disableTypeChecking: false opt-in reaches full parity with the Compilation API path.

Test plan

Ran for the affected package:

  • npx nx test vite-plugin-angular — 1171 passed, 23 skipped (incl. 6 new unit tests for collectEmittedDiagnostics and formatDiagnosticWithLocation)

  • npx tsc --noEmit -p packages/vite-plugin-angular/tsconfig.lib.json — clean

  • npx prettier --check on the changed files — clean

  • nx format:check

  • pnpm build

  • pnpm test

  • Manual verification

(Full-repo format:check / build and end-to-end manual verification left for CI / maintainer.)

Does this PR introduce a breaking change?

  • Yes
  • No

With the default config (disableTypeChecking: true), build mode now surfaces syntactic errors that were previously emitted silently. This is a correctness fix rather than a breaking change: a file with a TypeScript syntax error already produces broken output and a non-running app, so failing the build reports an existing failure instead of breaking working software. Semantic/template type-checking remains opt-in and unchanged by default.

Other information

The aggregation and buildEnd reporting are shared by both compilation paths, so the Compilation API path also moves from per-file transform reporting to aggregated buildEnd reporting in build mode.

🤖 Generated with Claude Code

…n the default compilation path

The default (non Compilation API) path reported diagnostics one file at a
time from the `transform` hook and threw on the first errored file, so a
production build aborted before the remaining files were ever checked, and
build mode collected no diagnostics at all. Reported messages also dropped
the source location and mishandled message chains (`[object Object]`
warnings, truncated error chains).

Accumulate diagnostics across every emitted file and report them together:

- Collect per-file diagnostics for every emitted file (not just watch mode)
  and report them once in a new `buildEnd` hook instead of aborting at the
  first errored module. `transform` still reports per-module in watch/serve
  so the dev overlay points at the edited file.
- Format every diagnostic as `file:line:column: message`, matching the
  Compilation API path's `groupDiagnosticsByFile` output. Location-less
  diagnostics fall back to the bare message.
- Flatten message chains via `flattenDiagnosticMessageText` for both errors
  and warnings, fixing the `[object Object]` warning output.

Reporting is unconditional; which diagnostics exist is still governed by
`disableTypeChecking` inside `getDiagnosticsForSourceFile` (syntactic-only by
default, full semantic + Angular template when type checking is enabled), so
the default config now surfaces syntax errors at build time with locations
while the type-checking opt-in reaches parity with the Compilation API path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented May 30, 2026

Copy link
Copy Markdown

Deploy Preview for analog-docs ready!

Name Link
🔨 Latest commit c9c0555
🔍 Latest deploy log https://app.netlify.com/projects/analog-docs/deploys/6a1b425aaaee7a0008197b50
😎 Deploy Preview https://deploy-preview-2354--analog-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented May 30, 2026

Copy link
Copy Markdown

Deploy Preview for analog-blog ready!

Name Link
🔨 Latest commit c9c0555
🔍 Latest deploy log https://app.netlify.com/projects/analog-blog/deploys/6a1b425a493ad500081f8aa2
😎 Deploy Preview https://deploy-preview-2354--analog-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented May 30, 2026

Copy link
Copy Markdown

Deploy Preview for analog-app ready!

Name Link
🔨 Latest commit c9c0555
🔍 Latest deploy log https://app.netlify.com/projects/analog-app/deploys/6a1b425a3354d9000805b394
😎 Deploy Preview https://deploy-preview-2354--analog-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors diagnostic reporting in the Angular Vite plugin to support deferred build-mode reporting. Two new utility functions are exported: collectEmittedDiagnostics() aggregates per-file TypeScript/Angular errors and warnings, and formatDiagnosticWithLocation() formats diagnostics as file:line:column: message. The plugin now uses a buildEnd() hook to report all build-mode diagnostics together at the end of the build process, while deferring per-module errors from transform() in production builds. The legacy compilation path's warning formatting is updated to use the new location-aware utility.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commit style with the vite-plugin-angular scope and clearly summarizes the main change: aggregating and locating diagnostics on the default compilation path.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly relates to the changeset, detailing diagnostic reporting changes in the vite-plugin-angular package with specific behavior improvements, test results, and impact analysis.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the scope:vite-plugin-angular Changes in @analogjs/vite-plugin-angular label May 30, 2026
@brandonroberts brandonroberts merged commit c7947ef into beta May 30, 2026
25 checks passed
@brandonroberts brandonroberts deleted the fix/accumulate-template-diagnostics branch May 30, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:vite-plugin-angular Changes in @analogjs/vite-plugin-angular

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant