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

index.mjs:151 Uncaught (in promise) TypeError: destr__WEBPACK_IMPORTED_MODULE_0__ is not a function #806

Open
HTR2747 opened this issue Jan 17, 2025 · 1 comment

Comments

@HTR2747
Copy link

HTR2747 commented Jan 17, 2025

// Facing this error "Uncaught (in promise) TypeError: destr__WEBPACK_IMPORTED_MODULE_0__ is not a function" on this EthereumProvider.init when I am adding this code in my existing application. If I create a new react template application it works fine!
// See my react hook component code usage

import { EthereumProvider } from '@walletconnect/ethereum-provider'

// 2. Initialize sign client
async function onInitializeProviderClient() {
const client = await EthereumProvider.init({
projectId: 'my-app-id',
showQrModal: true,
qrModalOptions: { themeMode: 'light' },
chains: [1],
methods: ['eth_sendTransaction', 'personal_sign'],
events: ['chainChanged', 'accountsChanged'],
metadata: {
name: 'My App',
description: 'My App Description',
url: 'https://my.app.com',
icons: ['https://my.app.com/logo.png'],
},
})
setProviderClient(client)
}

useEffect(() => {
    onInitializeProviderClient()
}, [])
// Function to handle connection
// 3. Enable / connect with provider, will open web3modal
async function onConnect() {
    if (providerClient) {
        await providerClient.connect()
    } else {
        throw new Error('providerClient is not initialized')
    }
}
@HTR2747
Copy link
Author

HTR2747 commented Jan 21, 2025

I fixed this issue.

  1. installed destr module by running yarn add destr
  2. My application based on react typescript instead vite so I added this alias in my webpack.congif.js file.
    resolve: { alias: { destr: require.resolve('../node_modules/destr/dist/index.mjs'), // Use ESM version explicitly }, },

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

1 participant