Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
wds-version:
- '4'
- '5'
- '6'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -71,6 +72,7 @@ jobs:
wds-version:
- '4'
- '5'
- '6'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ but you can set the [`overlay.sockIntegration`](docs/API.md#sockintegration) opt

The supported versions are as follows:

| Dependency | Version |
| ------------------------ | ----------------- |
| `webpack-dev-server` | `4.8.0`+ or `5.x` |
| `webpack-hot-middleware` | `2.x` |
| `webpack-plugin-serve` | `1.x` |
| Dependency | Version |
| ------------------------ | -------------------------- |
| `webpack-dev-server` | `4.8.0`+ or `5.x` or `6.x` |
| `webpack-hot-middleware` | `2.x` |
| `webpack-plugin-serve` | `1.x` |

## API

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"webpack-cli": "^7.0.3",
"webpack-dev-server": "^5.2.6",
"webpack-dev-server-v4": "npm:webpack-dev-server@^4.8.0",
"webpack-dev-server-v6": "npm:webpack-dev-server@^6.0.0",
"webpack-hot-middleware": "^2.26.1",
"webpack-plugin-serve": "^1.6.0",
"yn": "^4.0.0"
Expand All @@ -116,7 +117,7 @@
"sockjs-client": "^1.4.0",
"type-fest": ">=0.17.0 <6.0.0",
"webpack": "^5.0.0",
"webpack-dev-server": "^4.8.0 || 5.x",
"webpack-dev-server": "^4.8.0 || 5.x || 6.x",
"webpack-hot-middleware": "2.x",
"webpack-plugin-serve": "1.x"
},
Expand Down
9 changes: 5 additions & 4 deletions sockets/WDSSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
* @returns {void}
*/
function initWDSSocket(messageHandler) {
const { default: SockJSClient } = require('webpack-dev-server/client/clients/SockJSClient');
const { default: WebSocketClient } = require('webpack-dev-server/client/clients/WebSocketClient');
const { client } = require('webpack-dev-server/client/socket');

/** @type {WebSocket} */
let connection;
if (client instanceof SockJSClient) {
if (client.sock) {
// SockJSClient exposes the underlying socket via `.sock`.
// WDS 6.0.0 dropped SockJS support, so this branch is dead in WDS 6+.
connection = client.sock;
} else if (client instanceof WebSocketClient) {
} else if (client.client) {
// WebSocketClient exposes the underlying socket via `.client`.
connection = client.client;
} else {
throw new Error('Failed to determine WDS client type');
Expand Down
3 changes: 3 additions & 0 deletions test/helpers/sandbox/aliasWDSv6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const moduleAlias = require('module-alias');

moduleAlias.addAliases({ 'webpack-dev-server': 'webpack-dev-server-v6' });
1 change: 1 addition & 0 deletions test/helpers/sandbox/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ module.exports = {
alias: ${JSON.stringify(
{
...(WDS_VERSION === 4 && { 'webpack-dev-server': 'webpack-dev-server-v4' }),
...(WDS_VERSION === 6 && { 'webpack-dev-server': 'webpack-dev-server-v6' }),
},
null,
2
Expand Down
3 changes: 2 additions & 1 deletion test/helpers/sandbox/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ function spawnWebpackServe(port, dirs, options = {}) {

const NODE_OPTIONS = [
// This requires a script to alias `webpack-dev-server` -
// both v4 and v5 are installed,
// v4, v5 and v6 are all installed,
// so we have to ensure that they resolve to the correct variant.
WDS_VERSION === 4 && `--require "${require.resolve('./aliasWDSv4')}"`,
WDS_VERSION === 6 && `--require "${require.resolve('./aliasWDSv6')}"`,
]
.filter(Boolean)
.join(' ');
Expand Down
Loading
Loading