-
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
Hardhat compile - "Cannot use import statement outside a module" / tsconfig.json esnext #1808
Comments
Hey @martinoss, Sorry for the late answer. Unfortunately, Hardhat doesn't support ESM yet. We'll make an announcement once once we support it. |
@martinoss : Could you help me with the workaround? Did you use multiple tsconfig? @alcuadrado : Do you have any ETA? |
…c directory https://github.com/oklas/react-app-rewire-alias Issue: [Hardhat doesn't support ESM yet](NomicFoundation/hardhat#1808) So created 2 tsconfig files to cater hardhat and react needs. Signed-off-by: Sedhu <[email protected]>
We don't. And to be honest, I don't think we'll work on this anytime soon. We do want to support it at some point, but it's not on our short or mid-term roadmap right now. |
Hardhat and react projects can't easily coexist. NomicFoundation/hardhat#1808
for anyone finding this issue, know that it has been partly fixed in #957 (comment) |
I wanted to create a combined project with Hardhat and a React frontend, both configured to use typescript.
My plan was to share the same tsconfig.json, but Hardhat forces me to use "module": "commonjs" and React automatically changes the setting back to "esnext" when starting the application.
When I run "npx hardhat compile" for example, I get the error "Cannot use import statement outside a module"
The exception is thrown here, caused by require():
https://github.com/nomiclabs/hardhat/blob/ee4969a0a8f746f4775d4018326056d161066869/packages/hardhat-core/src/internal/core/config/config-loading.ts#L23
Is it required to configure commonjs when working with hardhat?
The text was updated successfully, but these errors were encountered: