Skip to content

Commit 106f66f

Browse files
authored
feat(vite): inspect modules and plugins page (#389)
1 parent 1e83649 commit 106f66f

107 files changed

Lines changed: 7843 additions & 654 deletions

File tree

Some content is hidden

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

docs/errors/VDT0001.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# VDT0001: Inspect Context Unavailable
6+
7+
## Message
8+
9+
> Vite inspect context is not available for this DevTools context.
10+
11+
## Cause
12+
13+
A `vite:inspect:*` RPC function was called in a DevTools context that did not register the Vite inspect collector.
14+
15+
## Example
16+
17+
Calling `vite:inspect:get-modules-list` while only the base Vite metadata RPC functions are registered triggers this error.
18+
19+
## Fix
20+
21+
Register the Vite UI plugin with inspect collection enabled before calling `vite:inspect:*` RPC functions.
22+
23+
## Source
24+
25+
- [`packages/vite/src/node/inspect/context.ts`](https://github.com/vitejs/devtools/blob/main/packages/vite/src/node/inspect/context.ts)`getViteInspectContext()` throws this when no inspect context was registered for the current DevTools context.

docs/errors/VDT0002.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# VDT0002: Inspect Target Not Found
6+
7+
## Message
8+
9+
> Vite inspect target "`{id}`" was not found in `{target}`.
10+
11+
## Cause
12+
13+
An inspect RPC query referenced a Vite instance or environment that the collector has not recorded.
14+
15+
## Example
16+
17+
Calling `vite:inspect:get-module-transform-info` with an unknown `{ vite, env }` query triggers this error.
18+
19+
## Fix
20+
21+
Read `vite:inspect:get-metadata` first and pass one of the returned Vite instance IDs and environment names to follow-up inspect RPC calls.
22+
23+
## Source
24+
25+
- [`packages/vite/src/node/inspect/context.ts`](https://github.com/vitejs/devtools/blob/main/packages/vite/src/node/inspect/context.ts)`getViteContext()` and `getEnvContext()` throw this when a query references an unknown inspect target.

docs/errors/index.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Vite DevTools uses structured diagnostics to surface actionable warnings and err
99
## How error codes work
1010

1111
- Codes follow the pattern **prefix + 4-digit number** (e.g., `DF0001`, `DTK0008`, `RDDT0002`).
12-
- Each prefix maps to a package: `DTK` for `@vitejs/devtools` (Vite-specific pieces), `RDDT` for `@vitejs/devtools-rolldown`. The framework-neutral `devframe` package documents its own `DF`-prefixed codes at the [Devframe docs site](https://devfra.me/errors/).
12+
- Each prefix maps to a package: `DTK` for `@vitejs/devtools` (Vite-specific pieces), `RDDT` for `@vitejs/devtools-rolldown`, `VDT` for `@vitejs/devtools-vite`. The framework-neutral `devframe` package documents its own `DF`-prefixed codes at the [Devframe docs site](https://devfra.me/errors/).
1313
- Every error page includes the cause, recommended fix, and a reference to the source file that emits it.
1414
- The diagnostics system is powered by [`nostics`](https://github.com/vercel-labs/nostics), which provides structured diagnostic codes with docs URLs and ANSI-formatted console output.
1515

@@ -42,3 +42,12 @@ Emitted by `@vitejs/devtools-rolldown`.
4242
|------|-------|-------|
4343
| [RDDT0001](./RDDT0001) | warn | Rolldown Logs Directory Not Found |
4444
| [RDDT0002](./RDDT0002) | warn | Rolldown Log Reader Bad Line |
45+
46+
## Vite DevTools (VDT)
47+
48+
Emitted by `@vitejs/devtools-vite`.
49+
50+
| Code | Level | Title |
51+
|------|-------|-------|
52+
| [VDT0001](./VDT0001) | error | Inspect Context Unavailable |
53+
| [VDT0002](./VDT0002) | error | Inspect Target Not Found |

docs/kit/diagnostics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Prefixes used by the in-tree packages:
7575
| `DF` | `devframe` |
7676
| `DTK` | `@vitejs/devtools` |
7777
| `RDDT` | `@vitejs/devtools-rolldown` |
78-
| `VDT` | `@vitejs/devtools-vite` (reserved) |
78+
| `VDT` | `@vitejs/devtools-vite` |
7979

8080
Each definition supports `why` (string or function returning a string) and an optional `fix` (string or function). A `docsBase` on the definition group auto-attaches a per-code URL to every emitted diagnostic.
8181

packages/rolldown/src/app/components/assets/Sunburst.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import type { GraphBase, GraphBaseOptions } from 'nanovis'
33
import type { AssetChartInfo, AssetChartNode } from '~/types/chart'
4+
import ChartNavBreadcrumb from '@vitejs/devtools-ui/components/ChartNavBreadcrumb.vue'
45
import { colorToCssBackground } from 'nanovis'
56
import { useTemplateRef, watchEffect } from 'vue'
67

packages/rolldown/src/app/components/chunks/Graph.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<script setup lang="ts">
22
import type { ChunkImport } from '@rolldown/debug'
3+
import type { ModuleGraphLink, ModuleGraphNode } from '@vitejs/devtools-ui/composables/module-graph'
34
import type { RolldownChunkInfo, SessionContext } from '~~/shared/types/data'
4-
import type { ModuleGraphLink, ModuleGraphNode } from '~/composables/module-graph'
55
import DisplayBadge from '@vitejs/devtools-ui/components/DisplayBadge.vue'
6+
import DisplayModuleGraph from '@vitejs/devtools-ui/components/DisplayModuleGraph.vue'
7+
import { createModuleGraph, getModuleGraphSize } from '@vitejs/devtools-ui/composables/module-graph'
68
import { computed, unref } from 'vue'
79
import { useRoute } from '#app/composables/router'
8-
import { createModuleGraph, getModuleGraphSize } from '~/composables/module-graph'
910
1011
type ChunkInfo = RolldownChunkInfo & {
1112
id: string
@@ -196,7 +197,6 @@ createModuleGraph<ChunkInfo, ChunkImport>({
196197

197198
<template>
198199
<DisplayModuleGraph
199-
:session="session"
200200
:modules="chunks"
201201
:expand-controls="false"
202202
>

packages/rolldown/src/app/components/chunks/Sunburst.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import type { GraphBase, GraphBaseOptions } from 'nanovis'
33
import type { ChunkChartInfo, ChunkChartNode } from '~/types/chart'
4+
import ChartNavBreadcrumb from '@vitejs/devtools-ui/components/ChartNavBreadcrumb.vue'
45
import { colorToCssBackground } from 'nanovis'
56
import { useTemplateRef, watchEffect } from 'vue'
67

packages/rolldown/src/app/components/data/AssetRelationships.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
2+
import type { ModuleGraphLink, ModuleGraphNode } from '@vitejs/devtools-ui/composables/module-graph'
23
import type { HierarchyNode } from 'd3-hierarchy'
34
import type { RolldownAssetInfo } from '~~/shared/types'
4-
import type { ModuleGraphLink, ModuleGraphNode } from '~/composables/module-graph'
5+
import { generateModuleGraphLink, getModuleGraphLinkColor } from '@vitejs/devtools-ui/composables/module-graph'
56
import { computed, onMounted, shallowRef, useTemplateRef, watch } from 'vue'
6-
import { generateModuleGraphLink, getModuleGraphLinkColor } from '~/composables/module-graph'
77
88
const props = defineProps<{
99
importers?: RolldownAssetInfo[]

packages/rolldown/src/app/components/data/ModuleImportRelationships.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
2+
import type { ModuleGraphLink, ModuleGraphNode } from '@vitejs/devtools-ui/composables/module-graph'
23
import type { HierarchyNode } from 'd3-hierarchy'
34
import type { ModuleImport, ModuleInfo, ModuleListItem, SessionContext } from '~~/shared/types'
4-
import type { ModuleGraphLink, ModuleGraphNode } from '~/composables/module-graph'
5+
import { generateModuleGraphLink, getModuleGraphLinkColor } from '@vitejs/devtools-ui/composables/module-graph'
56
import { computed, onMounted, shallowRef, useTemplateRef, watch } from 'vue'
6-
import { generateModuleGraphLink, getModuleGraphLinkColor } from '~/composables/module-graph'
77
88
const props = defineProps<{
99
module: ModuleInfo

packages/rolldown/src/app/components/data/PluginDetailsLoader.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import type { PluginChartInfo, PluginChartNode } from '~/types/chart'
55
import DisplayCloseButton from '@vitejs/devtools-ui/components/DisplayCloseButton.vue'
66
import DisplayDuration from '@vitejs/devtools-ui/components/DisplayDuration.vue'
77
import DisplayNumberBadge from '@vitejs/devtools-ui/components/DisplayNumberBadge.vue'
8+
import DisplayPluginName from '@vitejs/devtools-ui/components/DisplayPluginName.vue'
9+
import PluginsSunburst from '@vitejs/devtools-ui/components/PluginsSunburst.vue'
810
import { formatDuration } from '@vitejs/devtools-ui/utils/format'
911
import { useAsyncState, useMouse } from '@vueuse/core'
1012
import { normalizeTreeNode, Sunburst } from 'nanovis'
@@ -311,10 +313,19 @@ watch(() => settings.value.pluginDetailsViewType, () => {
311313
<PluginsSunburst
312314
v-if="settings.pluginDetailsViewType === 'sunburst' && graph"
313315
:graph="graph"
314-
:session="session"
315316
:selected="nodeSelected"
316317
@select="selectNode"
317-
/>
318+
>
319+
<template #module="{ child }">
320+
<DisplayModuleId
321+
:id="child.text!"
322+
w-full border-none ws-nowrap
323+
:session="session"
324+
hover="bg-active"
325+
border="~ base rounded" block px2 py1
326+
/>
327+
</template>
328+
</PluginsSunburst>
318329
</div>
319330
</div>
320331
<div v-else flex="~ items-center justify-center" w-full h-full>

0 commit comments

Comments
 (0)