WalletConnect / web3modal

A single Web3 provider solution for all Wallets
https://web3modal.com
Apache License 2.0
4.69k stars 1.3k forks source link

[bug] Does Web3Modal v3 have to rely on React? #1322

Closed hhun closed 8 months ago

hhun commented 8 months ago

Link to minimal reproducible example

https://docs.walletconnect.com/2.0/web3modal/v3/vue/about https://docs.walletconnect.com/2.0/web3modal/v3/html/about

Summary

When Vue does not use react, an error will be reported when running Web3Modal v3.0.0 Could not resolve "react" Vue不使用React时,运行Web3Modal v3.0.0 会报错 Could not resolve "react"

When html runs Web3Modal v3.0.0, an error message Could not resolve "react" html 运行 Web3Modal v3.0.0 会报错 Could not resolve "react"

Does Web3Modal v3 have to rely on React? Web3Modal v3必须依赖React吗?

List of related npm package versions

{
    "name": "Web3Modal-V3",
    "private": true,
    "version": "0.0.0",
    "type": "module",
    "scripts": {
        "dev": "vite",
        "build": "vite build",
        "preview": "vite preview"
    },
    "dependencies": {
        "vue": "^3.3.4",
        "@wagmi/core": "^1.4.1",
        "@web3modal/wagmi": "3.0.0-alpha.6",
        "viem": "^1.10.8"
    },
    "devDependencies": {
        "@vitejs/plugin-vue": "^4.2.3",
        "vite": "^4.4.5"
    }
}
xzilja commented 8 months ago

No, might be missing an optional peerDependency config here, will have a look 👍

hhun commented 8 months ago

No, might be missing an optional peerDependency config here, will have a look 👍

How to setup peerDependency ? 请问 peerDependency 要怎么设置?

xzilja commented 8 months ago

This is something we will address on our end for next alpha release, you shouldn't need to do anything extra once it is fixed 👍

xzilja commented 8 months ago

Should be fixed in alpha.8, let me know if you are still seeing this issue (make sure to install dependencies fresh)

hhun commented 8 months ago
{
    "name": "Web3Modal-V3",
    "private": true,
    "version": "1.0.0",
    "type": "module",
    "scripts": {
        "dev": "vite",
        "build": "vite build",
        "preview": "vite preview"
    },
    "dependencies": {
        "vue": "^3.3.4",
        "@wagmi/core": "^1.4.1",
        "@web3modal/wagmi": "3.0.0-alpha.8",
        "viem": "^1.10.8"
    },
    "devDependencies": {
        "@vitejs/plugin-vue": "^4.2.3",
        "vite": "^4.4.5"
    }
}

Using 3.0.0-alpha.8 will still report an error Could not resolve "react" 使用 3.0.0-alpha.8 依然会报错 Could not resolve "react"

请问要怎么解决这个问题? Please tell me how to solve this problem?

.

warning "@wagmi/core > abitype@0.8.7" has unmet peer dependency "typescript@>=5.0.4". warning "@wagmi/core > zustand > use-sync-external-store@1.2.0" has unmet peer dependency "react@^16.8.0 || ^17.0.0 || ^18.0.0".

xzilja commented 8 months ago

@hhun could you create a sandbox with minimal reproduction where this error can be investigated please

xzilja commented 8 months ago

I've released alpha.9 with an updated import for one of the dependencies that could've needed react. Can you please try it out. Here is simple vue project where I was able to run it with no issues (make sure to add your project id in App.vue):

https://stackblitz.com/edit/vitejs-vite-jekevf?file=src%2FApp.vue

hhun commented 8 months ago

I've released alpha.9 with an updated import for one of the dependencies that could've needed react. Can you please try it out. Here is simple vue project where I was able to run it with no issues (make sure to add your project id in App.vue):

https://stackblitz.com/edit/vitejs-vite-jekevf?file=src%2FApp.vue

After using npm install to initialize the project, using yarn dev will not report an error After using yarn install to initialize the project, using yarn dev will report an error

I don’t know if it’s because yarn is not compatible with peerDependencies

xzilja commented 8 months ago

It most probably is, especially if you are not using latest yarn.

hhun commented 8 months ago

It most probably is, especially if you are not using latest yarn.

I'm using v1.22.19, is the latest version

xzilja commented 8 months ago

I believe yarn v1 is no longer maintained? They are on versin 3 or 4 now probably on their new packages.

vitusha-rat commented 8 months ago

I'm using yarn v3 and face same problems

glitch-txs commented 8 months ago

Hi @vitusha-rat , could you try adding this to the package.json file?

"optionalDependencies": {
    "react": ">=17",
    "react-dom": ">=17"
  },
hhun commented 8 months ago

@vitusha-rat After adding optionalDependencies in package.json, it can run normally.

    "optionalDependencies": {
        "react": ">=17",
        "react-dom": ">=17",
        "typescript": ">=5.0.4"
    }
vitusha-rat commented 8 months ago

@hhun @glitch-txs Thanks! Works now:)

yucheng-Li commented 1 month ago

@xzilja It is not work for me in vue2, has any other method solve it?

glitch-txs commented 1 month ago

@yucheng-Li feel free to open a new issue stating your problem or a GitHub discussion, you can tag me there too, thanks!