diff --git a/lib/Server.js b/lib/Server.js index 6c265154a9..6fb8f87396 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -170,13 +170,13 @@ class Server { } // eslint-disable-next-line class-methods-use-this - normalizeOptions() { + async normalizeOptions() { const { options } = this; if (!this.logger) { this.logger = this.compiler.getInfrastructureLogger("webpack-dev-server"); } - + const compilerOptions = this.getCompilerOptions(); // TODO remove `{}` after drop webpack v4 support const watchOptions = compilerOptions.watchOptions || {}; @@ -528,7 +528,7 @@ class Server { return level; }; - + if (typeof proxyOptions.logLevel === "undefined") { proxyOptions.logLevel = getLogLevelForProxy( compilerOptions.infrastructureLogging @@ -1581,28 +1581,6 @@ class Server { }); } - close(callback) { - if (this.webSocketServer) { - this.webSocketServer.implementation.close(); - } - - const prom = Promise.all( - this.staticWatchers.map((watcher) => watcher.close()) - ); - this.staticWatchers = []; - - if (this.server) { - this.server.kill(() => { - // watchers must be closed before closing middleware - prom.then(() => { - this.middleware.close(callback); - }); - }); - } else if (callback) { - callback(); - } - } - getStats(statsObj) { const stats = Server.DEFAULT_STATS; const compilerOptions = this.getCompilerOptions(); @@ -1942,66 +1920,6 @@ class Server { this.stop().then(() => callback(null), callback); } - // TODO remove in the next major release - listen(port, hostname, fn) { - util.deprecate( - () => {}, - "'listen' is deprecated. Please use async 'start' or 'startCallback' methods.", - "DEP_WEBPACK_DEV_SERVER_LISTEN" - )(); - - this.logger = this.compiler.getInfrastructureLogger("webpack-dev-server"); - - if (typeof port === "function") { - fn = port; - } - - if ( - typeof port !== "undefined" && - typeof this.options.port !== "undefined" && - port !== this.options.port - ) { - this.options.port = port; - - this.logger.warn( - 'The "port" specified in options is different from the port passed as an argument. Will be used from arguments.' - ); - } - - if (!this.options.port) { - this.options.port = port; - } - - if ( - typeof hostname !== "undefined" && - typeof this.options.host !== "undefined" && - hostname !== this.options.host - ) { - this.options.host = hostname; - - this.logger.warn( - 'The "host" specified in options is different from the host passed as an argument. Will be used from arguments.' - ); - } - - if (!this.options.host) { - this.options.host = hostname; - } - - return this.start() - .then(() => { - if (fn) { - fn.call(this.server); - } - }) - .catch((error) => { - // Nothing - if (fn) { - fn.call(this.server, error); - } - }); - } - // TODO remove in the next major release close(callback) { util.deprecate(