-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Check existing issues
- I checked there isn't already an issue for the bug I encountered.
Describe the bug
Problem
Currently, the wagmi CLI generates all artifacts into a single file, including:
- Contract ABIs
- Contract addresses
- React hooks
- Other generated helpers
This creates an issue when consuming only a subset of the generated output in a different environment.
For example, when importing only the ABI into a non-React project or a separate repository, the entire file is imported, including React hooks and related code that are not needed. This introduces unnecessary dependencies, reduces clarity, and makes cross-environment usage less ergonomic.
In short: I only want the ABI, but I end up importing a whole React toolbox along with it.
Why this is problematic
- Makes it harder to reuse ABIs in backend, Node, or non-React contexts
- Introduces unwanted React-specific code in unrelated repositories
- Reduces tree-shaking clarity
- Couples UI layer artifacts with protocol layer artifacts
Proposed Improvement
The wagmi CLI could support generating separate outputs by concern. For example:
abi.tsexports ABIs onlyaddresses.tsexports contract addresses onlyreact.tsexports React hooks- optionally
actions.tsexports core viem actions
Or allow configuration like:
- Generate separate files by default
- Or provide an option to control outputs, for example:
{
"out": {
"abi": "src/generated/abi.ts",
"react": "src/generated/react.ts",
"addresses": "src/generated/addresses.ts"
}
}Happy to help think through the DX implications or contribute if this direction makes sense.
Link to Minimal Reproducible Example
No response
Steps To Reproduce
No response
What Wagmi package(s) are you using?
@wagmi/cli
Wagmi Package(s) Version(s)
2.8.0
Viem Version
2.45.3
TypeScript Version
No response
Anything else?
No response