tsconfig-paths
tsconfig-paths copied to clipboard
Add support for 'deep' extension
Typescript has support for deep config extensions
, but it seems like tsconfig-paths
isn't handling this too well and stops after the first 'extend'.
This rewrite makes sure it 'keeps on extending' until no 'extends' property is found.
Codecov Report
Merging #112 into master will not change coverage by
%
. The diff coverage isn/a
.
@@ Coverage Diff @@
## master #112 +/- ##
======================================
Coverage 0.00% 0.00%
======================================
Files 4 4
Lines 129 129
Branches 52 52
======================================
Misses 129 129
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 32338c6...61bab21. Read the comment docs.
Hi @jonaskello, any change of checking this out and getting it merged? :)
hey @jonaskello I'm running into the same problem trying to use a tool many steps removed from your own library (dependency-cruiser)
My company has a fairly complex typescript configuration setup which we have extracted to a config that is extended from multiple levels deep, as a result the paths
configuration that is inherited is unfortunately ignored by your library.
Perhaps you could update your tsconfig
resolution to just use what is provided out-of-the-box by typescript
itself to avoid needing to concern yourself with the details of how config extension actually works
https://typestrong.org/ts-node/api/interfaces/TSCommon.html#readConfigFile https://typestrong.org/ts-node/api/interfaces/TSCommon.html#parseJsonConfigFileContent
you should be able to use something like the following
import typescript from 'typescript';
const rawConfig = typescript.readConfigFile('tsconfig.json', typescript.sys.readFile);
const fullConfig = typescript.parseJsonConfigFileContent(
rawConfig.config,
typescript.sys,
'path/to/repo',
{},
'tsconfig.json'
);
fullConfig.options; // tsconfig compiler options (with all inherited values)
ironically I originally saw this while exploring the codebase of dependency-cruiser
trying to get to the bottom of this issue
https://github.com/sverweij/dependency-cruiser/blob/master/src/config-utl/extract-ts-config.js#L52
I'm also happy to make a PR with the above change if you like the solution but don't have the time to implement it