Skip to content

Commit b8ffe83

Browse files
committed
chore: update
2 parents 146a089 + 31c479c commit b8ffe83

22 files changed

Lines changed: 1014 additions & 873 deletions

File tree

e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@vitejs/devtools-e2e",
33
"type": "module",
4-
"version": "0.0.0",
4+
"version": "0.1.24",
55
"private": true,
66
"scripts": {
77
"test": "vitest --run"

examples/plugin-a11y-checker/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "example-plugin-a11y-checker",
33
"type": "module",
4-
"version": "0.1.22",
4+
"version": "0.1.24",
55
"private": true,
66
"exports": {
77
".": "./dist/index.mjs",
@@ -12,7 +12,7 @@
1212
"dist"
1313
],
1414
"scripts": {
15-
"build:node": "tsdown --config-loader=tsx",
15+
"build:node": "tsdown --config-loader=unrun",
1616
"build": "pnpm run build:node",
1717
"play:dev": "pnpm run build && cd playground && DEBUG='vite:devtools:*' vite"
1818
},

examples/plugin-file-explorer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "example-plugin-file-explorer",
33
"type": "module",
4-
"version": "0.1.22",
4+
"version": "0.1.24",
55
"private": true,
66
"exports": {
77
".": "./dist/index.mjs",
@@ -12,7 +12,7 @@
1212
"dist"
1313
],
1414
"scripts": {
15-
"build:node": "tsdown --config-loader=tsx",
15+
"build:node": "tsdown --config-loader=unrun",
1616
"build:ui": "cd src/ui && vite build",
1717
"build": "pnpm run build:node && pnpm run build:ui",
1818
"play:dev": "pnpm run build && cd playground && DEBUG='vite:devtools:*' vite",

examples/plugin-git-ui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "example-plugin-git-ui",
33
"type": "module",
4-
"version": "0.1.22",
4+
"version": "0.1.24",
55
"private": true,
66
"exports": {
77
".": "./dist/index.mjs",
@@ -12,7 +12,7 @@
1212
"dist"
1313
],
1414
"scripts": {
15-
"build": "tsdown --config-loader=tsx",
15+
"build": "tsdown --config-loader=unrun",
1616
"play:dev": "pnpm run build && cd playground && DEBUG='vite:devtools:*' vite",
1717
"play:build": "pnpm run build && cd playground && vite build && vite-devtools build",
1818
"play:preview": "serve ./playground/.vite-devtools"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"type": "module",
3-
"version": "0.1.22",
3+
"version": "0.1.24",
44
"private": true,
55
"packageManager": "pnpm@10.33.4",
66
"scripts": {
@@ -10,7 +10,7 @@
1010
"dev:rolldown": "pnpm -C packages/rolldown run dev",
1111
"dev:vite": "pnpm -C packages/vite run dev",
1212
"docs": "pnpm -C docs run docs",
13-
"docs:build": "pnpm -C docs run docs:build",
13+
"docs:build": "pnpm build && pnpm -C docs run docs:build",
1414
"docs:serve": "pnpm -C docs run docs:serve",
1515
"play": "pnpm -C packages/core run play",
1616
"play:debug": "pnpm -C packages/core run play:debug",

packages/core/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@vitejs/devtools",
33
"type": "module",
4-
"version": "0.1.22",
4+
"version": "0.1.24",
55
"description": "Vite DevTools",
66
"author": "VoidZero Inc.",
77
"license": "MIT",
@@ -41,9 +41,9 @@
4141
],
4242
"scripts": {
4343
"build": "pnpm build:js && pnpm build:standalone",
44-
"build:js": "tsdown --config-loader=tsx",
44+
"build:js": "tsdown --config-loader=unrun",
4545
"build:standalone": "cd src/client/standalone && vite build",
46-
"watch": "tsdown --watch --config-loader=tsx",
46+
"watch": "tsdown --watch --config-loader=unrun",
4747
"dev:standalone": "cd src/client/standalone && vite dev",
4848
"prepack": "pnpm build",
4949
"play": "DEBUG='vite:devtools:*' pnpm -C playground run dev",
@@ -89,15 +89,15 @@
8989
"vue-tsc": "catalog:devtools"
9090
},
9191
"inlinedDependencies": {
92-
"@clack/core": "1.3.0",
93-
"@clack/prompts": "1.3.0",
92+
"@clack/core": "1.3.1",
93+
"@clack/prompts": "1.4.0",
9494
"@json-render/core": "0.13.0",
9595
"@json-render/vue": "0.13.0",
9696
"@vueuse/core": "14.3.0",
9797
"@vueuse/shared": "14.3.0",
9898
"@xterm/addon-fit": "0.11.0",
9999
"@xterm/xterm": "6.0.0",
100-
"dompurify": "3.4.2",
100+
"dompurify": "3.4.3",
101101
"fast-string-truncated-width": "3.0.3",
102102
"fast-string-width": "3.0.2",
103103
"fast-wrap-ansi": "0.2.0",

packages/core/playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "playground",
33
"type": "module",
4-
"version": "0.1.22",
4+
"version": "0.1.24",
55
"private": true,
66
"scripts": {
77
"dev": "DEBUG='vite:devtools:*' VITE_DEVTOOLS_LOCAL_DEV=true vite",
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import { readFile } from 'node:fs/promises'
2+
import { dirname, relative, resolve } from 'node:path'
3+
import { findDynamicImports, findExports, findStaticImports } from 'mlly'
4+
5+
interface ForbiddenRule {
6+
name: string
7+
match: (specifier: string) => boolean
8+
}
9+
10+
const FORBIDDEN: ForbiddenRule[] = [
11+
{ name: 'ws', match: id => id === 'ws' || id.startsWith('ws/') },
12+
{ name: 'h3', match: id => id === 'h3' || id.startsWith('h3/') },
13+
{ name: 'node:* builtin', match: id => id.startsWith('node:') },
14+
{ name: 'devframe/rpc/transports/*', match: id => id.startsWith('devframe/rpc/transports/') },
15+
{ name: 'devframe/node*', match: id => id === 'devframe/node' || id.startsWith('devframe/node/') },
16+
]
17+
18+
interface ScannedSpecifiers {
19+
static: string[]
20+
dynamic: string[]
21+
}
22+
23+
interface Violation {
24+
file: string
25+
specifier: string
26+
rule: string
27+
}
28+
29+
async function scanSpecifiers(file: string): Promise<ScannedSpecifiers> {
30+
const code = await readFile(file, 'utf8')
31+
const staticIds = new Set<string>()
32+
for (const i of findStaticImports(code))
33+
staticIds.add(i.specifier)
34+
for (const e of findExports(code)) {
35+
if (e.specifier)
36+
staticIds.add(e.specifier)
37+
}
38+
const dynamicIds = new Set<string>()
39+
for (const d of findDynamicImports(code)) {
40+
// Only consider plain string expressions; ignore variable/template imports.
41+
const match = d.expression.match(/^\s*['"]([^'"]+)['"]\s*$/)
42+
if (match?.[1])
43+
dynamicIds.add(match[1])
44+
}
45+
return { static: [...staticIds], dynamic: [...dynamicIds] }
46+
}
47+
48+
export interface CheckClientDistOptions {
49+
/** Absolute paths to the client entry chunks to walk from. */
50+
entries: string[]
51+
/** Used to build relative paths in error messages. */
52+
cwd: string
53+
}
54+
55+
export async function checkClientDist(options: CheckClientDistOptions): Promise<void> {
56+
const { entries, cwd } = options
57+
const visited = new Set<string>()
58+
const violations: Violation[] = []
59+
60+
async function visit(file: string): Promise<void> {
61+
if (visited.has(file))
62+
return
63+
visited.add(file)
64+
65+
let scanned: ScannedSpecifiers
66+
try {
67+
scanned = await scanSpecifiers(file)
68+
}
69+
catch (err) {
70+
throw new Error(`[check-client-dist] Failed to read ${relative(cwd, file)}: ${(err as Error).message}`)
71+
}
72+
73+
// Static imports load eagerly when the file is evaluated — they're the leak
74+
// vector this guard exists to catch. Flag any forbidden specifier.
75+
for (const id of scanned.static) {
76+
const hit = FORBIDDEN.find(r => r.match(id))
77+
if (hit)
78+
violations.push({ file, specifier: id, rule: hit.name })
79+
}
80+
81+
// Follow both static and dynamic relative imports to discover every chunk
82+
// the browser can end up loading. Dynamic specifiers themselves aren't
83+
// checked against FORBIDDEN — the chunk they target is, on visit.
84+
for (const id of [...scanned.static, ...scanned.dynamic]) {
85+
if (id.startsWith('./') || id.startsWith('../')) {
86+
const next = resolve(dirname(file), id)
87+
await visit(next)
88+
}
89+
}
90+
}
91+
92+
for (const entry of entries)
93+
await visit(entry)
94+
95+
if (violations.length > 0) {
96+
const lines: string[] = ['[check-client-dist] Forbidden server-only imports found in client dist:', '']
97+
for (const v of violations) {
98+
lines.push(` ${relative(cwd, v.file)}`)
99+
lines.push(` imports ${JSON.stringify(v.specifier)} (matches forbidden rule: ${v.rule})`)
100+
}
101+
lines.push('')
102+
lines.push(`Scanned ${visited.size} chunks reachable from ${entries.length} client entries.`)
103+
lines.push('Client chunks must not statically import server-only modules — see packages/core/tsdown.config.ts.')
104+
throw new Error(lines.join('\n'))
105+
}
106+
107+
console.log(`[check-client-dist] OK — scanned ${visited.size} chunks reachable from ${entries.length} client entries`)
108+
}

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export { createDevToolsContext } from './node/context'
22
export { DevTools } from './node/plugins'
33
export type { BuiltinServerFunctions } from './node/rpc'
44
export { createDevToolsMiddleware } from './node/server'
5+
export type { DevToolsMiddleware } from './node/server'
56
export type { DevToolsInternalContext, InternalAnonymousAuthStorage } from 'devframe/node/internal'

0 commit comments

Comments
 (0)