How vitejs/devtools works
1. What this repo is
- This is a pnpm monorepo for the Vite DevTools ecosystem.
- The main product is a developer tooling platform that visualizes Vite/Rolldown internal state, build graphs, messages, terminals, and plugin data.
- The repo is split into reusable packages, feature-specific apps, examples, docs, and automated tests.
2. Primary architecture pattern
- The core design is a node-side plugin/runtime paired with a client-side UI.
- Data is collected in the host process, exposed through RPC/state channels, and rendered in a browser-based UI.
- Several packages follow the same pattern: a node layer gathers data, and an app or client layer renders it.
3. packages/kit: the shared SDK boundary
- packages/kit is the main abstraction layer for plugin authors.
- It defines the public API, types, utilities, and shared-state primitives used by other packages.
- It also contains client-side helpers for remote interaction and node-side helpers for creating devtools plugins from a Vite-style host context.
- Architecturally, this package is the contract layer between integrations and the core UI/runtime.
4. packages/core: the central runtime
- packages/core is the largest and most central package.
- Its node side contains CLI entrypoints, config, diagnostics, HTTPS, WebSocket transport, plugin registration, server startup, and RPC endpoints.
- Its client side contains the main devtools UI built from web components, including docks, command palette, messages, terminals, settings, toasts, JSON rendering, and floating UI.
- It supports both injection into another app and a standalone mode, which is an important deployment boundary.
5. Core data flow
- The node runtime collects diagnostics and runtime state, then publishes it through RPC and socket-based mechanisms.
- The client layer consumes that state and organizes it into dockable panels and views.
- Core’s internal state managers cover commands, docks, messages, terminals, confirmations, keybindings, popups, and persistent view state, which are the main interaction surfaces of the UI.
6. UI system and rendering model
- The core client UI is implemented with a web components / Vue-based component system.
- It has distinct subdomains for:
- dock layout and panel management,
- built-in views like settings/messages/terminals,
- JSON renderers for structured objects,
- floating popovers/tooltips,
- icons and display primitives.
- This makes the UI layer modular: the shell orchestrates layout while specific views render the actual data domains.
7. packages/ui: shared design primitives
- packages/ui is a smaller cross-package UI toolkit.
- It provides reusable visual components, composables, CSS, and UnoCSS configuration.
- This package is a presentation dependency rather than a runtime boundary; it standardizes look-and-feel across the ecosystem.
8. Feature packages: Vite, Rolldown, Self-Inspect
- packages/vite is a Vite-specific surface that exposes Vite environment and metadata info through RPC and renders a dedicated app.
- packages/rolldown is the build-analysis product: it has a richer application with session history, graph views, compare views, assets/chunks/modules/packages/plugins pages, and a worker for diffing.
- packages/self-inspect introspects the devtools itself, showing auth tokens, client scripts, registered plugins, docks, RPC functions, and shared-state keys.
- These packages share the same general shape: node RPC endpoints + client app pages/components + shared types.
9. Rolldown-specific architecture
- Rolldown is the most data-heavy subsystem.
- Its node side stores and reads build events/logs, manages sessions, and serves RPC endpoints for assets, chunks, modules, packages, plugins, and compare summaries.
- Its app side contains pages and specialized visualizations such as flamegraphs, treemaps, module flowmaps, graph views, search, and compare dashboards.
- A worker is used for diff computation, which keeps expensive comparison logic off the main UI thread.
10. packages/webext: browser-extension packaging
- packages/webext is the browser extension shell that wraps the devtools into extension targets.
- It contains background scripts, devtools panel/background pages, proxy/window coordination, and build scripts.
- This is the deployment layer for browser-based embedding, separate from the core rendering logic.
11. Examples as integration references
- The examples/ directory contains concrete plugin examples such as accessibility checking, file explorer, and git UI.
- Each example is split into a node plugin/backend and a playground UI for manual testing.
- These examples are important because they show how third-party tooling integrates with the kit/core contracts.
12. Testing and validation layers
- e2e/ contains end-to-end tests with a minimal Vite fixture to validate real integration behavior.
- packages/*/__tests__ and test/ cover package-level behavior and API snapshots.
- This suggests the repo treats both public API stability and runtime integration behavior as first-class concerns.
13. Documentation and release infrastructure
- docs/ is a full VitePress documentation site, including guides, kit docs, Rolldown docs, and error references.
- .github/workflows and the release scripts show automated CI/release pipelines, which matter because this repo ships multiple packages and generated artifacts.
- The repo is organized for publishable packages, not just a single app.
14. How to draw the architecture
- The clearest diagram is a layered system:
- Host integrations / plugins at the edge,
- Kit contracts in the middle,
- Node runtimes that collect state and expose RPC,
- Client apps/UI shells that render data,
- and deployment shells like the browser extension, standalone app, or example playgrounds.
- The main data path is: host/build process → node plugin/runtime → RPC/shared state → client UI components/views.
Main entry points: cli.ts Node Runtime · webcomponents/index.ts Client Shell · rpc/index.ts Core RPC · src/index.ts Kit SDK
Components 21
Contracts
Shared SDK and UI primitives
- Kit SDK · Public API, types, remote client, and node-side plugin helpers
packages/kit/src/index.ts - Shared State · Shared-state and event helpers used across integrations
packages/kit/src/utils/shared-state.ts - UI Toolkit · Cross-package visual components, composables, and UnoCSS theme
packages/ui/src/index.ts
Core Runtime
Central devtools runtime and client shell
- Node Runtime · CLI, config, diagnostics, transport, plugin registration, and RPC server
packages/core/src/node/cli.ts - Core RPC · Public and internal RPC endpoints for commands, messages, terminals, auth, and editor/finder actions
packages/core/src/node/rpc/index.ts - Core Plugins · Build, injection, server, and integration plugins that wire the runtime into hosts
packages/core/src/node/plugins/index.ts - Client Shell · Injectable and standalone client entrypoints for the main devtools UI
packages/core/src/client/webcomponents/index.ts - Dock System · Dock layout, entries, panels, groups, and sidebar orchestration
packages/core/src/client/webcomponents/components/dock/Dock.vue - Builtin Views · Settings, messages, terminals, command palette, confirmations, and popups
packages/core/src/client/webcomponents/components/views-builtin/ViewBuiltinSettings.vue - JSON Render · Structured object rendering catalog used by the client views
packages/core/src/client/webcomponents/json-render/index.ts - UI State · State managers for commands, docks, messages, terminals, keybindings, toasts, and popups
packages/core/src/client/webcomponents/state/commands.ts
Feature Apps
Vite, Rolldown, and self-inspection products
- Vite App · Vite environment and metadata RPC plus dedicated app shell
packages/vite/src/index.ts - Rolldown Node · Build event storage, session management, log cache, and data RPC endpoints
packages/rolldown/src/node/index.ts - Rolldown App · Session and compare dashboards with graph, flamegraph, treemap, flowmap, and detail views
packages/rolldown/src/app/app.vue - Diff Worker · Background diff computation for compare workflows
packages/rolldown/src/app/worker/diff.worker.ts - Inspect Node · RPC for auth tokens, client scripts, plugins, docks, RPC functions, and shared-state keys
packages/self-inspect/src/node/index.ts - Inspect App · Browser app for inspecting devtools internals and registered surfaces
packages/self-inspect/src/app/app.vue
Delivery
Deployment, docs, examples, and validation
- Web Extension · Browser-extension background, devtools panel, proxy, and window coordination
packages/webext/src/background.ts - Examples · Plugin examples with node backends and playground UIs for integration reference
examples/plugin-file-explorer/src/node/index.ts - Docs Site · VitePress docs, guides, kit references, and error documentation
docs/.vitepress/config.ts - E2E Tests · End-to-end fixture and integration tests for real host/runtime behavior
e2e/src/harness.ts
Connections 27
- Kit SDK → Node Runtime: plugin API · Core consumes the shared SDK contracts to expose host integration boundaries
- Kit SDK → Vite App: vite integration · Vite-specific features are built on the same plugin and RPC contract
- Kit SDK → Examples: example plugins · Examples demonstrate how third-party tooling uses the SDK
- Shared State → UI State: shared state · Shared-state primitives inform the client-side state managers
- UI Toolkit → Client Shell: visual system · Core client UI relies on shared presentation primitives
- UI Toolkit → Rolldown App: design system · Rolldown app uses the common UI toolkit for its presentation layer
- UI Toolkit → Inspect App: shared visuals · Inspection app uses the common UI toolkit for consistent rendering
- Node Runtime → Core RPC: serves rpc · Node runtime exposes internal and public RPC endpoints
- Node Runtime → Core Plugins: loads plugins · Runtime startup wires plugin registration and host integration
- Core RPC → Client Shell: state delivery · RPC feeds the client with runtime state and actions
- Core Plugins → Web Extension: embed/extend · Plugin and injection layers support browser-extension deployment
- Client Shell → Dock System: layout · The client shell organizes content through the dock system
- Client Shell → Builtin Views: panels · Builtin views render settings, messages, terminals, and palette flows
- Builtin Views → JSON Render: structured render · Views use the JSON renderer for typed object visualization
- UI State → Dock System: view state · Dock state drives panel placement and persistence
- UI State → Builtin Views: ui actions · Command, confirm, toast, and keybinding state powers built-in views
- Rolldown Node → Core RPC: rpc data · Rolldown backend publishes build analysis through RPC
- Rolldown Node → Diff Worker: diff jobs · Compare summaries offload expensive diffing to a worker
- Rolldown App → Diff Worker: compare ui · Compare dashboards consume worker-produced diff results
- Inspect Node → Core RPC: inspection rpc · Self-inspection backend exposes internal devtools surfaces via RPC
- Inspect App → Inspect Node: inspect data · Inspection app reads auth, plugins, scripts, docks, and shared-state data
- Vite App → Core RPC: host state · Vite-specific metadata is published through the shared RPC channel
- Web Extension → Client Shell: hosts ui · Extension shell wraps the client UI for browser targets
- Examples → E2E Tests: reference flows · Examples mirror integration patterns exercised by end-to-end tests
- Docs Site → Kit SDK: usage docs · Documentation explains the SDK and integration patterns
- Docs Site → Node Runtime: runtime docs · Docs cover the main devtools runtime and deployment modes
- E2E Tests → Node Runtime: integration check · End-to-end tests validate real host/runtime behavior