This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Description
ethereum.js doesn't support NPM users that use browserify to make their programs available in the browser. At present, if you attempt to use browserify on an app that requires ethereum.js than you will find that it includes a Node.js implementation of XHR, rather than the browser's native XHR.
ethereum.js seems to use process.env.NODE_ENV, envify & unreachable-branch-transform to support having different code paths in Node.js and the browser. This seems much clunkier than using the features built-in to browserify, but it's worse than that since:
- If you don't set
process.env.NODE_ENV = 'debug' you end up with a Node.js version of XHR.
- If you do set
process.env.NODE_ENV = 'debug' than the program errors because bignumber.js is purposely not loaded in that case (something to do with Meteor.js?).
IMO, a number of changes should be made:
- envify & unreachable-branch-transform should be dropped.
- The
browser field should be used to cause the native XHR package to be loaded when using browserify.
- bignumber.js should always be used, in both the browser and Node.js.
If you are happy in principle with these changes, then I'd be happy to raise a pull-request for this work?