diff --git a/.changeset/three-rockets-jump.md b/.changeset/three-rockets-jump.md new file mode 100644 index 000000000..fdd71a638 --- /dev/null +++ b/.changeset/three-rockets-jump.md @@ -0,0 +1,5 @@ +--- +"@fake-scope/fake-pkg": patch +--- + +fix: add default tsconfig.baseUrl to align with tsc behavior diff --git a/packages/register/read-default-tsconfig.ts b/packages/register/read-default-tsconfig.ts index 44e072c59..ed30165e1 100644 --- a/packages/register/read-default-tsconfig.ts +++ b/packages/register/read-default-tsconfig.ts @@ -34,6 +34,12 @@ export function readDefaultTsConfig( const { config } = ts.readConfigFile(fullTsConfigPath, ts.sys.readFile) const { options, errors, fileNames } = ts.parseJsonConfigFileContent(config, ts.sys, dirname(fullTsConfigPath)) + + // if baseUrl not set, use dirname of tsconfig.json. align with ts https://www.typescriptlang.org/tsconfig#paths + if (options.paths && !options.baseUrl) { + options.baseUrl = dirname(fullTsConfigPath) + } + if (!errors.length) { compilerOptions = options compilerOptions.files = fileNames