Skip to content

Commit ebb321d

Browse files
committed
feat: use obug
1 parent 5cff04c commit ebb321d

File tree

9 files changed

+37
-13
lines changed

9 files changed

+37
-13
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
"birpc": "catalog:deps",
6060
"birpc-x": "catalog:deps",
6161
"cac": "catalog:deps",
62-
"debug": "catalog:deps",
6362
"immer": "catalog:deps",
6463
"launch-editor": "catalog:deps",
6564
"mlly": "catalog:deps",
65+
"obug": "catalog:deps",
6666
"open": "catalog:deps",
6767
"pathe": "catalog:deps",
6868
"perfect-debounce": "catalog:deps",

packages/core/playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.0-alpha.22",
55
"private": true,
66
"scripts": {
7-
"dev": "VITE_DEVTOOLS_LOCAL_DEV=true vite",
7+
"dev": "DEBUG='vite:devtools:*' VITE_DEVTOOLS_LOCAL_DEV=true vite",
88
"dev:standalone": "DEBUG='vite:devtools:*' VITE_DEVTOOLS_LOCAL_DEV=true tsx ../src/node/cli.ts",
99
"build": "vite build && vite-devtools"
1010
}

packages/core/src/node/context.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { DevToolsNodeContext } from '@vitejs/devtools-kit'
22
import type { ResolvedConfig, ViteDevServer } from 'vite'
3-
import Debug from 'debug'
3+
import { createDebug } from 'obug'
44
import { debounce } from 'perfect-debounce'
55
import { searchForWorkspaceRoot } from 'vite'
66
import { ContextUtils } from './context-utils'
@@ -10,7 +10,8 @@ import { DevToolsTerminalHost } from './host-terminals'
1010
import { DevToolsViewHost } from './host-views'
1111
import { builtinRpcDecalrations } from './rpc'
1212

13-
const debug = Debug('vite:devtools:context')
13+
const debugSetup = createDebug('vite:devtools:context:setup')
14+
const debugEvent = createDebug('vite:devtools:context:event')
1415

1516
export async function createDevToolsContext(
1617
viteConfig: ResolvedConfig,
@@ -46,12 +47,14 @@ export async function createDevToolsContext(
4647

4748
// Register hosts side effects
4849
docksHost.events.on('dock:entry:updated', debounce(() => {
50+
debugEvent('dock:entry:updated')
4951
rpcHost.broadcast({
5052
method: 'vite:internal:docks:updated',
5153
args: [],
5254
})
5355
}, 10))
5456
terminalsHost.events.on('terminal:session:updated', debounce(() => {
57+
debugEvent('terminal:session:updated')
5558
rpcHost.broadcast({
5659
method: 'vite:internal:terminals:updated',
5760
args: [],
@@ -76,7 +79,7 @@ export async function createDevToolsContext(
7679
if (!plugin.devtools?.setup)
7780
continue
7881
try {
79-
debug(`Setting up plugin ${plugin.name}`)
82+
debugSetup(`setting up plugin ${JSON.stringify(plugin.name)}`)
8083
await plugin.devtools?.setup?.(context)
8184
}
8285
catch (error) {

packages/core/src/node/rpc-shared-state.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import type { RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost } from '@vitejs/devtools-kit'
22
import type { SharedState } from '@vitejs/devtools-kit/utils/shared-state'
33
import { createSharedState } from '@vitejs/devtools-kit/utils/shared-state'
4+
import { createDebug } from 'obug'
5+
6+
const debug = createDebug('vite:devtools:rpc:shared-state')
47

58
export function createRpcSharedStateServerHost(
69
rpc: RpcFunctionsHost,
@@ -13,13 +16,15 @@ export function createRpcSharedStateServerHost(
1316
offs.push(
1417
state.on('updated', (_fullState, patches, syncId) => {
1518
if (patches) {
19+
debug('patch', { key, syncId })
1620
rpc.broadcast({
1721
method: 'vite:internal:rpc:client-state:patch',
1822
args: [key, patches, syncId],
1923
// TODO: filter: broadcast to clients only subscribed to its
2024
})
2125
}
2226
else {
27+
debug('updated', { key, syncId })
2328
rpc.broadcast({
2429
method: 'vite:internal:rpc:client-state:updated',
2530
args: [key, syncId],
@@ -44,6 +49,7 @@ export function createRpcSharedStateServerHost(
4449
if (options?.initialValue === undefined) {
4550
throw new Error(`Shared state of "${key}" is not found, please provide an initial value for the first time`)
4651
}
52+
debug('new-state', key)
4753
const state = createSharedState<T>({
4854
initialState: options.initialValue,
4955
enablePatches: false,

packages/vite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"scripts": {
3232
"build": "pnpm dev:prepare && ROLLDOWN_OPTIONS_VALIDATION=loose nuxi build src && tsdown",
3333
"build:debug": "NUXT_DEBUG_BUILD=true pnpm run build",
34-
"dev": "ROLLDOWN_OPTIONS_VALIDATION=loose nuxi dev src",
34+
"dev": "DEBUG='vite:devtools:*' ROLLDOWN_OPTIONS_VALIDATION=loose nuxi dev src",
3535
"dev:prepare": "nuxi prepare src",
3636
"prepack": "pnpm build"
3737
},

packages/vite/src/nuxt.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export default defineNuxtConfig({
8383
},
8484
},
8585

86+
debug: false,
87+
8688
vite: {
8789
base: BASE,
8890
build: {

pnpm-lock.yaml

Lines changed: 18 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ catalogs:
3333
birpc: ^4.0.0
3434
birpc-x: 0.0.6
3535
cac: ^6.7.14
36-
debug: ^4.4.3
3736
diff: ^8.0.2
3837
get-port-please: ^3.2.0
3938
h3: ^1.15.4
4039
immer: ^11.1.0
4140
launch-editor: ^2.12.0
4241
mlly: ^1.8.0
4342
mrmime: ^2.0.1
43+
obug: ^0.1.0
4444
ohash: ^2.0.11
4545
open: ^11.0.0
4646
p-limit: ^7.2.0

turbo.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://turbo.build/schema.json",
33
"tasks": {
44
"build": {
5+
"outputLogs": "new-only",
56
"outputs": [
67
"dist/**"
78
]

0 commit comments

Comments
 (0)