Consider using ethers sub-packages to reduce bundle sizes
Hi! Optimism is in the process of trying to reduce bundle sizes for down-stream users of our contract packages. TypeChain currently imports ethers in its entirety into typing files but could instead import specific sub-packages. For example, contract type files import the following:
import type { Listener } from "@ethersproject/providers";
import type { Event, EventFilter } from "ethers";
This can be replaced with
import type { Listener } from "@ethersproject/providers";
import type { Event, EventFilter } from "@ethersproject/contracts";
+1, I've run into issues with bundle size and conflicting ethers packages. This would at least prevent the number of packages that need to be cross-installed.
+1 this would be a nice improvement to remove "ethers" dependency
Few things that may help with reducing bundle sizes further:
- Each bytecode can be around 10kb to 24kb. If there are a lot of them, it can add up. Currently, if contract instances are created through
ERC20__factory.connect(address, provider), it also touches the bytecode hence bundler has to include it. This might need a simpleERC20__contractwhich only touches abi. - We can explore using human-readable ABI since it's more compact than minified JSON fragments.