project-serum / sol-wallet-adapter

Other
185 stars 92 forks source link

`esbuild` is not working out of the box. #28

Closed nonken closed 3 years ago

nonken commented 3 years ago

I have a simple client.js

import Wallet from '@project-serum/sol-wallet-adapter';

And create a bundle using

esbuild ./client.js --bundle --outfile=./build/js/client.js

When including the bundled file on a simple page I am getting a bunch of bundling issues and can not use the output bundle.

Uncaught ReferenceError: process is not defined
nonken commented 3 years ago

The issue is in the secp256k1 dependency which uses elliptic in the browser. When requiring elliptic directly in https://github.com/solana-labs/solana-web3.js/blob/171c73ee938c2bd12f0a0785e52d076c3f58649d/src/secp256k1-program.ts#L3 the build passes and I can connect to the wallet.

nonken commented 3 years ago

I have opened a new issue here https://github.com/solana-labs/solana-web3.js/issues/1025