chore: use jiti for ts config loading #1474
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
As i mentioned:
Unfortunately we can't use
c12
because it load asynchonously but we can incorporatejiti
instead ofcosmiconfig-typescript-loader
/ts-node
.Looks like jiti was created for such usecases, where
ts-node
is not. The benefit of using jiti overts-node
:The problem with ts-node is that once it registered it starts processing all require calls in the current VM. That caused that not only config with it's dependecies get transpiled but also other code running in the same instance after register call.
Also all subsequent calls to
TypeScriptLoader
withts-node
would cause registering another instance of compiler for require module system and this is end up with out memory at certain point.Types of changes
Fixes # (issue)
Checklist