-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: full ESM config support using Jiti #1041
base: main
Are you sure you want to change the base?
Conversation
Hi @henrist, I really like the change, but I will need some time to consider any possible backwards compatibility implications caused it. I may not be able to properly review this until next week (it's the end of tax season over here which limits my extra time), but based on a quick scroll through I think it looks great overall. Backwards compatibility and potential breakage is my main concern and I'm grateful that you seem to have kept that in mind. For now, we are not ready to fully remove Do note that while this PR may add full ESM support on the CLI side, our runtimes do not yet support ESM due to complexities of the current architecture, so unfortunately this PR does not fully enable ESM on the entire Checkly platform. However, we have a project in progress to allow ESM to work on our runners, so ESM everywhere may soon be a possibility too. For now though it's a limitation that you have to keep in mind. Thanks a lot! |
@sorccu Thanks for your quick feedback! Looking forward to your review. I have put some effort into avoiding this to become a breaking change. I've tested it an original template project, new template project and on a couple of our repos. But useful to have someone else double check. Great to hear that you're working on ESM support on the runner side as well, although due to the limitation of dependencies and the fact that it parses module syntax just fine, this haven't been a real problem for us. I did use the term "config" in the PR title in an attempt to make it clear that this is for config of checks, not the check scripts/specs themself. Would it be possible to trigger the canary/experimental release for this PR? |
I would be happy to trigger a build, but unfortunately that will also have to wait till next week as our workflows do not currently give access to secrets for PRs from forks, which means that both integration tests and the build would fail. I will massage the workflows a little next week to make that work. |
Unfortunately I was extra busy last week and did not have bandwidth to test your PR, but I will handle this within the next 2 days. Super excited about this feature. |
Unfortunately I had to come up with a temporary janky solution to run the workflows by creating a non-fork PR with your changes in #1048, but since the commit hash is the same, the test results can be seen in this original PR too. I am happy to keep merging any changes to the build PR and make any other changes as needed. An experimental build is also available: However, as can be seen from the result of the test run, there seems to be some sort of an incompatibility. I will look into this shortly. |
That's great! I'll test out the experimental build on my end tomorrow or Thursday, and also see if I can understand the reason for the failure. I have 30+ repos here with Checkly CLI, however they are pretty homogeneous.
|
Indeed looks like a platform problem as it runs fine on ubuntu-latest. I wonder if this is a Jest issue and a caching bug in Jiti. Running it with debug mode shows that under Windows some additional file are being transpiled. It seems under Linux those same files exists in Node.js module cache, but on Windows I think it becomes a mix of path styles so the cache is not used. Even if we set the This problem is limited to testing here though, as regular users won't have this behavior since the Checkly CLI code is compiled to JS. A bit sure what would be the best fix. I'll anyways see if I can create a repro for the potential caching bug. |
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.