-
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
Support for ESM in TypeScript projects #3385
Comments
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: b31f8c05-52a3-44ca-b22e-10ec21278d4c |
@fvictorio we use wagmi/core for some scripts which only supports ESM. Had to convert all tests to .js and extract chunks of scripts into another package for now to deal with this. |
I'm using https://github.com/sindresorhus/execa, which is ESM-only. |
Suggestion for TS ESM implementation: ts-node has a |
Copying @alcuadrado comments from monorepo:
What about
If you keep supporting two module systems, ESM modules would be able to import common.js code - which uses old sequential |
Oh, that may be a great idea actually! I think now ESM in node.js means/implies that you have top-level-await. This could work! Thanks ! |
Upvote; we are using ESM in our TypeScript project because of a dependency requirement. |
pure esm package is coming. |
I am looking to integrate Playwright with Hardhat + Wagmi in order to automate frontend testing that involves connecting to a hardhat node :) |
Upvote; we are using ESM in our TypeScript project |
do u know when? 🧐 |
upvote, many packages are ESM only now, I have to install older versions for compatibility. all my projects and code is ESM now, except for hardhat. |
Upvoting as well. We have https://github.com/lukso-network/lsp-smart-contracts In our case, this is problematic as any Hardhat Typescript project that has the The only workaround we found was in this PR by @richtera: lukso-network/lsp-smart-contracts#601. https://github.com/lukso-network/lsp-smart-contracts/pull/601/files The file in the folder looks like this: ES Lint raises a warning, but we are still able to import as shown below. import { INTERFACE_IDS } from "@lukso/lsp-smart-contracts/dist/constants.cjs.js";
const test = INTERFACE_IDS.LSP0ERC725Account; |
Following this issue. Would help a lot to get rid of some workarounds for ESM/CJS interop. |
I experience the shifted line numbers in stack traces as well. Thanks @fullkomnun for your report, saved me time from trying these mitigations myself. |
It's 2024 and I'd like to start new projects with Typescript and ESM support. It would be create to support a runtime like Bun or Deno which supports these natively out of the box. |
I am trying to migrate a scaffold-eth project to allow for hardhat ESM support. Repo: https://github.com/Ahmedborwin/cryptoSoccer. I have followed the instructions listed by @schaable but I still get the much-loved HH19 error when I try to import hardhat tasks (that I got from the chainlink functions boilerplate) to my hardhat.config.cts. The tasks folder is made up of .js scripts that are common modules. Not sure why importing them is causing the error in the first place. I tried converting them to .cjs but still no luck. Anyone have any idea how I can make these hardhat tasks available to my hardhat typescript project? If this question is badly worded, please be patient with me. I am learning. Thank you |
Is there any news on the topic from the team? Should the user expect the project to be stuck on the old CJS or was any progress made with ESM? Thanks guys for the effort. |
The team is currently focused on the next version of Hardhat, which will support ESM. |
It would be great if the next version could be used with |
Please comment and/or upvote this issue if you need support for ESM in TypeScript projects. If possible, tell us more about your use case and why you need this and cannot just transpile to cjs.
UPDATE: We have an experimental version working
See this comment to learn how to use an experimental version of this: #3385 (comment)
The text was updated successfully, but these errors were encountered: