Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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: {}
})