Skip to content

now works browserify, considering publishing to npm #76

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 5 commits into from
Closed

now works browserify, considering publishing to npm #76

wants to merge 5 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jun 21, 2012

These patches detect the presence of module.exports and assign accordingly. I saw there was already a shim for AMD define() so I put this patch right next to it.

I also added a check to see if this === window in the constructor so that the new is optional in front of SockJS. Plus I added a var in front of the SockJS = so that the SockJS reference won't leak out when the whole module is wrapped in a closure, like browserify does. In the main window context doing var assigns onto window anyways so this change shouldn't have any impact.

I put some things in the .npmignore that would likely be troublesome in publishing to npm and added a "main" field, so this package should be suitable for an npm publish! Just adjust the version field.

When this package hits npm in browserify people will just be able to require('sockjs-client') which is much handier

@majek
Copy link
Member

majek commented Jun 22, 2012

The patch looks good. But I don't really get the rationale. SockJS-client only works in browser context, right? Can you explain would I like to do 'require' on it?

@ghost
Copy link
Author

ghost commented Jun 22, 2012

Module systems like browserify let you do require() in the browser: http://github.com/substack/node-browserify

@majek
Copy link
Member

majek commented Jun 26, 2012

Merged as 45417a1 to dev branch. Thanks!

@majek majek closed this Jun 26, 2012
@majek
Copy link
Member

majek commented Jun 26, 2012

I guess I should push sockjs-client to npm now, right?

@husio-org
Copy link

I am trying to bundle this package with browserify. Looks like this patch never made it to master, or did it?

browserify is a great package manager and also allows to share modules between client and server. we find it very useful.

Also looked into bower with no luck.

@yocontra
Copy link

Did this ever happen? This version of sockjs-client doesn't seem to be available on npm

@Fauntleroy
Copy link

Any chance this will be resolved? I'd like to use Sockjs with browserify and this is a blocker.

@stephenhandley
Copy link

+1

@gabegorelick
Copy link

+1 https://www.npmjs.org/package/sockjs-client appears to be a Node client, not a browser client

@amasad
Copy link

amasad commented May 26, 2014

why did this never make it in?

@brycekahle
Copy link
Contributor

I will get this published soonish. I think there is some confusion around this and the node SockJS client. Ideally there wouldn't be two clients, but that might take more time. Ideas on how to clarify until then?

@brycekahle brycekahle reopened this May 26, 2014
@amasad
Copy link

amasad commented May 26, 2014

maybe in the name? sockjs-node-client and/or sockjs-browser-client

@yocontra
Copy link

Why is there a difference?

@amasad
Copy link

amasad commented May 26, 2014

I'm guessing because on node it simply uses node's http library, but in the browser the transports are WebSocket, xhr, iframe, all the other fallbacks etc. And they don't want to ship node code to browsers or browser code to node. Just guessing

@yocontra
Copy link

IMO sockjs should take the same approach engine.io takes with this problem - one library but skip the upgrade chain and go straight to websockets on node

@3rd-Eden
Copy link

yes, because building the exact same library makes sense right ;-)?

@piranna
Copy link

piranna commented Jun 25, 2014

The usage of the http module on browser is perfectly acceptable. It's logical that there would be only one client package, both fro Node.js and browsers.

@brycekahle
Copy link
Contributor

1.0 will have the same client for node and browsers published to npm as sockjs-client.

@brycekahle brycekahle closed this Oct 20, 2014
@brycekahle
Copy link
Contributor

Heads up that 1.0.0-beta.4 has been published to npm, and all future versions will be too.

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

Successfully merging this pull request may close these issues.

10 participants