Skip to content

allow browserify #1134

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

Closed
wants to merge 2 commits into from
Closed

allow browserify #1134

wants to merge 2 commits into from

Conversation

chpio
Copy link

@chpio chpio commented Jun 25, 2015

Hi,

you can bundle node packages with browserify. Unfortunately it only works with static requires. So i changed all require-all with static requires.

@sidorares
Copy link
Member

@t128 what is the point of browserifying node-mysql?

@chpio
Copy link
Author

chpio commented Jun 25, 2015

bundle it into one js file eg: browserify/browserify#1277 (comment)

this has a few advantages:

  • the app starts a lot faster (node needs to load only one file)
  • the app is a lot smaller (in my examle app ~50mb to ~1mb)
  • you can transfer it more easily to eg the server

@sidorares
Copy link
Member

ok, it might make sense with node-webkit, but why bundle there when you can use native require?

@sidorares
Copy link
Member

also see related #961

@sidorares
Copy link
Member

sorry, have not read your comment until the end. ~50mb to ~1mb seems like a lot, but I guess it's not because of one file but because you exclude unused files. This can be done via coverage-like instrumentation to mark files for exclusion before packaging

@chpio
Copy link
Author

chpio commented Jun 25, 2015

yeah, sorry, i changed the comment.

so, it will never happen, as only node.js is really supported?

ps: uglify halved the size to 400kb :)

@sidorares
Copy link
Member

I'm not completely against your PR, but forcing only static require is actually bad for performance: I often require conditionally features that not always used to make startup time better

@dougwilson
Copy link
Member

We would only even accept this PR if this library was usable in a browser, but as far as I know, you cannot use it in a browser because you cannot make raw sockets there.

Could you perhaps show/tell us how you are using this module in a web browser?

@sidorares
Copy link
Member

@dougwilson it's used in node-webkit and bundled for performance considerations, not because of lack of module system

Field: require('./Field'),
FieldPacket: require('./FieldPacket'),
HandshakeInitializationPacket: require('./HandshakeInitializationPacket'),
index: require('./index'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you requiring itself? You can remove this.

@dougwilson
Copy link
Member

Oh, gotcha. I left a couple line notes of two things that need to be fixed.

@chpio
Copy link
Author

chpio commented Jun 25, 2015

hmm, you'r right. i missed the [A-Z]

@dougwilson dougwilson self-assigned this Jun 26, 2015
@dougwilson
Copy link
Member

We can probably remove require-all from the list of dependencies now, no?

@chpio
Copy link
Author

chpio commented Jun 26, 2015

@sidorares
Copy link
Member

move it to devDependencies ?

@chpio
Copy link
Author

chpio commented Jun 26, 2015

dat error:

AssertionError: 'Fri Jun 26 2015 09:50:00 GMT+0000 (Coordinated Universal Time)' === 'Fri Jun 26 2015 09:49:00 GMT+0000 (Coordinated Universal Time)'

:(

@dougwilson
Copy link
Member

@t128 don't worry about that error :) We had a volunteer who would look into it at #1045 but still no resolution.

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

Successfully merging this pull request may close these issues.

3 participants