PatrickJS/angular-websocket

Does not work with webpack

Head opened this issue · 14 comments

Head commented

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

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

@Head

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

@willsoto-FD done

if there's another issue ping me again

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

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 ?

@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.

@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.

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

@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

thnx, will give it a try

I used this workaround for Webpack 2:

module.exports = {
  module: {
    noParse: [/angular-websocket/],
  }
  // ... other config
}

please use noParse

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