Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module exports { default, __esModule } #17

Closed
hazae41 opened this issue Jan 26, 2021 · 5 comments
Closed

Module exports { default, __esModule } #17

hazae41 opened this issue Jan 26, 2021 · 5 comments

Comments

@hazae41
Copy link

hazae41 commented Jan 26, 2021

When importing the default export from WalletConnect

import WalletConnect from "https://esm.sh/@walletconnect/web3-provider"

console.log(WalletConnect)

Which is a class in my editor

Capture

However, when deploying (aleph dev) I get the following object instead

Capture

@shadowtime2000
Copy link

I think this is kind of expected behaviour, has something to do with the conversion of CJS -> ES though I think this is based on the build system of WalletConnect instead of on ESM's side

@hazae41
Copy link
Author

hazae41 commented Jan 26, 2021

Thanks, any idea how I can reconcile my editor and the browser?

@hazae41
Copy link
Author

hazae41 commented Jan 26, 2021

I did this workaround

import WalletConnectModule from "https://cdn.esm.sh/v15/@walletconnect/web3-provider@1.3.4/esnext/web3-provider.js"
import WalletConnectProvider from "https://cdn.esm.sh/v15/@walletconnect/web3-provider@1.3.4/dist/cjs/index.d.ts"

const WalletConnect: typeof WalletConnectProvider = WalletConnectModule.default

@shadowtime2000
Copy link

Yup, it has to do with the fact that WalletConnect isn't shipping ES modules and instead they are using Webpack + TS to convert their ES source code into CJS which is published. This causes export default to be transformed to exports.default which isn't actually a proper conversion though. @hazae41 I'd recommend you open an issue on their repo.

@hazae41
Copy link
Author

hazae41 commented Jan 26, 2021

Okay thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants