Repository navigation
Fix latest dependencies v2 - #8311
Conversation
🦋 Changeset detectedLatest commit: 5589cfa The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR addresses CI/workflow failures caused by mixing await import("viem") with CJS-style require-compiled imports under Node16 module resolution, which can select different package.json#exports conditions and effectively load divergent module shapes/versions. It standardizes viem loading to always use require(...) in the affected packages.
Changes:
- Replaced dynamic
await import("viem")usages withrequire("viem")(typed viaas typeof import("viem")) across hardhat-viem internals. - Replaced dynamic imports of
viemandviem/chainswithrequire(...)in chain detection logic. - Updated hardhat-ignition-viem helper to load
viemviarequire(...), and added changesets for both packages.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/hardhat-viem/src/internal/contracts.ts | Switches viem loading from dynamic import to require for contract address calculation and getContract usage. |
| packages/hardhat-viem/src/internal/clients.ts | Switches viem loading from dynamic import to require for client construction helpers. |
| packages/hardhat-viem/src/internal/chains.ts | Switches viem / viem/chains loading from dynamic import to require for chain extraction/selection. |
| packages/hardhat-viem/src/internal/bytecode.ts | Switches viem loading from dynamic import to require for hex validation in bytecode linking. |
| packages/hardhat-ignition-viem/src/viem-ignition-helper.ts | Switches viem loading from dynamic import to require when building a contract instance. |
| .changeset/sharp-ignition-viem-require.md | Adds a patch changeset for hardhat-ignition-viem documenting the import normalization. |
| .changeset/quick-viem-require.md | Adds a patch changeset for hardhat-viem documenting the import normalization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
The reason this workflow was failing was that we were using both top-level and
await importforviemin some packages, and with Node16 module resolution and CJS those behave differently.The top level ones get compiled to a require, so they use the
require/defaultcondition of thepackage.json#exports. Theawait importones use theimportone. These lead to two versions being exported.This PR normalizes it so that we always use
require.