Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use typescript library to resolve tsconfig files #246

Conversation

effervescentia
Copy link

hey @jonaskello I'm running into this problem when trying to use a library that depends on yours
(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.
This change updates the tsconfig resolution to 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

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

@effervescentia effervescentia changed the title fix: use typescript to resolve tsconfig files fix: use typescript library to resolve tsconfig files Mar 29, 2023
@codecov
Copy link

codecov bot commented Mar 29, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -1.62 ⚠️

Comparison is base (910a138) 68.16% compared to head (9a46e67) 66.54%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #246      +/-   ##
==========================================
- Coverage   68.16%   66.54%   -1.62%     
==========================================
  Files           9        9              
  Lines         311      284      -27     
  Branches       96       86      -10     
==========================================
- Hits          212      189      -23     
+ Misses         93       88       -5     
- Partials        6        7       +1     
Impacted Files Coverage Δ
src/tsconfig-loader.ts 83.78% <100.00%> (-0.60%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jonaskello
Copy link
Member

This seems interesting :-) Is there some docs that state that parseJsonConfigFileContent is a public api in the typescript package?

@effervescentia
Copy link
Author

This seems interesting :-) Is there some docs that state that parseJsonConfigFileContent is a public api in the typescript package?

That's a good question... I haven't seen anywhere that states that it is explicitly available for use or what the expected longterm support for it is. The docs from ts-node that I referenced indicate that it's a common method shared across multiple versions of typescript.

The other (or one of the other) options is to use a library that is purpose-built for resolving a typescript config file such as this one, get-tsconfig. It has no dependency on typescript to provide the config file resolution, but does claim to test against it for correctness (I haven't confirmed this for myself).

@effervescentia
Copy link
Author

@jonaskello I collected a list of notable repositories using this approach in their own source code, not sure if that helps to sell my change 😅

https://github.com/quasarframework/quasar
https://github.com/bokeh/bokeh
https://github.com/AssemblyScript/assemblyscript
https://github.com/GoogleChromeLabs/squoosh
https://github.com/vuejs/vetur

@effervescentia
Copy link
Author

hey @jonaskello any update from your end? are you looking for a different kind of solution?

@effervescentia effervescentia deleted the fix/use-typescript-to-resolve-tsconfig-files branch June 1, 2023 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants