feat(devtools): enable dev server integration - #23333
Conversation
There was a problem hiding this comment.
Pull request overview
Integrates @vitejs/devtools more deeply into Vite Core so the experimental devtools option can activate DevTools for both dev-server inspection (serve) and build analysis (build), aligning behavior with the new async “plugin array” integration contract introduced in @vitejs/devtools 0.6.0.
Changes:
- Updates Vite’s DevTools integration to load an async plugin array and preserve
pre/normal/postordering. - Changes DevTools enablement semantics so a config object is enabled by default unless
enabled: false. - Bumps DevTools-related dependencies (plus playground + docs) to
@vitejs/devtools^0.6.0and adds opt-in integration packages in the playground.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Updates lockfile for @vitejs/devtools@0.6.0 and its new dependency graph. |
| playground/devtools/vite.config.ts | Adjusts playground DevTools config to exercise serve-mode integration via apply: 'serve'. |
| playground/devtools/package.json | Adds @vitejs/devtools-vite and @vitejs/devtools-rolldown to demonstrate opt-in integrations. |
| packages/vite/src/node/plugins/index.ts | Loads DevTools integration as a plugin set and inserts into Vite’s plugin pipeline. |
| packages/vite/src/node/config.ts | Updates DevTools config resolution semantics and carries through apply. |
| packages/vite/package.json | Bumps Vite’s DevTools dependency + peer dependency requirement. |
| docs/config/shared-options.md | Updates docs to reflect serve + build behavior and required opt-in integration packages. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const isDevToolsPluginRegistered = | ||
| config.command === 'serve' && | ||
| [...prePlugins, ...normalPlugins, ...postPlugins].some( | ||
| (plugin) => plugin.name === 'vite:devtools:server', | ||
| ) |
There was a problem hiding this comment.
Are there a reason for the user to add the devtools plugin manually?
There was a problem hiding this comment.
@vitejs/devtools currently exposes the DevTools() plugin for manual registration. Once dev-mode support is officially available, we can update the docs to recommend the built-in integration for users on Vite 8.3.0+ instead of adding the plugin manually.
There was a problem hiding this comment.
Does that mean all options in DevTools will be moved to devtools option?
There was a problem hiding this comment.
Yeah, I think the ideal use case would be
export default defineConfig({
devtools: true,
plugins: [
// ideally no manually ViteDevTools()
VueDevTools(),
NuxtDevTools(),
XxxDevTools(),
]
})|
I'm finding some problems with the current structure:
|
Good catch, I'll improve them. |
sapphi-red
left a comment
There was a problem hiding this comment.
As long as the option lives in Vite, I guess the complexity around the plugin resolution is inevitable.
@bluwy Do you have any thoughts?
|
My high-level instinct is that we should have as little logic on the Vite side as possible to decouple Vite and Vite DevTools, so they can keep evolving without trapping each other. If the Imagine a case where a user has the Vue DevTools plugin installed in the |
|
Thanks @antfu and @sapphi-red — I’ve updated both implementations based on your feedback. Changes in this PR:
Changes in vitejs/devtools#549:
Please give this a final check. If everything looks good, I’ll release Vite DevTools 0.7 and mark this PR as ready to merge. 🙏 |
I was thinking of a case where a meta-framework wants to change the value, but that reasoning makes sense to me. |
I'm not really sure what you mean. I guess the PR has changed since you last commented. The current structure of how the types is re-exported seems fine to me though. |
sapphi-red
left a comment
There was a problem hiding this comment.
Sorry, after your update, I noticed about this and was thinking of how to solve it:
https://github.com/vitejs/vite/pull/23333/changes#r3923113643
The problem there was the following circular dep:
The original implementation solved this by breaking the first point. Anthony's suggestion solved this by breaking the third point. |
|
Thanks for the thorough review, @sapphi-red! I’ve addressed all your feedback. Could you take one final look? |
| export type { | ||
| DevToolsConfig, | ||
| ResolvedDevToolsConfig, | ||
| } from '@vitejs/devtools/config' |
There was a problem hiding this comment.
One idea about this, since @vitejs/devtools deps on vite while vite is not depend directly on @vitejs/devtools, what we can do is that we define an empty config interface in Vite:
// Augment by `@vitejs/devtools`
export interface DevToolsConfig {}
export interface ResolvedDevToolsConfig {}and in @vitejs/devtools, we do
declare module 'vite' {
interface DevToolsConfig {
foo: string,
bar: ...
}
interface ResolvedDevToolsConfig {}
}I don't know which approach would be more robust, just an idea I haven't tested
There was a problem hiding this comment.
I think that is better if we can remove all @vitejs/devtools import from Vite core. But since that exists, we need to keep @vitejs/devtools as a peer dep, so I think it won't simplify much.
|
/ecosystem-ci run |
@vitejs/plugin-legacy
vite
commit: |
|
/ecosystem-ci run vite-plugin-svelte |
|
📝 Ran ecosystem CI on
✅ |
|
📝 Ran ecosystem CI on
✅ |
Background
Vite's experimental
devtoolsoption currently supports build-time analysis only. When enabled, Vite loads a single build integration plugin that configures Rolldown analysis and starts Vite DevTools after the build.Using Vite DevTools during development still requires users to register the
DevTools()plugin manually invite.config.ts. This creates two separate setup paths for development and build analysis.vitejs/devtools#541 prepares
@vitejs/devtoolsfor first-class Vite integration by:devtools.applywith'serve','build', and'all'DevToolsIntegration()return an async plugin arrayDevTools()plugins in serve modeThis PR is the corresponding Vite Core integration for
@vitejs/devtools0.6.0.Changes
@vitejs/devtools0.6.0.devtoolsintegration for bothserveandbuild.DevToolsIntegration().sortUserPlugins()helper to preserve each integration plugin'spre, normal, orpostenforcement order.DevTools()manually.devtools.applythrough the resolved DevTools configuration.enabled: falseis explicitly set.@vitejs/devtools-viteis required for dev-server inspection.@vitejs/devtools-rolldownis required for build analysis.serveandbuildby default.Breaking changes
These changes only affect the experimental
devtoolsoption.devtools: truenow enables DevTools during both development and production builds. Previously, it only enabled build-time analysis.To preserve the previous behavior:
A DevTools configuration object now enables the integration by default. Previously, an object without
enabled: truewas treated as disabled.Use
enabled: falseto disable it explicitly:The minimum supported
@vitejs/devtoolsversion is now 0.6.0 because Vite Core relies on the new async plugin-array integration contract.Build analysis and dev-server inspection remain opt-in integrations. Users need to install the corresponding package:
For build analysis:
Screenshot