Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Followed this migration guide by Hardhat to try leverage the experimental support for ESM typescript hardhat projects using
hardhat-deploy
plugin.hardhat
to v2.19.4 that has required ESM support for TS projectspackage.json
andtsconfig.json
according to the guide with some extras forts-config
hardhat.config
(and any related setup utils) must remain CJS but tests and scripts could be either CJS or ESMNODE_OPTIONS='--loader ts-node/esm/transpile-only --no-warnings=ExperimentalWarning'
but at least when using mocha directly (via .'mocharc') or the wrapper script you can hide this verbosity and apply type checking conditionally based onHARDHAT_TYPECHECK
env varI monkey-patched
hardhat-deploy
so it can support loading of CJS modules as it previously did using 'require' or when consuming project is configured to use expermiental ESM support - it can load either CJS/ESM scripts using dynamic import (withg some workaround to mitigate default exports). All use-cases work!I looked into creating a PR in
hardhat-deploy
repo but had some issues since AFAIK hardhat and its plugins themselves currently must remain CJS. Here's the patched loading raw JS: