Skip to content

Commit

Permalink
fix: set baseUrl if none is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
lachieh committed Oct 1, 2024
1 parent a7e1c0c commit 1232266
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 1232266

Please sign in to comment.