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

Make ethereum.js browserify compatible #114

@dchambers

Description

@dchambers

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:

  1. If you don't set process.env.NODE_ENV = 'debug' you end up with a Node.js version of XHR.
  2. 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:

  1. envify & unreachable-branch-transform should be dropped.
  2. The browser field should be used to cause the native XHR package to be loaded when using browserify.
  3. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions