feat: Vite 8 support via vite-plugin-inspect v12 and devtools-kit RPC#1085
feat: Vite 8 support via vite-plugin-inspect v12 and devtools-kit RPC#1085skirtles-code wants to merge 1 commit intovuejs:mainfrom
Conversation
✅ Deploy Preview for vue-devtools-docs canceled.
|
@vue/devtools-applet
@vue/devtools-core
@vue/devtools
@vue/devtools-api
@vue/devtools-kit
@vue/devtools-electron
@vue/devtools-shared
@vue/devtools-ui
vite-plugin-vue-devtools
commit: |
| resolvers: [ElementPlusResolver()], | ||
| }), | ||
| inspect(), | ||
| // inspect(), |
There was a problem hiding this comment.
I used this playground to test my changes.
I had to remove vite-plugin-inspect from the plugins because it caused an error:
[Vite DevTools] Error setting up plugin vite-plugin-inspect: Error: RPC function "vite-plugin-inspect:clear-module-transform" is already registered
We're already adding another copy of vite-plugin-inspect inside Vue DevTools, and it seems that v12.0.0-beta.1 isn't happy with that duplication.
As a side note, running the playground using pnpm run play from the project root proved problematic because turbo didn't play nicely with the authentication stuff in Vite DevTools. I had to run pnpm run dev from packages/playground/basic instead.
| async getGraphModules(): Promise<ModuleInfo[]> { | ||
| const meta = await rpc.getMetadata() | ||
| const rpc = getRpc() | ||
| const meta = await rpc?.invokeLocal('vite-plugin-inspect:get-metadata' as any) |
There was a problem hiding this comment.
I'm not aware of a good way to type these calls to invokeLocal. I've used as any as that's what Nuxt DevTools does.
| } | ||
|
|
||
| return [ | ||
| ViteDevTools(), |
There was a problem hiding this comment.
This is a hack and definitely not right.
I'm using devtools.setup to get rpc, but that function isn't called by default. I've not been able to figure out what the correct way to trigger that function is. Adding the Vite DevTools plugin here does the job, but that also adds the UI widget, which we don't want.
It'll also fail if something else adds another copy of the Vite DevTools plugin.
Related issue: #1068
Background
Creating a project with
create-vuewill use Vite 8. While everything appears to work, we get warnings when installing packages.npm:
pnpm:
The 3 packages
vite-plugin-inspect@11,vite-dev-rpcandvite-hot-clientdon't officially support Vite 8 in their version ranges. They do appear to work correctly, so it isn't clear to me whether there's a good technical reason why new releases of those packages couldn't be made with Vite 8 added to thepeerDependencies.This PR
Of those 3 dependencies,
vite-plugin-inspectis the only one we depend on directly. There is currently a12.0.0-beta.1release, which does support Vite 8. This PR attempts some initial work to migrate to12.0.0-beta.1, but it isn't complete and I don't currently see a way to get where we need to be.It is based on the equivalent migration of the Nuxt DevTools. See antfu-collective/vite-plugin-inspect#167 (comment) for more information.
Major version
Migrating to
vite-plugin-inspectv12 is going to require a major version release of Vue DevTools, asvite-plugin-vue-devtoolswill only support Vite 8. It isn't clear to me that a major version, with the downstream pain that will cause, is actually the right way forward.But without a version of
vite-plugin-inspectthat supports Vite 6, 7 & 8, I think we're going to be forced into a major version release.Remaining problems
I'll add some inline review comments to explain some of the remaining problems.
Testing with
pkg-pr-newsuggests that this PR does resolve the peer dependency warnings. While all functionality is 'working' to some extent, there are several significant blockers to getting this merged.The two biggest problems currently are:
vite-plugin-inspectin an iframe).