-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: Support .cts extension with ts-node 10+ #3017
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This issue is also being tracked on Linear. We use Linear to manage our development process, but we keep the conversations on Github. LINEAR-ID: aa761df6-e663-4f74-a192-ba44dc37a0f4 |
Thanks for submitting this PR! Unfortunately, it has some linter errors, so we can't merge it yet. Can you please fix them? Running yarn |
@alcuadrado this looks good to me. Do you want to take a look? |
Hmm, this might need some changes to the Hardhat config loading logic. |
edit: on further consideration I don't think this solves anything. we can rename all the files to .cts, which allows the project itself to be ESM compatible and we could load ESM modules into .ts files, but we wouldn't be able to load ESM modules into .cts files, which would basically be all the hardhat project files. whilst great it we can use hardhat inside a ESM project, it doesn't really allow the use of ESM modules, unless those are standalone scripts/modules not imported into any hardhat files. this whole ESM thing is a mess. I tried this and it doesn't seem to be detecting my .cts config file. and if I manually pass
I tried editing this in package.json and renaming to Lock.cts but it doesn't seem to detect it and reports oh snap it worked.
I'd love to contribute but I've only been working with node for about 2 weeks |
@robwilkes this is the very first, minor step into getting some semblance of interopt with |
Woohoo, your important contribution to this open-source project has earned you a GitPOAP! GitPOAP: 2022 Hardhat Contributor: Head on over to GitPOAP.io and connect your GitHub account to mint! |
Merging this to the |
Due to the way hardhat registers tasks, v3 can't support ESM (as I outlined at #1994 (comment)); however, TypeScript added ESM support and many projects are converting to ESM-only. The ts-node team added support for the
.cts
extension in TypeStrong/ts-node#1694, which allows individual files to be resolved as commonjs (see https://github.com/TypeStrong/ts-node#module-type-overrides).This change should allow a monorepo to become
"type": "module"
and still use hardhat in commonjs mode. 🎉