diff --git a/packages/nuxt/src/core/nuxt.ts b/packages/nuxt/src/core/nuxt.ts index a121ab8442..8952a1f7df 100644 --- a/packages/nuxt/src/core/nuxt.ts +++ b/packages/nuxt/src/core/nuxt.ts @@ -99,12 +99,12 @@ async function initNuxt (nuxt: Nuxt) { const packageJSON = await readPackageJSON(nuxt.options.rootDir).catch(() => ({}) as PackageJson) const dependencies = new Set([...Object.keys(packageJSON.dependencies || {}), ...Object.keys(packageJSON.devDependencies || {})]) const paths = Object.fromEntries(await Promise.all(coreTypePackages.map(async (pkg) => { - // ignore packages that exist in `package.json` as these can be resolved by TypeScript - if (dependencies.has(pkg) && !(pkg in nightlies)) { return [] } - const [_pkg = pkg, _subpath] = /^[^@]+\//.test(pkg) ? pkg.split('/') : [pkg] const subpath = _subpath ? '/' + _subpath : '' + // ignore packages that exist in `package.json` as these can be resolved by TypeScript + if (dependencies.has(_pkg) && !(_pkg in nightlies)) { return [] } + async function resolveTypePath (path: string) { try { const r = await _resolvePath(path, { url: nuxt.options.modulesDir, conditions: ['types', 'import', 'require'] }) @@ -120,14 +120,14 @@ async function initNuxt (nuxt: Nuxt) { // deduplicate types for nightly releases if (_pkg in nightlies) { - const nightly = nightlies[pkg as keyof typeof nightlies] + const nightly = nightlies[_pkg as keyof typeof nightlies] const path = await resolveTypePath(nightly + subpath) if (path) { return [[pkg, [path]], [nightly + subpath, [path]]] } } - const path = await resolveTypePath(pkg + subpath) + const path = await resolveTypePath(_pkg + subpath) if (path) { return [[pkg, [path]]] }