-
Notifications
You must be signed in to change notification settings - Fork 14
feat: Migrate to Hardhat 3 #312
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
base: feat/clean-dep
Are you sure you want to change the base?
Conversation
…0.10, add old config file for reference, and update Node version in .nvmrc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the project from CommonJS to ES Modules (ESM) and upgrades Hardhat from version 2 to version 3. The configuration has been significantly simplified while maintaining core functionality.
Key changes:
- Package.json now declares
"type": "module"to enable ESM - Hardhat upgraded from v2.22.18 to v3.0.10
- Node.js version updated from 20 to 22.10.0
- Direct module execution check updated from CommonJS pattern to ESM-compatible approach
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Declares ESM mode, upgrades Hardhat to v3, removes incompatible toolbox dependency |
| hardhat.config.ts | Drastically simplified configuration, removing most network/task definitions (likely moved elsewhere) |
| hardhat.config.old.ts | Preserves previous configuration with Hardhat 3 adaptations for reference |
| scripts/tools/copy-deployments.ts | Updates direct execution check from CommonJS to ESM pattern |
| .nvmrc | Specifies Node.js 22.10.0 for version management |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // When script is run directly | ||
| if (require.main === module) { | ||
| // When script is run directly (ESM compatible check) | ||
| if (import.meta.url === `file://${process.argv[1]}`) { |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ESM direct execution check is incorrect. process.argv[1] contains an absolute file path, but import.meta.url is a file:// URL. On Windows, this comparison will fail due to path separator differences. Use import.meta.url === pathToFileURL(process.argv[1]).href with import { pathToFileURL } from 'url'; instead.
| }, | ||
| }, | ||
| }; | ||
| import type { HardhatUserConfig } from 'hardhat/config'; |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The drastically simplified configuration is missing plugin imports (hardhat-deploy, hardhat-dependency-compiler, solidity-docgen, dotenv/config) and all custom tasks that were present in the original. While hardhat.config.old.ts preserves the full configuration, ensure these are intentionally removed or relocated, as this will break existing workflows.
…endency compiler and solidity docgen, and add new ABI exporter settings
Hardhat Migration Guide
État de la migration Hardhat 3
✅ Fait
^2.22.18→^3.0.10package.json: ajout"type": "module"(ESM requis)hardhat.config.tsavec seulementsolidityconfighardhat.config.old.ts.nvmrcmodifié avec Node.js 22.10.0Plugins non compatibles (à migrer/remplacer)
hardhat-deploy(^0.11.43)Package subpath './types/runtime' is not definedhardhat-dependency-compiler(^1.2.1)Package subpath './builtin-tasks/task-names' is not defined@nomicfoundation/hardhat-toolbox(retiré)package.json@nomicfoundation/hardhat-toolbox-mocha-etherspour les tests (voir guide)solidity-docgen(^0.6.0-beta.36)ERR_REQUIRE_ESMsolidity-coverage(^0.8.14)📋 À faire
Migration de la configuration (depuis
hardhat.config.old.ts)networks) avectype: 'http'outype: 'edr-simulated'abis,docgen,test)namedAccounts(si supporté par hardhat-deploy v3)etherscanetsourcifytypechainconfigmochaconfigPlugins et tests
@nomicfoundation/hardhat-toolbox-mocha-etherspour les testsdeploy/) pour fonctionner sans hardhat-deploy ou avec alternativesolidity-coveragecompatibilitésolidity-docgenune fois compatibleDépendances externes
hardhat-dependency-compilerquand compatiblehardhat-deployquand compatible@mudgen/diamond-1avec Hardhat 3