Skip to content

Commit 331658b

Browse files
committed
Merge branch 'main' into feat/learn-devtools-by-codex
2 parents 3200556 + 484d2ef commit 331658b

72 files changed

Lines changed: 1793 additions & 1106 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

β€ŽCONTRIBUTING.mdβ€Ž

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Contributing
2+
3+
Thank you for your interest in contributing to Vite DevTools! Before submitting your contribution, please take a moment to read through the following guidelines.
4+
5+
Please be aware that we are still in the early stages of development, and huge refactoring occasionally are expected.
6+
7+
We are currently focusing on getting the basic data visualization working for **Vite-Rolldown's build mode**. Dev mode will be delayed for later until Vite get the full-bundler dev mode.
8+
9+
You can check the [TODO list](https://github.com/vitejs/devtools/issues/9) (excluding `hold-off`) if you are interested in helping out.
10+
11+
## Setup
12+
13+
```bash
14+
pnpm install
15+
pnpm build # Required: generates Rolldown meta under ./packages/vite/.rolldown
16+
pnpm dev # Start dev server
17+
```
18+
19+
**Note**: After pulling latest commits, remove `./packages/vite/.rolldown` and rebuild to get the latest data format.
20+
21+
## Project Structure
22+
23+
Monorepo with pnpm workspaces. Each package's scope:
24+
25+
### `packages/core` - `@vitejs/devtools`
26+
27+
Main entry point and core functionality.
28+
29+
- CLI (`vite-devtools` command)
30+
- Client-side injection scripts
31+
- Standalone mode
32+
- WebComponents UI (Dock, Panels, Terminals)
33+
- Node.js server for DevTools UI
34+
- RPC server/client setup
35+
- Host functions and docks management
36+
37+
**Key files**: `src/node/cli.ts`, `src/node/server.ts`, `src/client/webcomponents/`
38+
39+
---
40+
41+
### `packages/kit` - `@vitejs/devtools-kit`
42+
43+
Utility library for integration authors.
44+
45+
- TypeScript types and interfaces
46+
- Utilities for custom docks, views, panels
47+
- Event system utilities
48+
- RPC client helpers
49+
50+
**Key files**: `src/index.ts`, `src/client.ts`, `src/utils/`
51+
52+
---
53+
54+
### `packages/vite` - `@vitejs/devtools-vite`
55+
56+
Built-in UI panel for Vite/Rolldown integration.
57+
58+
- Vite plugin (enabled by default)
59+
- Nuxt-based UI for build visualization
60+
- Rolldown build output integration
61+
- Build analysis panels, module graph, file inspection
62+
63+
**Key files**: `src/index.ts` (plugin entry), `src/` (Nuxt app)
64+
65+
**Note**: Build generates Rolldown metadata in `.rolldown` folder.
66+
67+
---
68+
69+
### `packages/rpc` - `@vitejs/devtools-rpc`
70+
71+
RPC layer for component communication.
72+
73+
- RPC client/server implementations
74+
- WebSocket presets
75+
- Message serialization
76+
- Type-safe RPC methods
77+
78+
**Key files**: `src/index.ts`, `src/client.ts`, `src/server.ts`, `src/presets/ws/`
79+
80+
---
81+
82+
### `packages/webext` - `@vitejs/devtools-webext`
83+
84+
Browser extension (planned for future dev mode). **Not accepting contributions currently.**
85+
86+
---
87+
88+
## Scripts
89+
90+
- `pnpm build` - Build all packages
91+
- `pnpm watch` - Watch mode
92+
- `pnpm dev` - Dev server
93+
- `pnpm lint` - ESLint
94+
- `pnpm test` - Vitest
95+
- `pnpm typecheck` - Type check
96+
97+
Package-specific: `pnpm -C packages/core run cli`, `pnpm -C packages/vite run dev`
98+
99+
## Workflow
100+
101+
1. For new features: open an issue first for discussion
102+
2. Make changes, run `pnpm test && pnpm typecheck && pnpm lint`
103+
3. Use conventional commits (`feat:`, `fix:`, etc.)
104+
4. Submit PR with clear description and related issue reference
105+
106+
## Package Guidelines
107+
108+
- **core**: CLI in `cli-commands.ts`, server in `server.ts`, components in `client/webcomponents/`
109+
- **kit**: Keep APIs stable, add types for public APIs, consider backward compatibility
110+
- **vite**: Nuxt 3 app, Vue 3 Composition API, test with `pnpm dev` after build
111+
- **rpc**: Keep methods type-safe, document new methods, test client/server

β€ŽREADME.mdβ€Ž

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,13 @@
22

33
# Vite DevTools
44

5-
Vite DevTools is a set of tools for visualizing the internal state and build analysis for Vite and Rolldown (currently only work with [`rolldown-vite`](https://github.com/vitejs/rolldown-vite)).
5+
Vite DevTools is a set of tools for visualizing the internal state and build analysis for Vite and Rolldown.
66

77
> [!IMPORTANT]
88
> This project is still in development. Not yet usable. You may preview it by building this project from source.
99
10-
## πŸ—οΈ Project Progress
11-
12-
State: **🚧 Work in progress**
13-
14-
We are currently focusing on getting the basic data visualization working for **Vite-Rolldown's build mode**. Dev mode will be delayed for later until Vite get the full-bundler dev mode.
15-
16-
You can check the [TODO list](https://github.com/vitejs/devtools/issues/9) (excluding `hold-off`) if you are interested in helping out.
17-
18-
## πŸ“¦ Packages
19-
20-
- `packages/core`: `@vitejs/devtools` the entry point of the project. It provides the core functionality of Vite DevTools, including the CLI.
21-
- `packages/kit`: `@vitejs/devtools-kit` the utility library for integration authors to extend Vite DevTools. Which include types and utilities for the project.
22-
- `packages/vite`: `@vitejs/devtools-vite` the built-in UI panel for Vite/Rolldown, it's presented as a Vite plugin which is enabled by default.
23-
- `packages/rpc`: `@vitejs/devtools-rpc` the rpc layer of the project.
24-
25-
## πŸ’‘ Contributing Guide
26-
27-
We're really excited that you're interested in contributing to Vite DevTools! Before submitting your contribution, please take a moment to read through the following guidelines:
28-
29-
- For the `devtools-webext` package, we plan to use it for dev mode in the future, so no contributions are needed at this time.
30-
- For any new feature additions, we recommend submitting an issue for discussion and confirmation first.
31-
32-
## πŸ§‘β€πŸ’» Development Guide
33-
34-
Currently Vite DevTools only supports build time inspection, to develop this project, you first need to build itself to get the Rolldown meta for testing.
35-
36-
- `pnpm install` to install dependencies
37-
- `pnpm build` first to get the Rolldown logs under `./packages/vite/.rolldown` folder
38-
- `pnpm dev` to start the dev server
39-
40-
As the data interface between Rolldown is not yet stable, and breaking changes are expected. We locked the Rolldown version in our `pnpm-workspace.yaml`, which means the published version may not work with the latest Rolldown.
41-
42-
When pulling the latest commits, it's recommended to remove the `./packages/vite/.rolldown` folder and run `pnpm build` again to get the latest data format.
10+
- πŸ“– [Documentation](https://vite-devtools.netlify.app)
11+
- πŸ’‘ [Contributing Guide](./CONTRIBUTING.md)
4312

4413
## πŸ“„ Licenses
4514

β€Žalias.tsβ€Ž

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import fs from 'node:fs'
2+
import { fileURLToPath } from 'node:url'
3+
import { join, relative } from 'pathe'
4+
5+
const root = fileURLToPath(new URL('.', import.meta.url))
6+
const r = (path: string) => fileURLToPath(new URL(`./packages/${path}`, import.meta.url))
7+
8+
export const alias = {
9+
'@vitejs/devtools-rpc': r('rpc/src'),
10+
'@vitejs/devtools-rpc/presets/ws/server': r('rpc/src/presets/ws/server.ts'),
11+
'@vitejs/devtools-rpc/presets/ws/client': r('rpc/src/presets/ws/client.ts'),
12+
'@vitejs/devtools-kit/client': r('kit/src/client/index.ts'),
13+
'@vitejs/devtools-kit/utils/events': r('kit/src/utils/events.ts'),
14+
'@vitejs/devtools-kit/utils/nanoid': r('kit/src/utils/nanoid.ts'),
15+
'@vitejs/devtools-kit/utils/shared-state': r('kit/src/utils/shared-state.ts'),
16+
'@vitejs/devtools-kit': r('kit/src/index.ts'),
17+
'@vitejs/devtools-vite': r('vite/src/index.ts'),
18+
'@vitejs/devtools/client/inject': r('core/src/client/inject/index.ts'),
19+
'@vitejs/devtools/client/webcomponents': r('core/src/client/webcomponents/index.ts'),
20+
'@vitejs/devtools': r('core/src/index.ts'),
21+
}
22+
23+
// update tsconfig.base.json
24+
const raw = fs.readFileSync(join(root, 'tsconfig.base.json'), 'utf-8').trim()
25+
const tsconfig = JSON.parse(raw)
26+
tsconfig.compilerOptions.paths = Object.fromEntries(
27+
Object.entries(alias).map(([key, value]) => [key, [`./${relative(root, value)}`]]),
28+
)
29+
const newRaw = JSON.stringify(tsconfig, null, 2)
30+
if (newRaw !== raw)
31+
fs.writeFileSync(join(root, 'tsconfig.base.json'), `${newRaw}\n`, 'utf-8')

β€Ždocs/.vitepress/config.tsβ€Ž

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,32 @@ import {
44
groupIconMdPlugin,
55
groupIconVitePlugin,
66
} from 'vitepress-plugin-group-icons'
7+
import { version } from '../../package.json'
78

89
// https://vitepress.dev/reference/site-config
910
export default defineConfig({
1011
title: 'Vite DevTools',
11-
description: 'DevTools for Vite',
12+
description: 'Visualize and analyze your Vite build process with powerful developer tools. Extensible architecture for building custom DevTools integrations.',
1213
head: [
1314
['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }],
1415
],
1516
themeConfig: {
1617
// https://vitepress.dev/reference/default-theme-config
1718
nav: [
1819
{ text: 'Guide', link: '/guide/' },
19-
{ text: 'Kit', link: '/kit/' },
20+
{ text: 'DevTools Kit', link: '/kit/' },
21+
{
22+
text: `v${version}`,
23+
items: [
24+
{ text: 'Release Notes', link: 'https://github.com/vitejs/devtools/releases' },
25+
{ text: 'Contributing', link: 'https://github.com/vitejs/devtools/blob/main/CONTRIBUTING.md' },
26+
],
27+
},
2028
],
2129

2230
sidebar: [
2331
{
24-
text: 'Introduction',
32+
text: 'Guide',
2533
items: [
2634
{ text: 'Getting Started', link: '/guide/' },
2735
],
@@ -33,15 +41,25 @@ export default defineConfig({
3341
],
3442
},
3543
],
44+
45+
search: {
46+
provider: 'local',
47+
},
48+
3649
logo: {
3750
light: '/logo.svg',
3851
dark: '/logo_dark.svg',
3952
},
53+
4054
footer: {
4155
message: `Released under the MIT License.`,
4256
copyright: 'Copyright Β© 2025-present VoidZero Inc. & Vite Contributors',
4357
},
4458

59+
lastUpdated: {
60+
text: 'Last updated',
61+
},
62+
4563
editLink: {
4664
pattern: 'https://github.com/vitejs/devtools/edit/main/docs/:path',
4765
text: 'Suggest changes to this page',

β€Ždocs/guide/index.mdβ€Ž

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
---
2+
outline: deep
3+
---
4+
15
# Getting Started
26

37
> [!WARNING]
48
> Vite DevTools is still in development and not yet ready for production use.
59
> And currently Vite DevTools is designed only for Vite-Rolldown's build mode.
610
> Dev mode and normal Vite are not supported yet.
711
12+
## What is Vite DevTools?
13+
14+
Vite DevTools is a comprehensive set of developer tools for visualizing and analyzing your Vite build process. It provides deep insights into your build pipeline, module dependencies, and build metadata, helping you understand and optimize your Vite applications.
15+
16+
### Key Features
17+
18+
- **πŸ” Build Analysis**: Visualize module graphs, dependencies, and build metadata
19+
- **πŸ“Š Performance Insights**: Understand build performance and bottlenecks
20+
- **🧩 Extensible**: Build custom DevTools integrations with the DevTools Kit
21+
- **🎨 Unified Interface**: All DevTools integrations appear in a consistent dock interface
22+
- **⚑ Type-Safe**: Full TypeScript support with type-safe RPC communication
23+
24+
## Installation
25+
826
If you want to give an early preview, you can try it out by building this project from source, or install the preview build with the following steps:
927

1028
Switch your Vite to [Rolldown Vite](https://vite.dev/guide/rolldown#how-to-try-rolldown):
@@ -54,3 +72,31 @@ Open the DevTools panel in your browser to play with the DevTools:
5472
```bash
5573
pnpm dev
5674
```
75+
76+
## What's Next?
77+
78+
Now that you have Vite DevTools set up, you can:
79+
80+
- **Explore the built-in tools**: Check out the various panels and visualizations available in the DevTools interface
81+
- **Build custom integrations**: Learn how to extend Vite DevTools with your own tools using the [DevTools Kit](/kit/)
82+
- **Contribute**: Help improve Vite DevTools by checking out our [contributing guide](https://github.com/antfu/contribute)
83+
84+
## Current Limitations
85+
86+
> [!NOTE]
87+
> Vite DevTools is currently in active development with the following limitations:
88+
89+
- **Build mode only**: Currently works with Vite-Rolldown's build mode
90+
- **Dev mode**: Not yet supported (planned for future releases)
91+
- **Standard Vite**: Requires Rolldown Vite for now
92+
93+
## Architecture Overview
94+
95+
Vite DevTools consists of several core packages:
96+
97+
- **`@vitejs/devtools`**: The main entry point and CLI
98+
- **`@vitejs/devtools-kit`**: Utilities and types for building custom integrations
99+
- **`@vitejs/devtools-vite`**: Built-in UI panel for Vite/Rolldown
100+
- **`@vitejs/devtools-rpc`**: RPC layer for server-client communication
101+
102+
For more details on extending Vite DevTools, see the [DevTools Kit documentation](/kit/).

β€Ždocs/index.mdβ€Ž

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ layout: home
44
hero:
55
name: Vite DevTools
66
text: DevTools for Vite.
7-
tagline: Working in Progress
7+
tagline: Visualize and analyze your Vite build process with powerful developer tools
88
actions:
99
- theme: brand
1010
text: Get Started
@@ -18,13 +18,22 @@ hero:
1818
alt: Vite DevTools
1919

2020
features:
21+
- icon: πŸ”
22+
title: Build Analysis
23+
details: Deep insights into your Vite-Rolldown build process. Visualize module graphs, dependencies, and build metadata to understand what's happening under the hood.
24+
- icon: 🧩
25+
title: Extensible Architecture
26+
details: Build custom DevTools integrations with the DevTools Kit. Extend any Vite plugin with a simple devtools hook to add your own visualizations and tools.
2127
- icon: πŸš€
22-
title: Feature1
23-
details: Description of feature 1.
24-
- icon: πŸš€
25-
title: Feature2
26-
details: Description of feature 2.
27-
- icon: πŸš€
28-
title: Feature3
29-
details: Description of feature 3.
28+
title: Unified Dock System
29+
details: A familiar dock interface (like macOS Dock) where all DevTools integrations appear together. Switch between tools seamlessly in a consistent UI.
30+
- icon: πŸ”Œ
31+
title: Type-Safe RPC
32+
details: Built-in RPC layer for bidirectional communication between server and client. Full TypeScript support for type-safe data exchange.
33+
- icon: 🎨
34+
title: Flexible UI Options
35+
details: Choose from iframe panels, custom renderers, or action buttons. Host your UI as embedded panels, browser extensions, or standalone webpages.
36+
- icon: ⚑
37+
title: Framework Agnostic
38+
details: Works with any framework built on Vite. Use Vue, React, Svelte, or any other framework to build your DevTools UI.
3039
---

0 commit comments

Comments
Β (0)