Skip to content

Commit

Permalink
feat(nuxt): add @nuxt/devtools as dependency and enable (#23576)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Oct 12, 2023
1 parent eb40409 commit 598e8c2
Show file tree
Hide file tree
Showing 4 changed files with 1,268 additions and 62 deletions.
1 change: 1 addition & 0 deletions packages/nuxt/package.json
Expand Up @@ -53,6 +53,7 @@
},
"dependencies": {
"@nuxt/devalue": "^2.0.2",
"@nuxt/devtools": "1.0.0-beta.1",
"@nuxt/kit": "workspace:*",
"@nuxt/schema": "workspace:*",
"@nuxt/telemetry": "^2.5.2",
Expand Down
19 changes: 10 additions & 9 deletions packages/nuxt/src/core/nuxt.ts
Expand Up @@ -441,15 +441,16 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
options.appDir = options.alias['#app'] = resolve(distDir, 'app')
options._majorVersion = 3

// Nuxt DevTools is currently opt-in
if (options.devtools === true || (options.devtools && options.devtools.enabled !== false)) {
if (await import('./features').then(r => r.ensurePackageInstalled('@nuxt/devtools', {
rootDir: options.rootDir,
searchPaths: options.modulesDir
}))) {
options._modules.push('@nuxt/devtools')
} else {
logger.warn('Failed to install `@nuxt/devtools`, please install it manually, or disable `devtools` in `nuxt.config`')
// Nuxt DevTools only works for Vite
if (options.builder === '@nuxt/vite-builder') {
const isDevToolsEnabled = typeof options.devtools === 'boolean'
? options.devtools
: 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')
}
}
}

Expand Down
8 changes: 3 additions & 5 deletions packages/schema/src/config/adhoc.ts
Expand Up @@ -60,11 +60,9 @@ export default defineUntypedSchema({
/**
* Enable Nuxt DevTools for development.
*
* This is an experimental feature.
* Breaking changes for devtools might not reflect on the version of Nuxt.
* @see [Nuxt DevTools](https://devtools.nuxtjs.org/) for more information.
* @experimental
* @type {boolean | { enabled: boolean, [key: string]: any }}
* @see [Nuxt DevTools](https://devtools.nuxt.com/) for more information.
* @type { { enabled: boolean, [key: string]: any } }
*/
devtools: false
devtools: {}
})

0 comments on commit 598e8c2

Please sign in to comment.