webpack-dev-server icon indicating copy to clipboard operation
webpack-dev-server copied to clipboard

Sockjs live reloading migration from v3 to v4 unclear

Open WisaniShilumani opened this issue 3 years ago • 6 comments

Documentation Is:

  • [x] Missing

Please Explain in Detail...

Webpack-dev-server config options migration from v3 to v4 is not clear with regards to changes to websocket options; particularly when using sockjs protocol, given the new defaulting to the ws protocol.

When the sockjs protocol is provided in options, the SockJS server is bound to the '/ws' path.

This is fixed by adding the webSocketServer options as such:

webSocketServer: {
  type: 'sockjs',
  options: {
    path: '/sockjs-node'
  }
}

Your Proposal for Changes

This should be communicated in docs, or the defaultWebSocketServerOptions in lib/Server.js [line 1517] currently: const defaultWebSocketServerOptions = { path: '/ws' }

should have the path be equal to client.webSocketURL or client.webSocketURL.pathname

WisaniShilumani avatar Apr 11 '22 09:04 WisaniShilumani

Socksjs supports ws and versa vice too, it was replaced in runtime based on supporting

alexander-akait avatar Apr 11 '22 10:04 alexander-akait

Thanks @alexander-akait, does this need to be documented here https://webpack.js.org/configuration/dev-server/#websocketurl so that the developer knows that the path needs to either be '/ws', or they must set it under webSocketServer.options.path?

WisaniShilumani avatar Apr 11 '22 15:04 WisaniShilumani

Based on your configuration, if you have before non default options, you need to update, but if you don't change it, you can don't touch it and all will work

alexander-akait avatar Apr 11 '22 15:04 alexander-akait

Alright, if it doesn't warrant a docs update, happy if we close the issue!

WisaniShilumani avatar Apr 11 '22 15:04 WisaniShilumani

@WisaniShilumani We can improve docs, so feel free to send a PR, any docs updates are good for developers

alexander-akait avatar Apr 11 '22 15:04 alexander-akait

Thanks @alexander-akait I will open a PR shortly!

WisaniShilumani avatar Apr 11 '22 16:04 WisaniShilumani

Closing due to inactivity. Anyway feel free to send a PR. Thanks!

alexander-akait avatar Feb 08 '24 13:02 alexander-akait