fix(devtools): don't scope dock plugin with { server: false }#1006
Conversation
Deploying nuxt-devtools with
|
| Latest commit: |
b2665eb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c4c25281.nuxt-devtools.pages.dev |
| Branch Preview URL: | https://fix-dock-devtools-applytoenv.nuxt-devtools.pages.dev |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThis PR adds a new SPA playground (Nuxt config with ssr: false, package.json, .npmrc, tsconfig, and an app.vue), removes the Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/devtools/src/module-main.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. playgrounds/spa/app.vueESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. playgrounds/spa/nuxt.config.tsESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.
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. Comment |
Under Nuxt 5 / Vite 8 (and Nuxt 4 with `experimental.viteEnvironmentApi`),
`addVitePlugin(plugin, { server: false })` makes `@nuxt/kit` wrap the
plugin in an `applyToEnvironment` shell. That wrapper plugin lacks a
`devtools` property, so `@vitejs/devtools`'s plugin filter
(`viteConfig.plugins.filter(p => "devtools" in p)`) silently drops it
and the Nuxt DevTools dock entry never appears in the Vite DevTools
dock bar.
The original client-vs-server RPC race that motivated the scoping in
b5f9f8a is already prevented by the `if (devtoolsKitCtx) return`
guard inside `connectDevToolsKit`, so the plugin-level scoping is
unnecessary.
Adds a `spa` playground (`ssr: false` + `experimental.viteEnvironmentApi: true`)
to the e2e matrix as a hard regression test: under this combo on Nuxt 4 the
dock-missing bug reproduces identically to the Nuxt 5 SPA scenario the
report was filed against, so the existing `iframe.spec.ts` fixture
turns RED when `{ server: false }` is reintroduced.
5d9f2b6 to
b2665eb
Compare
Why
Under Nuxt 5 / Vite 8 — and Nuxt 4 with
experimental.viteEnvironmentApi: true— the@nuxt/devtoolsdock entry disappears from the Vite DevTools dock bar. UnoCSS, Unhead, andvite-plugin-inspectregister dock entries fine; only ours goes missing.The cause is the
{ server: false }scoping passed toaddVitePluginfor the dock plugin. Whenconfig.environments.{ssr,client}is populated atvite:extendtime,@nuxt/kit'saddVitePluginroutes the plugin through itsapplyToEnvironmentwrapper. The wrapper is a separate Vite plugin object that does not carry thedevtoolsproperty, so@vitejs/devtools's plugin filter (viteConfig.plugins.filter(p => "devtools" in p)) silently drops it and the docksetup(ctx)never runs.The original "server Vite overwrites client Vite RPC" race that motivated the scoping in #977 is already handled by the
if (devtoolsKitCtx) returnguard insideconnectDevToolsKititself, so the plugin-level scoping was redundant safety that turned into a regression vector.Dropping the scoping restores the dock entry in all Nuxt 4/5 × SSR/SPA combinations without re-introducing the RPC race.
A new
playgrounds/spa(withssr: falseandexperimental.viteEnvironmentApi: true) is added to the e2e matrix as a hard regression test: under this combo on Nuxt 4 the bug reproduces identically to the Nuxt 5 SPA scenario from the report, so the existingiframe.spec.tsfixture goes RED whenever{ server: false }sneaks back in.This PR was created with the help of an agent.