web3.js-browser
An intent to bundle a standalone version of web3.js for browsers, because web3.js SHOULD have a 2.x minified version for dApp developers.
FYI: web3.js#2623.
tl;dr
- Download scripts in build/ directory, or
- Use it as a typical npm module, or
- Import from CDN services like jsDelivr.
It is recommended to pin this bundle to some specific version, because web3.js varies dramatically across versions. You may waste much time debugging on some inconsistencies like me if used naively.
Build
git submodule initgit submodule update # configure web3 cd web3.jsnpm installnpm run build # build web3 packages; we only need *.esm.js cd .. # build web3.js yarnnpm run build
Web3.js caveats
The author was not careful enough to mistake v2.0.0-alpha for v2.0.0-alpha.1. To reduce confusion, this project deserves its own semantics versioning. See the releases page for details.
Scrypt
This bundle current follows v2.0.0-alpha.1. Current implementation deprecates scrypt
dependency in higher versions of Node.js, likely because its lack of security. If you see the following message, it can be safely ignored.
WARNING in ./web3.js/packages/web3-eth-accounts/dist/web3-eth-accounts.esm.js
Module not found: Error: Can't resolve 'scrypt' in '/.../web3.js-browser/web3.js/packages/web3-eth-accounts/dist'
Please refer to this commit for details.