torusresearch / solana-embed

Embeds the Solana Wallet directly in your application via solana-embed. Exposes a Web3 Provider.
https://demo-solana.tor.us
12 stars 6 forks source link

Bundling with esbuild fails because of `require('stream')` and `require('crypto')` #70

Open stijlist opened 2 years ago

stijlist commented 2 years ago

My apologies, accidentally hit enter in the middle of typing my comment.

I filed https://github.com/solana-labs/wallet-adapter/issues/584 against @solana/wallet-adapter - you can run esbuild index.tsx --bundle --sourcemap --outfile=src/assets/index.js on the gist I've included below and then run npm ls cipher-base and npm ls @toruslabs/eccrypto to see that Torus is the dependency causing the resolution errors.

https://gist.github.com/stijlist/174b3b3c8bc6e4d009826c8a13a7e661

metallicalfa2 commented 2 years ago

@ieow @guru-web3

chaitanyapotti commented 2 years ago

As a library, we don't polyfill the dependencies on the default esm, cjs builds. this is to prevent double polyfilling by webpack/rollup/esbuild incase you're using other deps which require polyfilling (which is often the case)

We also provide umd build which is polyfilled and can be used as a script tag in your application.

Here are some cases on how to polyfill: https://web3auth.io/docs/troubleshooting/webpack-issues