This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
fix: import EthereumProvider instead of default #382
Merged
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.
Description
I ran into this
Uncaught (in promise) TypeError: EthereumProvider.init is not a function at WalletConnectConnector.initProvider_fn
error when testing my React components with vitest, and I can saw multiple similar reports:The problem I found is how we use dynamic import in ESM like below https://github.com/wagmi-dev/references/blob/eeed52e2d0170324c53c145e54dc089761a414cb/packages/connectors/src/walletConnect.ts#L280-L284
Unfortunately,
init
is missing fromEthereumProvider
in this case.I've set up a small example here where you can check the
test.cjs
file https://stackblitz.com/edit/stackblitz-starters-4alfhc?file=index.mjs, no bundlers like esbuild or webpack messing around, so it seems it's how the import works, though I haven't yet found the standard to reference.Additional Information
Your ENS/address: