fix(nuxi): strip extensions from absolute paths (for types) (#4300)

This commit is contained in:
Daniel Roe 2022-04-19 20:14:39 +01:00 committed by GitHub
parent b38dc097f6
commit eed7036627
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,9 +43,10 @@ export const writeTypes = async (nuxt: Nuxt) => {
if (excludedAlias.some(re => re.test(alias))) { if (excludedAlias.some(re => re.test(alias))) {
continue continue
} }
const relativePath = isAbsolute(aliases[alias]) const path = aliases[alias].replace(/(?<=\w)\.\w+$/g, '') /* remove extension */
? relative(nuxt.options.rootDir, aliases[alias]).replace(/(?<=\w)\.\w+$/g, '') /* remove extension */ || '.' const relativePath = isAbsolute(path)
: aliases[alias] ? relative(nuxt.options.rootDir, path) || '.'
: path
tsConfig.compilerOptions.paths[alias] = [relativePath] tsConfig.compilerOptions.paths[alias] = [relativePath]
try { try {