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?
|
I'm finding some problems with the current structure:
|
Good catch, I'll improve them. |
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