paths in extended tsconfig not resolved correctly
xania opened this issue · comments
This line can be improved,
- in case baseUrl is not specified in parent config then we can still have paths defined that need to be mapped
- baseUrl of the extended config should remain intact / unchanged
tsconfig-paths/src/tsconfig-loader.ts
Line 162 in 1b71683
I have here a draft but working implementation for fixing these issues, will create a PR for that soon.
if (base.compilerOptions) {
const basePath = path.resolve(
path.join(path.dirname(configFilePath), config.compilerOptions?.baseUrl ?? '.')
);
var extendsDir = path.dirname(extendedConfigPath);
if (base.compilerOptions.paths) {
for(const key in base.compilerOptions.paths) {
const paths = base.compilerOptions.paths[key];
for(let i=0 ; i<paths.length ; i++) {
const fullPath = path.resolve(
path.join(extendsDir, base.compilerOptions.baseUrl || '.', paths[i])
);
paths[i] = path.relative(
basePath,
fullPath
);
}
}
}
delete base.compilerOptions.baseUrl;
}