anza-xyz / wallet-adapter

Modular TypeScript wallet adapters and components for Solana applications.
https://anza-xyz.github.io/wallet-adapter/
Apache License 2.0
1.53k stars 938 forks source link

Wallet Adapter For Solana Example doesn't work out of the box with create-react-app #843

Open CrossedCarpet opened 10 months ago

CrossedCarpet commented 10 months ago

Describe the bug Adding Wallet Adapter for Solana in a project created with create-react-app introduces 6 errors related to missing modules. Example message:

ERROR in ./node_modules/micro-ftch/index.js 59:15-30
Module not found: Error: Can't resolve 'zlib' in '.../node_modules/micro-ftch'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
    - add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
    - install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "zlib": false }

To Reproduce Steps to reproduce the behavior:

$ npx create-react-app walletadapter --template typescript
$ cd walletadapter
$ npm i @solana/wallet-adapter-react @solana/wallet-adapter-base @solana/wallet-adapter-wallets @solana/wallet-adapter-react-ui @solana/wallet-adapter-react-ui
$ npm run start

Desktop (please complete the following information):

CrossedCarpet commented 10 months ago

Related issue and workaround: https://solana.stackexchange.com/questions/1850/webpack-5-polyfill-problem-when-using-solana-wallet-adapter-on-react18-2-0

CrossedCarpet commented 10 months ago

This is also documented in: https://www.npmjs.com/package/@project-serum/anchor

@project-serum/anchor depends on node.js native modules. Therefore, webpack 5 will not work with current version. You will either need to rollback to webpack 4, or use a polyfill for each missing dependency.

acoutts commented 9 months ago

Shouldn't the starer app be updated accordingly? I also arrived here today after cloning the starter app as a place to start, only to find it doesn't work.

Update: Seems to work if you use yarn instead of NPM, selecting the latest package versions.

gameuser1982 commented 4 months ago

@acoutts this starter app is even in worse shape now. I've been trying to get the create-react-app-starter to work for two weeks and still have compile errors because someone changed the function TransportRaceCondition to TransportPendingOperation. There is a fix here, except it doesn't work because like you I have to use Yarn otherwise the dependencies don't get installed: https://github.com/anza-xyz/wallet-adapter/pull/949

Is it just me or is this repo very poorly maintained?

keolamation commented 4 months ago

@acoutts this starter app is even in worse shape now. I've been trying to get the create-react-app-starter to work for two weeks and still have compile errors because someone changed the function TransportRaceCondition to TransportPendingOperation. There is a fix here, except it doesn't work because like you I have to use Yarn otherwise the dependencies don't get installed: #949

Is it just me or is this repo very poorly maintained?

nah it is poorly maintained. not sure how solana went up 30% th last 2 weeks. pretty sure the normies dont know how much of a scattered mess Solana documentation is. lol