From 7e668d9b4854534a8f09defeb906d3062e77c239 Mon Sep 17 00:00:00 2001 From: York Yao Date: Sun, 13 Mar 2022 22:18:09 +0800 Subject: [PATCH] fix: relative path baseUrl resolves wrong path #101 --- packages/core/src/tsconfig.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/core/src/tsconfig.ts b/packages/core/src/tsconfig.ts index 269459e..b9a1bce 100644 --- a/packages/core/src/tsconfig.ts +++ b/packages/core/src/tsconfig.ts @@ -17,6 +17,18 @@ export async function getProjectRootNamesAndCompilerOptions(project: string) { } const rootNames = await getRootNames(config, dirname) + if (compilerOptions.baseUrl) { + if (compilerOptions.baseUrl === '.' + || compilerOptions.baseUrl === '..' + || compilerOptions.baseUrl.startsWith(`.${path.sep}`) + || compilerOptions.baseUrl.startsWith(`..${path.sep}`) + || compilerOptions.baseUrl.startsWith('./') + || compilerOptions.baseUrl.startsWith('../') + ) { + compilerOptions.baseUrl = path.resolve(path.resolve(process.cwd(), dirname), compilerOptions.baseUrl) + } + } + return { rootNames, compilerOptions } }