You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(devtools): prefix client module resolution URL with effective Vite base - #1186
Clicking Inspect Vue component triggers a dynamic browser import for the bare module specifier vite-plugin-vue-tracer/client/vite-devtools. @vitejs/devtools / @devframes/hub default ctx.staticConfig.dock.clientModuleResolution to '/@id/{specifier}' (and initHub resets it after devtools.setup(ctx) runs), which causes the browser to fetch http://localhost:3000/@id/... at the site root instead of under Nuxt's mounted Vite base (by default /_nuxt/), receiving text/html instead of JavaScript.
This resolves Nuxt's effective client Vite base (viteConfig.server?.base -> viteConfig.base -> joinURL(app.baseURL, app.buildAssetsDir)) and applies <viteBase>@id/{specifier} to ctx.staticConfig.dock.clientModuleResolution on the client DevTools context (including after initHub via provideConnectionMeta and the configureServer post hook).
No actionable comments were generated in the recent review.
Walkthrough
The change adds a utility to resolve client module URLs from Vite base values or Nuxt app paths. The DevTools plugin applies the resolved URL during client setup and refreshes it before connection metadata generation and from a post-order server hook. Tests cover URL normalisation, dock configuration, plugin integration, and SSR setup.
This change makes the component inspector's picker import use the effective Vite base instead of the site root, which addresses the reported failure. No concrete merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the fix (prefixing the client module resolution URL with the effective Vite base) and the affected package (devtools). The changeset adds resolveClientModuleResolution and applyClientM…
Description check
The description states the bug (Inspect Vue component dynamic import resolving at the site root), links issue #1185, and explains the fix: resolving Nuxt's effective client Vite base and applying it t…
Linked Issues check
[#1185] requires the Inspect Vue component picker import to use Nuxt's effective Vite base (/_nuxt/ in the reported setup), not the site root. At the reviewed head, `packages/devtools/src/utils/clie…
Out of Scope Changes check
All changed files relate to the linked issue. module-main.ts wires the resolution into the DevTools Vite plugin lifecycle. utils/client-module-resolution.ts contains the URL resolution helpers. Th…
Full details: Title check
Explanation
The title names the fix (prefixing the client module resolution URL with the effective Vite base) and the affected package (devtools). The changeset adds resolveClientModuleResolution and applyClientModuleResolution, which compute the Vite base and apply it to ctx.staticConfig.dock.clientModuleResolution, so the title matches the main change. It is a single, concise sentence of 10 words.
Full details: Description check
Explanation
The description states the bug (Inspect Vue component dynamic import resolving at the site root), links issue #1185, and explains the fix: resolving Nuxt's effective client Vite base and applying it to ctx.staticConfig.dock.clientModuleResolution, including after initHub via provideConnectionMeta and the configureServer post hook. This matches the changes in module-main.ts and client-module-resolution.ts.
Full details: Linked Issues check
Explanation
[#1185] requires the Inspect Vue component picker import to use Nuxt's effective Vite base (/_nuxt/ in the reported setup), not the site root. At the reviewed head, packages/devtools/src/utils/client-module-resolution.ts builds <base>@id/{specifier}. Base precedence is viteServerBase, then viteBase, then joinURL(app.baseURL, app.buildAssetsDir), with /_nuxt/ as the default assets directory. applyClientModuleResolution writes this value to ctx.staticConfig.dock.clientModuleResolution. In packages/devtools/src/module-main.ts, the value is applied during devtools.setup(ctx). It is also re-applied in a configureServer post hook and wrapped around host.provideConnectionMeta. That covers the initHub reset described in the issue. The added test file (packages/devtools/test/client-module-resolution.test.ts) covers precedence, slash normalisation, and metadata output. I did not execute the tests or run the browser flow, so runtime behaviour is supported by source inspection only.
Full details: Out of Scope Changes check
Explanation
All changed files relate to the linked issue. module-main.ts wires the resolution into the DevTools Vite plugin lifecycle. utils/client-module-resolution.ts contains the URL resolution helpers. The new test file covers those helpers and the DevTools integration. No unrelated feature, refactor, or dependency change appears in the reviewed summary and the focused module-main.ts diff. The SSR guard (server.config.build?.ssr) and skipInSSR keep the change limited to the client context.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1185
Summary
Clicking Inspect Vue component triggers a dynamic browser import for the bare module specifier
vite-plugin-vue-tracer/client/vite-devtools.@vitejs/devtools/@devframes/hubdefaultctx.staticConfig.dock.clientModuleResolutionto'/@id/{specifier}'(andinitHubresets it afterdevtools.setup(ctx)runs), which causes the browser to fetchhttp://localhost:3000/@id/...at the site root instead of under Nuxt's mounted Vite base (by default/_nuxt/), receivingtext/htmlinstead of JavaScript.This resolves Nuxt's effective client Vite base (
viteConfig.server?.base->viteConfig.base->joinURL(app.baseURL, app.buildAssetsDir)) and applies<viteBase>@id/{specifier}toctx.staticConfig.dock.clientModuleResolutionon the client DevTools context (including afterinitHubviaprovideConnectionMetaand theconfigureServerpost hook).