PatrickJS / angular-websocket

:arrow_upper_left: The missing Angular WebSocket module for connecting client applications to servers by @AngularClass
https://angularclass.github.io/angular-websocket
MIT License
1.22k stars 195 forks source link

Does not work with webpack #82

Closed Head closed 8 years ago

Head commented 8 years ago

When using webpack, the "Socket = ws.Client || ws.client || ws;" part get's executed and the socket don't work anymore in a browser.

TomNeyland commented 8 years ago

@gdi2290 It'd be fantastic if you could cut a new release so this fix is available via npm.

@Head

ghost commented 8 years ago

@gdi2290 is there anything we can do to help cut a release? This should just be a patch release (2.0.1)

PatrickJS commented 8 years ago

@willsoto-FD done

PatrickJS commented 8 years ago

if there's another issue ping me again

ghost commented 8 years ago

@gdi2290 just pulled from npm. Thanks for taking care of this so quick!

lionelB commented 8 years ago

Hello, I think I've the same problem, wich seems to be fix. Unfortunatly for me, I can't figure out how make it work. Webpack try to include the ws package and I get some error

WARNING in ./~/ws/lib/BufferUtil.js
Module not found: Error: Cannot resolve module 'bufferutil' in /Users/lionel/code/node_modules/ws/lib
 @ ./~/ws/lib/BufferUtil.js 10:19-40

WARNING in ./~/ws/lib/Validation.js
Module not found: Error: Cannot resolve module 'utf-8-validate' in /Users/lionel/code/node_modules/ws/lib
 @ ./~/ws/lib/Validation.js 10:19-44

ERROR in ./~/ws/lib/WebSocketServer.js
Module not found: Error: Cannot resolve module 'tls' in /Users/lionel/code/node_modules/ws/lib
 @ ./~/ws/lib/WebSocketServer.js 15:10-24

Have you done something special in your webpack config ?

mheppner commented 8 years ago

@lionelB, I solved this by following this webpack issue. I'm not that great with webpack, but I'm guessing this should be fixed somehow in angular-websocket.

lionelB commented 8 years ago

@mheppner oh thanks ! After digging into the problem, it seems taht the problem come from the UMD build that hoist the require definition which no more wrapped by a if statement. Also I not convinced that including ws for an angular 1.x app is a good idea.

Remco75 commented 8 years ago

I have the same issue as @lionelB . @lionelB did you find a solution?

lionelB commented 8 years ago

@Remco75 you can override/polyfilll some module using a node entry in your webpack config http://webpack.github.io/docs/configuration.html#node ws: empty should do the trick

Remco75 commented 8 years ago

thnx, will give it a try

tom-schoener commented 7 years ago

I used this workaround for Webpack 2:


module.exports = {
  module: {
    noParse: [/angular-websocket/],
  }
  // ... other config
}
PatrickJS commented 7 years ago

please use noParse

jacek-jaskolski commented 7 years ago

Using noParse was not a solution for me. If your client is in browser you can use my fork to resolve this issue. npm i jacek-jaskolski/angular-websocket --save