Open daramir opened 1 year ago
Hi, https://github.com/ethers-io/ethers.js/blob/main/lib.esm/providers/contracts.js file cannot export interface as it is not supported by js file, it is like type only export so won't be present in .js file. it may be some other config related issue.
The ContractRunner
is exported from the root. Maybe it's searching somewhere else?
The
ContractRunner
is exported from the root.
@ricmoo can you please to the code in this repo where that happens? i.e. the file you are referring to as "the root"?
I think this might be fixed by a47cad16a85f1ef8268542b3c6955c462a56a9d3, but haven't had the change to test and reproduce the issue on the latest version. Thinking of closing this issue, ideally with an answer of whether it's "completed" or "not planned". Will add to my backlog.
Ethers Version
6.2.0
Search Terms
esm, ContractRunner
Describe the Problem
Generating types using
typechain
(with--target=@typechain/ethers-v6
) works without issue and can integrate the generated types with Typescript files that useethers
(v6). However, when building the DApp (or runningvite dev
), the compiled site will fail, because theContractRunner
cannot be found.My surface level analysis tells me this could be due to the
esm
build exporting nothing to https://github.com/ethers-io/ethers.js/blob/main/lib.esm/providers/contracts.js, when in fact https://github.com/ethers-io/ethers.js/blob/main/src.ts/providers/contracts.ts is not empty. The commonjs build counterpart https://github.com/ethers-io/ethers.js/blob/main/lib.commonjs/providers/contracts.d.ts isn't empty either and exports the expected types/interface.The error is a bit more evident when ethers is excluded from dependency optimization in vite config (see code snippet), after which the error turns into the error labeled as "Error when dependency is not optimized". Following the breadcrumbs the built files "/node_modules/ethers/lib.esm/index.js?v=6358794d" and "/node_modules/ethers/lib.esm/providers/index.js?v=6358794d" do not export
ContractRunner
, possibly due to the findings aforementioned.Code Snippet
Contract ABI
No response
Errors
Error when dependency is not optimized: