diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index f08b82e70b..31732fa048 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -78,7 +78,6 @@ "jiti": "^1.19.1", "klona": "^2.0.6", "knitwork": "^1.0.0", - "local-pkg": "^0.4.3", "magic-string": "^0.30.2", "mlly": "^1.4.0", "nitropack": "^2.5.2", @@ -88,6 +87,7 @@ "ohash": "^1.1.2", "pathe": "^1.1.1", "perfect-debounce": "^1.0.0", + "pkg-types": "^1.0.3", "prompts": "^2.4.2", "scule": "^1.0.0", "strip-literal": "^1.0.1", diff --git a/packages/nuxt/src/core/features.ts b/packages/nuxt/src/core/features.ts index 96616c996a..6c88aaebdd 100644 --- a/packages/nuxt/src/core/features.ts +++ b/packages/nuxt/src/core/features.ts @@ -1,10 +1,10 @@ import { addDependency } from 'nypm' -import { isPackageExists } from 'local-pkg' +import { resolvePackageJSON } from 'pkg-types' import { logger } from '@nuxt/kit' import prompts from 'prompts' export async function ensurePackageInstalled (rootDir: string, name: string, searchPaths?: string[]) { - if (isPackageExists(name, { paths: searchPaths })) { + if (await resolvePackageJSON(name, { url: searchPaths }).catch(() => null)) { return true } diff --git a/packages/nuxt/src/core/nuxt.ts b/packages/nuxt/src/core/nuxt.ts index 5654f56572..2588a1949c 100644 --- a/packages/nuxt/src/core/nuxt.ts +++ b/packages/nuxt/src/core/nuxt.ts @@ -411,6 +411,13 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise { } } + // Nuxt Webpack Builder is currently opt-in + if (options.builder === '@nuxt/webpack-builder') { + if (!await import('./features').then(r => r.ensurePackageInstalled(options.rootDir, '@nuxt/webpack-builder', options.modulesDir))) { + logger.warn('Failed to install `@nuxt/webpack-builder`, please install it manually, or change the `builder` option to vite in `nuxt.config`') + } + } + // Add core modules options._modules.push(pagesModule, metaModule, componentsModule) options._modules.push([importsModule, { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 317e9f3b84..41c37b4a54 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -415,9 +415,6 @@ importers: knitwork: specifier: ^1.0.0 version: 1.0.0 - local-pkg: - specifier: ^0.4.3 - version: 0.4.3 magic-string: specifier: ^0.30.2 version: 0.30.2 @@ -445,6 +442,9 @@ importers: perfect-debounce: specifier: ^1.0.0 version: 1.0.0 + pkg-types: + specifier: ^1.0.3 + version: 1.0.3 prompts: specifier: ^2.4.2 version: 2.4.2