From 12322661cb7c81aa687fc6f19d5e40bf0c19a7a5 Mon Sep 17 00:00:00 2001 From: Lachlan Heywood Date: Mon, 30 Sep 2024 20:53:32 -0400 Subject: [PATCH] fix: set baseUrl if none is provided --- src/plugin.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugin.ts b/src/plugin.ts index dbe613d..74d773b 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -288,7 +288,13 @@ export function dtsPlugin(options: PluginOptions = {}): import('vite').Plugin { : [ensureAbsolute(content?.raw.compilerOptions?.outDir || 'dist', root)] } - const { baseUrl, paths } = compilerOptions + const { + // Here we are using the default value to set the `baseUrl` to the current directory if no value exists. This is + // the same behavior as the TS Compiler. See TS source: + // https://github.com/microsoft/TypeScript/blob/3386e943215613c40f68ba0b108cda1ddb7faee1/src/compiler/utilities.ts#L6493-L6501 + baseUrl = compilerOptions.paths ? process.cwd() : undefined, + paths + } = compilerOptions if (pathsToAliases && baseUrl && paths) { aliases.push(