Skip to content

feat: migrate warnings/errors to structured diagnostics via logs-sdk#285

Draft
antfu wants to merge 2 commits intomainfrom
antfu/migrate-logs-sdk
Draft

feat: migrate warnings/errors to structured diagnostics via logs-sdk#285
antfu wants to merge 2 commits intomainfrom
antfu/migrate-logs-sdk

Conversation

@antfu
Copy link
Copy Markdown
Member

@antfu antfu commented Apr 9, 2026

Description

Migrate all node-side console.warn/console.error/throw new Error patterns to structured diagnostics using @antfu/experimental-logs-sdk. Each error/warning now gets a unique code (DTK0001DTK0032 for core/rpc, RDDT0001RDDT0002 for rolldown) with auto-generated docs URLs and ANSI-formatted console output.

  • Add @antfu/experimental-logs-sdk (^0.0.3) as dependency to rpc, core, and rolldown packages
  • Create diagnostics.ts in each package with defineDiagnostics() + createLogger() — flat code keys like DTK0001 (no prefix option)
  • Migrate 34 error/warning sites across 19 source files to use the logger
  • Add 35 VitePress documentation pages under docs/errors/ (one per code + index) with cause, fix, examples, and source links
  • Add "Error Reference" sidebar section to VitePress config
  • Update test assertions in packages/rpc/src/dumps.test.ts to match new CodedError message format

Linked Issues

Additional context

  • Only node-side code is migrated; client-side Vue components/webcomponents are excluded
  • Code prefixes: DTK = DevTools Kit (rpc + core), RDDT = Rolldown DevTools, VDT reserved for the vite package
  • The rpc package uses plainFormatter (no ansis dependency); core and rolldown use ansiFormatter

Replace inconsistent console.warn/error/throw patterns with structured
diagnostics using @antfu/experimental-logs-sdk. Each error gets a unique
code (DTK0001-DTK0032 for core/rpc, RDDT0001-RDDT0002 for rolldown)
with auto-generated docs URLs and ANSI-formatted output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 9, 2026

Open in StackBlitz

@vitejs/devtools

npm i https://pkg.pr.new/@vitejs/devtools@285

@vitejs/devtools-kit

npm i https://pkg.pr.new/@vitejs/devtools-kit@285

@vitejs/devtools-rolldown

npm i https://pkg.pr.new/@vitejs/devtools-rolldown@285

@vitejs/devtools-rpc

npm i https://pkg.pr.new/@vitejs/devtools-rpc@285

@vitejs/devtools-self-inspect

npm i https://pkg.pr.new/@vitejs/devtools-self-inspect@285

commit: 35ff95d

@antfu antfu marked this pull request as draft April 9, 2026 07:58
TypeScript doesn't narrow types after `logger.CODE().throw()` because
the return type inference doesn't propagate `never` through the chained
call. Adding `throw` before the expression fixes control flow analysis.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant