Skip to content

Commit

Permalink
fix: show deprecation warning for incorrect usage of Node.js API
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Jul 23, 2021
1 parent fe8dda7 commit 7cd333b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class Server {
// TODO: remove this after plugin support is published
if (options.hooks) {
[options, compiler] = [compiler, options];

this.compiler = compiler;
this.logger = this.compiler.getInfrastructureLogger("webpack-dev-server");

this.logger.warn(
"Using 'compiler' as the first argument is deprecated. Please use 'options' as first argument and 'compiler' as second argument."
);
}

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

this.compiler = compiler;
if (typeof this.compiler === "undefined") {
this.compiler = compiler;
this.logger = this.compiler.getInfrastructureLogger("webpack-dev-server");
}
}

static get DEFAULT_STATS() {
Expand Down Expand Up @@ -1378,7 +1388,6 @@ class Server {
}

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

if (typeof port === "function") {
Expand Down

0 comments on commit 7cd333b

Please sign in to comment.