mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxi): don't strip file extensions from dirs in tsconfig
(#4595)
This commit is contained in:
parent
b8d2e64c78
commit
2d202b59e3
@ -43,18 +43,17 @@ export const writeTypes = async (nuxt: Nuxt) => {
|
||||
if (excludedAlias.some(re => re.test(alias))) {
|
||||
continue
|
||||
}
|
||||
const path = aliases[alias].replace(/(?<=\w)\.\w+$/g, '') /* remove extension */
|
||||
const relativePath = isAbsolute(path)
|
||||
? relative(nuxt.options.rootDir, path) || '.'
|
||||
: path
|
||||
tsConfig.compilerOptions.paths[alias] = [relativePath]
|
||||
const relativePath = isAbsolute(aliases[alias])
|
||||
? relative(nuxt.options.rootDir, aliases[alias]) || '.'
|
||||
: aliases[alias]
|
||||
|
||||
try {
|
||||
const { isDirectory } = await fsp.stat(resolve(nuxt.options.rootDir, relativePath))
|
||||
if (isDirectory) {
|
||||
tsConfig.compilerOptions.paths[`${alias}/*`] = [`${relativePath}/*`]
|
||||
}
|
||||
} catch { }
|
||||
const stats = await fsp.stat(resolve(nuxt.options.rootDir, relativePath)).catch(() => null /* file does not exist */)
|
||||
if (stats?.isDirectory()) {
|
||||
tsConfig.compilerOptions.paths[alias] = [relativePath]
|
||||
tsConfig.compilerOptions.paths[`${alias}/*`] = [`${relativePath}/*`]
|
||||
} else {
|
||||
tsConfig.compilerOptions.paths[alias] = [relativePath.replace(/(?<=\w)\.\w+$/g, '')] /* remove extension */
|
||||
}
|
||||
}
|
||||
|
||||
const references: TSReference[] = [
|
||||
|
Loading…
Reference in New Issue
Block a user