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

possibility to leave out buffer for browserify build? #7

Open
gr2m opened this issue Jun 10, 2015 · 2 comments
Open

possibility to leave out buffer for browserify build? #7

gr2m opened this issue Jun 10, 2015 · 2 comments

Comments

@gr2m
Copy link

gr2m commented Jun 10, 2015

I've a little lib that is a wrapper of a REST API, and we use it both in browser and node.
When I build it with browserify, ~90% of the code is Buffer. Can I somehow leave it out of the build, and do the encoding: undefined thing, at least for browser usage?

@mattdesl
Copy link

I really like nets but had the same problem -- the vast majority of my bundle was just Buffer, which was never even getting used.

If this is intended to be browser-first, it could act a bit more like xhr by defaulting to a string response and using ArrayBuffer instead of Buffer (in both node + browser). But there are some problems that might come from that... maybe it's better to just keep it as a separate module?

Also, there are some alternatives here which might be good (axios and superagent are both small)

https://github.com/zeke/npm-collection-http-clients

@nichoth
Copy link

nichoth commented Jun 9, 2016

+1

Use the package.json browser field & refactor the require statements so that only xhr is included in browserify bundles.


On the other hand, the user can just do

browserify --exclude buffer code.js > bundle.js

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

3 participants