feat(nuxt): add @nuxt/devtools as dependency and enable (#23576)

This commit is contained in:
Anthony Fu 2023-10-12 23:50:49 +08:00 committed by GitHub
parent eb40409f23
commit 598e8c2cd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1268 additions and 62 deletions

View File

@ -53,6 +53,7 @@
}, },
"dependencies": { "dependencies": {
"@nuxt/devalue": "^2.0.2", "@nuxt/devalue": "^2.0.2",
"@nuxt/devtools": "1.0.0-beta.1",
"@nuxt/kit": "workspace:*", "@nuxt/kit": "workspace:*",
"@nuxt/schema": "workspace:*", "@nuxt/schema": "workspace:*",
"@nuxt/telemetry": "^2.5.2", "@nuxt/telemetry": "^2.5.2",

View File

@ -441,15 +441,16 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
options.appDir = options.alias['#app'] = resolve(distDir, 'app') options.appDir = options.alias['#app'] = resolve(distDir, 'app')
options._majorVersion = 3 options._majorVersion = 3
// Nuxt DevTools is currently opt-in // Nuxt DevTools only works for Vite
if (options.devtools === true || (options.devtools && options.devtools.enabled !== false)) { if (options.builder === '@nuxt/vite-builder') {
if (await import('./features').then(r => r.ensurePackageInstalled('@nuxt/devtools', { const isDevToolsEnabled = typeof options.devtools === 'boolean'
rootDir: options.rootDir, ? options.devtools
searchPaths: options.modulesDir : options.devtools?.enabled !== false // enabled by default unless explicitly disabled
}))) {
if (isDevToolsEnabled) {
if (!options._modules.some(m => m === '@nuxt/devtools' || m === '@nuxt/devtools-edge')) {
options._modules.push('@nuxt/devtools') options._modules.push('@nuxt/devtools')
} else { }
logger.warn('Failed to install `@nuxt/devtools`, please install it manually, or disable `devtools` in `nuxt.config`')
} }
} }

View File

@ -60,11 +60,9 @@ export default defineUntypedSchema({
/** /**
* Enable Nuxt DevTools for development. * Enable Nuxt DevTools for development.
* *
* This is an experimental feature.
* Breaking changes for devtools might not reflect on the version of Nuxt. * Breaking changes for devtools might not reflect on the version of Nuxt.
* @see [Nuxt DevTools](https://devtools.nuxtjs.org/) for more information. * @see [Nuxt DevTools](https://devtools.nuxt.com/) for more information.
* @experimental * @type { { enabled: boolean, [key: string]: any } }
* @type {boolean | { enabled: boolean, [key: string]: any }}
*/ */
devtools: false devtools: {}
}) })

File diff suppressed because it is too large Load Diff