stuartpb / hashblot

A simple method for abstract hash visualization
https://hashblot.com
14 stars 3 forks source link

browserify: require('crypto') bloats bundle #6

Closed eins78 closed 9 years ago

eins78 commented 9 years ago

Since browserify only does static requires, the whole crypto module always ends up in the bundle (actually crypto-browserify since it's shimmed).

It would be really nice to be able to require just the actual hashblot lib.

stuartpb commented 9 years ago

That's a fair point- in practice, I don't think I'm even using the sha1-based convenience functions any more (IIRC all my implementations are either calling a vendored sha1 function and passing its results to the module's main functions, or calling arbitrary hash functions via crypto externally like images.hashblot.com).

I might make some kind of derived drop-in replacement of this module that extends it with the sha1 methods (and maybe incorporates any_sha1, for the non-browserify use cases), then reduce this to just the abstract path-from-hash functions.

stuartpb commented 9 years ago

Actually, I think I'll just cut that functionality altogether for 0.5 and include the two lines that define them as a note on backward-compatibility in the README.

eins78 commented 9 years ago

Btw: your code works fine as-is when ignoring the crypto module in the browserify config section of the package.json.

For me, this issue is solved. Here is the solution:

To use the library with browserify, require('any-sha') from npm and set up as in the examples. Then ignore the crypto module by putting this in the package.json:

{
  "browserify": {
    "ignore": [
      "crypto"
    ]
  }
}