feat: full ESM config support using Jiti #1041
Open
+222
−121
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.
I hereby confirm that I followed the code guidelines found at engineering guidelines <-- I don't have access to this
Affected Components
Notes for the Reviewer
The current use of
ts-node
is problematic:ts-node
is currently not maintained and haven't received updates for 1+ year. It lacks newer TypeScript features. For instance it does not support multiple extends intsconfig.json
that came with TypeScript 5.This has been a large pain as most of the code I work with is in ESM. It has required non-trivial tsconfig files to workaround this.
This PR introduces Jiti as an alternative to
ts-node
. I could have picked tsx as well, but I don't find the API of tsx as intuitive/simple as Jiti. This is very similar as the implementation of eslint that uses Jiti for its TypeScript support.Additional file extensions are also supported:
.mts
,.cts
,.cjs
To avoid a breaking change it supports both
ts-node
andjiti
. Existing users with onlyts-node
should not be affected, while new users will be recommended to addjiti
. Jiti does not depend on atsconfig.json
file (and does not do type checking), sotypescript
is not requested as a dependency. Existing users can addjiti
to get better (and ESM) support, and we also recommend this on compile issues. If you're open for a breaking change we could removets-node
support and avoid dealing with both.