Skip to content

Commit a35a929

Browse files
authored
feat: update WebSocket communication conditions and multi-compiler fallback logic
1 parent bb72f16 commit a35a929

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

lib/Server.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,7 @@ class Server {
560560
* @returns {boolean} true when target is `web`, otherwise false
561561
*/
562562
static isWebTarget(compiler) {
563-
return (
564-
compiler.platform?.web || compiler.options.externalsPresets?.web || false
565-
);
563+
return compiler.platform?.web || false;
566564
}
567565

568566
/**
@@ -778,12 +776,7 @@ class Server {
778776
// Configuration with `web` preset
779777
const compilerWithWebPreset =
780778
/** @type {MultiCompiler} */
781-
(this.compiler).compilers.find(
782-
(config) =>
783-
config.options.externalsPresets?.web ||
784-
config.platform?.web ||
785-
false,
786-
);
779+
(this.compiler).compilers.find((config) => Server.isWebTarget(config));
787780

788781
if (compilerWithWebPreset) {
789782
return compilerWithWebPreset.options;

migration-v6.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ This document serves as a migration guide for `webpack-dev-server@6.0.0`.
3737
};
3838
```
3939

40-
- Now, webpack-dev-server adds WebSocket communication only when the `target` is set to a web-compatible environment or when `externalsPresets` includes `web`.
40+
- Now, webpack-dev-server adds WebSocket communication only when the `target` is set to a web-compatible environment. Previously, it also injected WebSocket communication if `resolve` contained a `conditionNames` entry with `browser` or if `externalsPresets.web` existed.
4141

42-
Previously, it also injected WebSocket communication if `resolve` contained a `conditionNames` entry with `browser`.
42+
- When retrieving the configuration in a multi-compiler setup, it will look for one that has a target compatible with a web environment. If it doesn’t find one, it will fall back to the first compiler found by webpack.
4343

4444
## Deprecations
4545

0 commit comments

Comments
 (0)