Skip to content

Conversation

@Le-Caignec
Copy link
Contributor

@Le-Caignec Le-Caignec commented Oct 31, 2025

Hardhat Migration Guide

État de la migration Hardhat 3

✅ Fait

  • Hardhat mis à jour : ^2.22.18^3.0.10
  • package.json : ajout "type": "module" (ESM requis)
  • Configuration minimale créée : hardhat.config.ts avec seulement solidity config
  • Sauvegarde de l'ancienne config : hardhat.config.old.ts
  • .nvmrc modifié avec Node.js 22.10.0
  • Fix non compatible script with ESM

⚠️ Blocages actuels

Plugins non compatibles (à migrer/remplacer)

  1. hardhat-deploy (^0.11.43)

    • Erreur : Package subpath './types/runtime' is not defined
    • Statut : Désactivé dans config
    • Action : Attendre version compatible Hardhat 3 ou trouver alternative
  2. hardhat-dependency-compiler (^1.2.1)

    • Erreur : Package subpath './builtin-tasks/task-names' is not defined
    • Statut : Désactivé dans config
    • Action : Attendre version compatible Hardhat 3
  3. @nomicfoundation/hardhat-toolbox (retiré)

    • Conflit de dépendances
    • Statut : Retiré du package.json
    • Action : Installer @nomicfoundation/hardhat-toolbox-mocha-ethers pour les tests (voir guide)
  4. solidity-docgen (^0.6.0-beta.36)

    • Erreur : ERR_REQUIRE_ESM
    • Statut : Désactivé dans config
    • Action : Tester une fois Node.js 22+ installé
  5. solidity-coverage (^0.8.14)

    • Statut : Non testé
    • Action : Vérifier compatibilité Hardhat 3

📋 À faire

Migration de la configuration (depuis hardhat.config.old.ts)

  • Migrer les réseaux (networks) avec type: 'http' ou type: 'edr-simulated'
  • Migrer les tasks personnalisées (abis, docgen, test)
  • Migrer namedAccounts (si supporté par hardhat-deploy v3)
  • Migrer etherscan et sourcify
  • Migrer typechain config
  • Migrer mocha config

Plugins et tests

  • Installer @nomicfoundation/hardhat-toolbox-mocha-ethers pour les tests
  • Migrer les fichiers de test vers ESM
  • Adapter les scripts de déploiement (deploy/) pour fonctionner sans hardhat-deploy ou avec alternative
  • Tester solidity-coverage compatibilité
  • Réactiver solidity-docgen une fois compatible

Dépendances externes

  • Réactiver hardhat-dependency-compiler quand compatible
  • Réactiver hardhat-deploy quand compatible
  • Vérifier compatibilité de @mudgen/diamond-1 avec Hardhat 3

…0.10, add old config file for reference, and update Node version in .nvmrc
Copilot AI review requested due to automatic review settings October 31, 2025 16:40
@Le-Caignec Le-Caignec self-assigned this Oct 31, 2025
Copy link
Contributor

Copilot AI left a 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]}`) {
Copy link

Copilot AI Oct 31, 2025

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.

Copilot uses AI. Check for mistakes.
},
},
};
import type { HardhatUserConfig } from 'hardhat/config';
Copy link

Copilot AI Oct 31, 2025

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.

Copilot uses AI. Check for mistakes.
…endency compiler and solidity docgen, and add new ABI exporter settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant