From d619c51872cd81eac727a7dd659c3c06324a33ea Mon Sep 17 00:00:00 2001 From: Aditya Pandey Date: Thu, 10 Oct 2024 15:05:40 -0500 Subject: [PATCH] Fix build with TS alias without basePath --- packages/babel-config/src/common.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/babel-config/src/common.ts b/packages/babel-config/src/common.ts index 2b3e5b00b02b..5829c7cfaf1b 100644 --- a/packages/babel-config/src/common.ts +++ b/packages/babel-config/src/common.ts @@ -140,16 +140,21 @@ export const getPathsFromTypeScriptConfig = ( return {} } - if (!config.compilerOptions?.baseUrl || !config.compilerOptions?.paths) { + if (!config.compilerOptions?.paths) { return {} } const { baseUrl, paths } = config.compilerOptions - // Convert it to absolute path - on windows the baseUrl is already absolute - const absoluteBase = path.isAbsolute(baseUrl) - ? baseUrl - : path.join(rootDir, baseUrl) + let absoluteBase: string + if (baseUrl) { + // Convert it to absolute path - on windows the baseUrl is already absolute + absoluteBase = path.isAbsolute(baseUrl) + ? baseUrl + : path.join(rootDir, baseUrl) + } else { + absoluteBase = rootDir + } const pathsObj: Record = {} for (const [key, value] of Object.entries(paths)) {