Skip to content

feat(devframe): dev-time RPC bridge via createVitePlugin({ devMiddleware }) and Nuxt module#329

Merged
antfu merged 1 commit intomainfrom
antfu/nuxt-dev-middleware
May 11, 2026
Merged

feat(devframe): dev-time RPC bridge via createVitePlugin({ devMiddleware }) and Nuxt module#329
antfu merged 1 commit intomainfrom
antfu/nuxt-dev-middleware

Conversation

@antfu
Copy link
Copy Markdown
Member

@antfu antfu commented May 11, 2026

Description

Adds a devMiddleware option to createVitePlugin so any Vite-based host (Nuxt, Astro, SolidStart, plain Vite) can own the SPA while devframe owns the RPC + WS backend — the plugin starts createDevServer in bridge mode on a resolved port and serves <base>__connection.json via Vite middleware. The @devframes/nuxt module gains a matching devframe + devMiddleware pair (default-on whenever devframe is set, auto-reads nuxt.options.devServer.host so nuxt dev --host propagates, clean teardown on Vite restart / Nuxt close). createDevServer's distDir is now truly optional — bridge mode skips the sirv SPA mount. New DF0033 (warn) covers bridge startup failures, with docs added under docs/errors/ and a new "Dev-time RPC bridge" section in the Nuxt guide.

Linked Issues

Additional context

This unblocks Nuxt-based devtools (e.g. eslint-config-inspector) running nuxt dev without hand-rolling a ~40-line Vite plugin per project. Backwards compatible: createVitePlugin defaults devMiddleware: false, and the Nuxt module's bridge is gated on a devframe being provided.

🤖 Generated with Claude Code

…are }) and Nuxt module

Adds `devMiddleware` to `createVitePlugin` so a host Vite/Nuxt/Astro app
can own the SPA while devframe owns the RPC + WS backend. The plugin
starts `createDevServer` in bridge mode (no sirv mount) on a resolved
port and serves `<base>__connection.json` via Vite middleware so the
host-served SPA can discover the WS endpoint.

The `@devframes/nuxt` module gains a matching `devframe` + `devMiddleware`
pair. Passing `devframe` is the only step required — the bridge defaults
on, auto-reads `nuxt.options.devServer.host` so `nuxt dev --host`
propagates, and tears down cleanly on Vite restart / Nuxt close.

`createDevServer`'s `distDir` is now truly optional (bridge mode). New
`DF0033` (warn) covers bridge startup failures.

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

netlify Bot commented May 11, 2026

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit b226dbe
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a01483f3905860008e4096b
😎 Deploy Preview https://deploy-preview-329--devfra.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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 11, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@vitejs/devtools@329
npm i https://pkg.pr.new/@vitejs/devtools-kit@329
npm i https://pkg.pr.new/@vitejs/devtools-rolldown@329
npm i https://pkg.pr.new/@vitejs/devtools-self-inspect@329

commit: b226dbe

@antfu antfu merged commit f255885 into main May 11, 2026
13 checks passed
@antfu antfu deleted the antfu/nuxt-dev-middleware branch May 11, 2026 03:28
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