Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate sha1 function/make it optional #7

Open
epoberezkin opened this issue Feb 24, 2014 · 10 comments
Open

Separate sha1 function/make it optional #7

epoberezkin opened this issue Feb 24, 2014 · 10 comments

Comments

@epoberezkin
Copy link

We use base32 in the browser with browserify. sha1 requires crypto which adds 5k+ lines to the bundle. Also, I don't think sha1 will work in the browser anyway...

In the fork I separated sha1 (milojs@9c7fe12), but I don't think it is a good solution, it will break code that uses it. Any better ideas?

@agnoster
Copy link
Owner

Perhaps we could simply have sha1 require crypto when it's needed, and memoize? Will browserify still pull in require statements in a function body or no?

@epoberezkin
Copy link
Author

It is in the function body already, but browserify simply bundles together everything that is required... Maybe the right thing is to have one index file which is the same as current that requires both encode/decode and sha1 (to keep all existing users happy) and add another file for the browser that will only require endode/decode. I can refactor like this and add something to readme about another version for the browser.

@agnoster
Copy link
Owner

Ironically, it should work fine in the browser without browserify - it’s actually browserify that makes it not work :-(

@epoberezkin
Copy link
Author

sha1 works in the browser?

@agnoster
Copy link
Owner

No, but I mean base32 loads and you can use all the other methods, right?

@epoberezkin
Copy link
Author

I can use it with browserify too (without sha1). It's just that id adds almost 6000 lines to the bundle... So my idea was to make a second file for the browser without sha1 without duplicating the code and without breaking existing api. I will show you.

@agnoster
Copy link
Owner

Right, but typically one uses browserify to take a module that doesn’t work in the browser and make it work, while this already works in the browser and only brings in a bunch of unnecessary code for you.

@epoberezkin
Copy link
Author

Maybe I simply have to load it separately in the browser. As it's used in the framework all dependencies of which are relatively small we had everything in one bundle... I'll think about it. Maybe we can just have an extra build step and concatenate base32 to the bundle rather than require it

@lbeschastny
Copy link

👍 same problem with webpack

@cyxou
Copy link

cyxou commented Apr 8, 2017

Solved Webpack build error with the

module: {
        noParse: [
            /base32/,
        ],
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants