From f3f79c5b50175ab3b5f95d2ce1bdb7056d2538ad Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 4 Aug 2026 05:54:06 +0000 Subject: [PATCH] feat(devtools): add dataInspector option and lazy-load gated integrations --- packages/devtools-kit/src/_types/options.ts | 8 ++++++++ packages/devtools/src/constant.ts | 1 + packages/devtools/src/module-main.ts | 19 +++++++++++++------ packages/devtools/src/server-rpc/index.ts | 3 +-- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/packages/devtools-kit/src/_types/options.ts b/packages/devtools-kit/src/_types/options.ts index d336f910bf..cad1c5dd19 100644 --- a/packages/devtools-kit/src/_types/options.ts +++ b/packages/devtools-kit/src/_types/options.ts @@ -49,6 +49,14 @@ export interface ModuleOptions { */ viteInspect?: boolean + /** + * Enable the Data Inspector integration, which registers the live + * `Nuxt Application` data source and mounts the Data Inspector panel. + * + * @default true + */ + dataInspector?: boolean + /** * Disable the DevTools client authorization prompt, allowing any browser to * connect without approving it first. diff --git a/packages/devtools/src/constant.ts b/packages/devtools/src/constant.ts index baa3d29b2f..39d6311b09 100644 --- a/packages/devtools/src/constant.ts +++ b/packages/devtools/src/constant.ts @@ -7,6 +7,7 @@ export const defaultOptions: ModuleOptions = { enabled: undefined, // determine multiple conditions componentInspector: true, viteInspect: true, + dataInspector: true, codeServer: { enabled: true, }, diff --git a/packages/devtools/src/module-main.ts b/packages/devtools/src/module-main.ts index c3a716e0c8..2b80d17dd7 100644 --- a/packages/devtools/src/module-main.ts +++ b/packages/devtools/src/module-main.ts @@ -7,7 +7,7 @@ import type { AnyNitroConfig } from './utils/nitro-compat' import { existsSync } from 'node:fs' import fs from 'node:fs/promises' import os from 'node:os' -import { NUXT_DEVTOOLS_GROUP_ID } from '@nuxt/devtools-kit' +import { deprecate, NUXT_DEVTOOLS_GROUP_ID } from '@nuxt/devtools-kit' import { addImports, addPlugin, addTemplate, addVitePlugin, extendViteConfig, logger } from '@nuxt/kit' import { colors } from 'consola/utils' import { join } from 'pathe' @@ -277,10 +277,8 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now() await import('./integrations/plugin-metrics').then(({ setup }) => setup(ctx)) - // Data Inspector is always mounted when DevTools is enabled (no module - // option): it registers the live `Nuxt Application` source and mounts the - // bundled SPA into the Nuxt dock group. - await import('./integrations/data-inspector').then(({ setup }) => setup(ctx)) + if (options.dataInspector !== false) + await import('./integrations/data-inspector').then(({ setup }) => setup(ctx)) if (options.viteInspect !== false) await import('./integrations/vite-inspect').then(({ setup }) => setup(ctx)) @@ -288,8 +286,17 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now() if (options.componentInspector !== false) await import('./integrations/vue-tracer').then(({ setup }) => setup(ctx)) + if (options.codeServer?.enabled === false && options.vscode !== undefined) { + deprecate(nuxt, 'NDT_DEP_0008', { + api: 'devtools.vscode', + replacement: 'devtools.codeServer', + }) + } + const integrations = [ - import('./integrations/code-server').then(({ setup }) => setup(ctx)), + options.codeServer?.enabled !== false + ? import('./integrations/code-server').then(({ setup }) => setup(ctx)) + : null, (options.experimental?.timeline || options.timeline?.enabled) ? import('./integrations/timeline').then(({ setup }) => setup(ctx)) : null, diff --git a/packages/devtools/src/server-rpc/index.ts b/packages/devtools/src/server-rpc/index.ts index 8610bc94c9..6022504fca 100644 --- a/packages/devtools/src/server-rpc/index.ts +++ b/packages/devtools/src/server-rpc/index.ts @@ -5,7 +5,6 @@ import type { ModuleOptions, NuxtDevtoolsServerContext, ServerFunctions } from ' import { deprecate, registerHostDiagnostics } from '@nuxt/devtools-kit' import { logger } from '@nuxt/kit' import { colors } from 'consola/utils' -import { getServerData } from '../integrations/data-inspector' import { RPC_NAMESPACE } from '../rpc-namespace' import { setupAnalyzeBuildRPC } from './analyze-build' import { setupAssetsRPC } from './assets' @@ -165,7 +164,7 @@ export function setupRPC(nuxt: Nuxt, options: ModuleOptions) { // Deprecated compat shim (NDT_DEP_0009). The capture + live source now live // in the Data Inspector integration; `getServerConfig` is served by the // canonical `setupGeneralRPC` above. - getServerData: async () => getServerData(nuxt), + getServerData: async () => import('../integrations/data-inspector').then(({ getServerData }) => getServerData(nuxt)), } as ServerFunctions) /**