mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 15:42:09 +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))) {
|
if (excludedAlias.some(re => re.test(alias))) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const path = aliases[alias].replace(/(?<=\w)\.\w+$/g, '') /* remove extension */
|
const relativePath = isAbsolute(aliases[alias])
|
||||||
const relativePath = isAbsolute(path)
|
? relative(nuxt.options.rootDir, aliases[alias]) || '.'
|
||||||
? relative(nuxt.options.rootDir, path) || '.'
|
: aliases[alias]
|
||||||
: path
|
|
||||||
tsConfig.compilerOptions.paths[alias] = [relativePath]
|
|
||||||
|
|
||||||
try {
|
const stats = await fsp.stat(resolve(nuxt.options.rootDir, relativePath)).catch(() => null /* file does not exist */)
|
||||||
const { isDirectory } = await fsp.stat(resolve(nuxt.options.rootDir, relativePath))
|
if (stats?.isDirectory()) {
|
||||||
if (isDirectory) {
|
tsConfig.compilerOptions.paths[alias] = [relativePath]
|
||||||
tsConfig.compilerOptions.paths[`${alias}/*`] = [`${relativePath}/*`]
|
tsConfig.compilerOptions.paths[`${alias}/*`] = [`${relativePath}/*`]
|
||||||
|
} else {
|
||||||
|
tsConfig.compilerOptions.paths[alias] = [relativePath.replace(/(?<=\w)\.\w+$/g, '')] /* remove extension */
|
||||||
}
|
}
|
||||||
} catch { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const references: TSReference[] = [
|
const references: TSReference[] = [
|
||||||
|
Loading…
Reference in New Issue
Block a user