feat!: migrate logs-sdk to nostics, bump devframe to v0.3#350
Conversation
`logs-sdk` has been renamed and rewritten as `nostics`. Devframe v0.3.0
is the first release on the new dep. Doing both together keeps
`ctx.diagnostics` (re-exported from devframe) and our internal
diagnostics backed by the same library.
API delta:
- `defineDiagnostics({ docsBase, codes })` + separate `createLogger()`
→ `defineDiagnostics({ docsBase, reporters, codes })`
- Code fields `message`/`hint`/`level` → `why`/`fix` (no `level`)
- `logger.CODE(params).throw() / .log()` → `diagnostics.CODE.throw(params) / .report(params)`
- `cause` moves from a 2nd arg to inside the params object
For plugin authors, `ctx.diagnostics.logger.CODE` is now a proxy that
resolves directly to a `nostics` handle, so emission is
`ctx.diagnostics.logger.CODE.throw(params)` instead of the old
`logger.CODE(params).throw()` shape.
# Conflicts: # devframe # pnpm-lock.yaml # pnpm-workspace.yaml
commit: |
`tsdown`'s client/server split in devframe v0.2.3+ emits the
`DevToolsRpc{Server,Client}Functions` and `DevToolsRpcSharedStates`
interfaces twice — once in the canonical `devframe-*.d.mts` chunk and
again in the `index-*.d.mts` chunk consumed by `devframe/client`. The
duplicate declarations are seen by TypeScript as separate identities,
so `declare module '@vitejs/devtools-kit'` augmentations applied to
the canonical interface don't reach client-side consumers.
The patch replaces the duplicate declarations in the client chunk with
type imports from the canonical chunk, so both sides resolve to the
same interface. Remove the patch once devframe ships a fix upstream.
# Conflicts: # packages/rolldown/src/node/diagnostics.ts # packages/rolldown/src/node/utils/json-parse-stream.ts # pnpm-lock.yaml
|
|
||
| // Log without throwing | ||
| ctx.diagnostics.logger.MYP0002().log() | ||
| throw ctx.diagnostics.logger.MYP0001.throw({ name: 'foo' }) |
There was a problem hiding this comment.
I'm realizing, after much trial and error, that it's not possible to type the .throw() call to have never. In TS, only an explicit root-lever const fn: () => never = ... works. Maybe we should just remove it and tell people to use throw diagnostics.X.report() (already works)
There was a problem hiding this comment.
In that case, do you think we should just have throw diagnostics.X()?
There was a problem hiding this comment.
I think that yeah, no need to have an object and we could always add methods to it if we need in the future. The only thing I can think about is being able to create the Diagnostic without reporting but we currently don't support it and seems exactly like what we want to avoid
Initially I thought of report() and throw() because I wanted to avoid a side effect on the constructor: new diags.X.() -> eslint would complain. But now that we got rid of the new, it's a function invocation, so side effects are okay!
Description
logs-sdkhas been renamed and rewritten asnostics. Devframe v0.3.0 is the first release that consumes the new dep, so this PR bumps both together to keepctx.diagnostics(re-exported from devframe) and the in-repodiagnosticsfiles backed by the same library and emission API.API delta (also applies to plugin-facing
ctx.diagnostics):defineDiagnostics({ docsBase, codes })+ separatecreateLogger()→defineDiagnostics({ docsBase, reporters, codes })(no morecreateLogger).message/hint/level→why/fix(nolevel).logger.CODE(params).throw() / .log()→diagnostics.CODE.throw(params) / .report(params)(andctx.diagnostics.logger.CODEis now a proxy that resolves directly to the nostics handle).causemoves from a 2nd arg into the params object.Convention docs (
AGENTS.md/CLAUDE.md), plugin-author docs (docs/kit/diagnostics.md,docs/errors/index.md), and the vite-devtools-kit skill have been rewritten to teach the new API.Linked Issues
Additional context
Verification:
pnpm sync --check✓ (devframe atv0.3.0),pnpm lint✓,pnpm test✓ (190/190),pnpm build✓. The remainingpnpm typecheckerrors are pre-existing RPC-type registration issues unrelated to this migration.