Skip to content

Commit 7cd333b

Browse files
committed
fix: show deprecation warning for incorrect usage of Node.js API
1 parent fe8dda7 commit 7cd333b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/Server.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ class Server {
2020
// TODO: remove this after plugin support is published
2121
if (options.hooks) {
2222
[options, compiler] = [compiler, options];
23+
24+
this.compiler = compiler;
25+
this.logger = this.compiler.getInfrastructureLogger("webpack-dev-server");
26+
27+
this.logger.warn(
28+
"Using 'compiler' as the first argument is deprecated. Please use 'options' as first argument and 'compiler' as second argument."
29+
);
2330
}
2431

2532
validate(schema, options, "webpack Dev Server");
@@ -29,7 +36,10 @@ class Server {
2936
// Keep track of websocket proxies for external websocket upgrade.
3037
this.webSocketProxies = [];
3138

32-
this.compiler = compiler;
39+
if (typeof this.compiler === "undefined") {
40+
this.compiler = compiler;
41+
this.logger = this.compiler.getInfrastructureLogger("webpack-dev-server");
42+
}
3343
}
3444

3545
static get DEFAULT_STATS() {
@@ -1378,7 +1388,6 @@ class Server {
13781388
}
13791389

13801390
listen(port, hostname, fn) {
1381-
this.logger = this.compiler.getInfrastructureLogger("webpack-dev-server");
13821391
this.normalizeOptions(this.options);
13831392

13841393
if (typeof port === "function") {

0 commit comments

Comments
 (0)