ethereumjs/keythereum

browserifiable version

Closed this issue · 3 comments

https://github.com/ethereumjs/keythereum/blob/0.4.7/index.js#L8-L11

  • why NODE_JS defined as (typeof module !== "undefined") && process && !process.browser? not just process.browser?
  • instead var path = (NODE_JS) ? require("path") : null; will better resolve through browser field in package.json

Read a bit about this today and it seems there is not a consensus on the best way to detect Node.js vs browser environment. Apparently browserify and webpack are the edge cases that create complications. I thought this discussion was good -- conclusion was that the "right" way to do this is:

typeof process !== "undefined" && process.nextTick && !process.browser

nextTick is defined in process for browser

Well, process.nextTick is defined if you require('process'), but the browser does not normally have process.nextTick (or process) defined.