From d7402a79917a414ff8aa3f5c59f776207343fdc5 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 20 Jun 2024 19:57:05 +0100 Subject: [PATCH] fix(nuxt): handle subpaths more correctly --- packages/nuxt/src/core/nuxt.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/nuxt/src/core/nuxt.ts b/packages/nuxt/src/core/nuxt.ts index b2551a7c9..2cab93f2c 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]]] }