Skip to content

Commit d7402a7

Browse files
committed
fix(nuxt): handle subpaths more correctly
1 parent e6940db commit d7402a7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/nuxt/src/core/nuxt.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ async function initNuxt (nuxt: Nuxt) {
9999
const packageJSON = await readPackageJSON(nuxt.options.rootDir).catch(() => ({}) as PackageJson)
100100
const dependencies = new Set([...Object.keys(packageJSON.dependencies || {}), ...Object.keys(packageJSON.devDependencies || {})])
101101
const paths = Object.fromEntries(await Promise.all(coreTypePackages.map(async (pkg) => {
102-
// ignore packages that exist in `package.json` as these can be resolved by TypeScript
103-
if (dependencies.has(pkg) && !(pkg in nightlies)) { return [] }
104-
105102
const [_pkg = pkg, _subpath] = /^[^@]+\//.test(pkg) ? pkg.split('/') : [pkg]
106103
const subpath = _subpath ? '/' + _subpath : ''
107104

105+
// ignore packages that exist in `package.json` as these can be resolved by TypeScript
106+
if (dependencies.has(_pkg) && !(_pkg in nightlies)) { return [] }
107+
108108
async function resolveTypePath (path: string) {
109109
try {
110110
const r = await _resolvePath(path, { url: nuxt.options.modulesDir, conditions: ['types', 'import', 'require'] })
@@ -120,14 +120,14 @@ async function initNuxt (nuxt: Nuxt) {
120120

121121
// deduplicate types for nightly releases
122122
if (_pkg in nightlies) {
123-
const nightly = nightlies[pkg as keyof typeof nightlies]
123+
const nightly = nightlies[_pkg as keyof typeof nightlies]
124124
const path = await resolveTypePath(nightly + subpath)
125125
if (path) {
126126
return [[pkg, [path]], [nightly + subpath, [path]]]
127127
}
128128
}
129129

130-
const path = await resolveTypePath(pkg + subpath)
130+
const path = await resolveTypePath(_pkg + subpath)
131131
if (path) {
132132
return [[pkg, [path]]]
133133
}

0 commit comments

Comments
 (0)