Skip to content

Commit eeb29a9

Browse files
authored
feat(devtools): add dataInspector option + lazy-load integrations (#1061)
1 parent 5ba4c3e commit eeb29a9

4 files changed

Lines changed: 23 additions & 8 deletions

File tree

‎packages/devtools-kit/src/_types/options.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ export interface ModuleOptions {
4949
*/
5050
viteInspect?: boolean
5151

52+
/**
53+
* Enable the Data Inspector integration, which registers the live
54+
* `Nuxt Application` data source and mounts the Data Inspector panel.
55+
*
56+
* @default true
57+
*/
58+
dataInspector?: boolean
59+
5260
/**
5361
* Disable the DevTools client authorization prompt, allowing any browser to
5462
* connect without approving it first.

‎packages/devtools/src/constant.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const defaultOptions: ModuleOptions = {
77
enabled: undefined, // determine multiple conditions
88
componentInspector: true,
99
viteInspect: true,
10+
dataInspector: true,
1011
codeServer: {
1112
enabled: true,
1213
},

‎packages/devtools/src/module-main.ts‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { AnyNitroConfig } from './utils/nitro-compat'
77
import { existsSync } from 'node:fs'
88
import fs from 'node:fs/promises'
99
import os from 'node:os'
10-
import { NUXT_DEVTOOLS_GROUP_ID } from '@nuxt/devtools-kit'
10+
import { deprecate, NUXT_DEVTOOLS_GROUP_ID } from '@nuxt/devtools-kit'
1111
import { addImports, addPlugin, addTemplate, addVitePlugin, extendViteConfig, logger } from '@nuxt/kit'
1212
import { colors } from 'consola/utils'
1313
import { join } from 'pathe'
@@ -277,19 +277,26 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
277277

278278
await import('./integrations/plugin-metrics').then(({ setup }) => setup(ctx))
279279

280-
// Data Inspector is always mounted when DevTools is enabled (no module
281-
// option): it registers the live `Nuxt Application` source and mounts the
282-
// bundled SPA into the Nuxt dock group.
283-
await import('./integrations/data-inspector').then(({ setup }) => setup(ctx))
280+
if (options.dataInspector !== false)
281+
await import('./integrations/data-inspector').then(({ setup }) => setup(ctx))
284282

285283
if (options.viteInspect !== false)
286284
await import('./integrations/vite-inspect').then(({ setup }) => setup(ctx))
287285

288286
if (options.componentInspector !== false)
289287
await import('./integrations/vue-tracer').then(({ setup }) => setup(ctx))
290288

289+
if (options.codeServer?.enabled === false && options.vscode !== undefined) {
290+
deprecate(nuxt, 'NDT_DEP_0008', {
291+
api: 'devtools.vscode',
292+
replacement: 'devtools.codeServer',
293+
})
294+
}
295+
291296
const integrations = [
292-
import('./integrations/code-server').then(({ setup }) => setup(ctx)),
297+
options.codeServer?.enabled !== false
298+
? import('./integrations/code-server').then(({ setup }) => setup(ctx))
299+
: null,
293300
(options.experimental?.timeline || options.timeline?.enabled)
294301
? import('./integrations/timeline').then(({ setup }) => setup(ctx))
295302
: null,

‎packages/devtools/src/server-rpc/index.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { ModuleOptions, NuxtDevtoolsServerContext, ServerFunctions } from '
55
import { deprecate, registerHostDiagnostics } from '@nuxt/devtools-kit'
66
import { logger } from '@nuxt/kit'
77
import { colors } from 'consola/utils'
8-
import { getServerData } from '../integrations/data-inspector'
98
import { RPC_NAMESPACE } from '../rpc-namespace'
109
import { setupAnalyzeBuildRPC } from './analyze-build'
1110
import { setupAssetsRPC } from './assets'
@@ -165,7 +164,7 @@ export function setupRPC(nuxt: Nuxt, options: ModuleOptions) {
165164
// Deprecated compat shim (NDT_DEP_0009). The capture + live source now live
166165
// in the Data Inspector integration; `getServerConfig` is served by the
167166
// canonical `setupGeneralRPC` above.
168-
getServerData: async () => getServerData(nuxt),
167+
getServerData: async () => import('../integrations/data-inspector').then(({ getServerData }) => getServerData(nuxt)),
169168
} as ServerFunctions)
170169

171170
/**

0 commit comments

Comments
 (0)