Skip to content
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: Load hardhat.config.cjs to partially support ESM projects #3155

Merged
merged 7 commits into from Sep 13, 2022

Conversation

phated
Copy link

@phated phated commented Sep 8, 2022

  • I talked about the limitations in the ESM PR and suggestion in the ts-node transpile PR and discussed this with @fvictorio

Due to the way hardhat registers tasks, v3 can't support ESM (as I outlined at #1994 (comment)); however, you can load .cjs files inside an ESM project. Since many projects are converting to ESM-only, it is helpful to be able to run hardhat in those contexts.

This change should allow a monorepo to become "type": "module" and still use hardhat in commonjs mode. 🎉

This support is in parallel to my other PR (#3017) which adds this support for TypeScript. There are follow up PRs to allow loading of ESM tasks and scripts.

@changeset-bot
Copy link

changeset-bot bot commented Sep 8, 2022

⚠️ No Changeset found

Latest commit: 17c56bc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Sep 8, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
hardhat ✅ Ready (Inspect) Visit Preview Sep 13, 2022 at 1:18PM (UTC)
hardhat-storybook ✅ Ready (Inspect) Visit Preview Sep 13, 2022 at 1:18PM (UTC)

@phated phated changed the title feat: Load harhat.config.cjs to partially support ESM projects feat: Load hardhat.config.cjs to partially support ESM projects Sep 8, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2022

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: be8191f8-10f8-4c1f-af20-4d7d0e39feca

@phated
Copy link
Author

phated commented Sep 8, 2022

With this .cjs change, I found that the run task just supports ESM, so I've added those tests to this PR! 🎉

@alcuadrado
Copy link
Member

👑

@alcuadrado
Copy link
Member

Should we review and merge this and #3017 in any particular order?

@phated
Copy link
Author

phated commented Sep 8, 2022

@alcuadrado I think we should merge this one first. I believe that the TS change should also add tests for run/test tasks after those are done for JS.

@phated
Copy link
Author

phated commented Sep 12, 2022

@alvrs was testing this out and pointed out that I didn't update isCwdInsideProject 🙈 This fixes the issue and adds a test

@alcuadrado Do you think this can land soon so I can rebase #3156 and update #3017 ?

@fvictorio fvictorio changed the base branch from main to esm September 13, 2022 12:26
@fvictorio
Copy link
Member

Merging this to the esm feature branch.

@fvictorio fvictorio merged commit c93960a into NomicFoundation:esm Sep 13, 2022
@phated phated deleted the phated/cjs branch September 13, 2022 20:17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants