From 0d23323959455bd35ae0b1b7352e493953e675cc Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 2 Nov 2021 18:19:14 -0700 Subject: [PATCH 1/2] fix: show deprecation warning for `https`/`http2` option --- lib/Server.js | 10 ++++++++++ test/e2e/http2.test.js | 8 ++++++++ test/e2e/https.test.js | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/lib/Server.js b/lib/Server.js index b74614ea15..45ac4e46bc 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -523,6 +523,16 @@ class Server { const isHTTPs = Boolean(options.https); const isSPDY = Boolean(options.http2); + if (isHTTPs || isSPDY) { + util.deprecate( + () => {}, + `'${ + isHTTPs ? "https" : "http2" + }' option is deprecated. Please use the 'server' option.`, + `DEP_WEBPACK_DEV_SERVER_${isHTTPs ? "HTTPS" : "HTTP2"}` + )(); + } + options.server = { type: // eslint-disable-next-line no-nested-ternary diff --git a/test/e2e/http2.test.js b/test/e2e/http2.test.js index dd57c62755..e5dffc005b 100644 --- a/test/e2e/http2.test.js +++ b/test/e2e/http2.test.js @@ -2,6 +2,7 @@ const path = require("path"); const http2 = require("http2"); +const util = require("util"); const webpack = require("webpack"); const Server = require("../../lib/Server"); const config = require("../fixtures/static-config/webpack.config"); @@ -92,10 +93,13 @@ describe("http2 option", () => { let browser; let pageErrors; let consoleMessages; + let utilSpy; beforeEach(async () => { compiler = webpack(config); + utilSpy = jest.spyOn(util, "deprecate"); + server = new Server( { static: staticDirectory, @@ -135,6 +139,10 @@ describe("http2 option", () => { () => performance.getEntries()[0].nextHopProtocol ); + expect(utilSpy.mock.calls[0][1]).toBe( + "'http2' option is deprecated. Please use the 'server' option." + ); + expect(HTTPVersion).toMatchSnapshot("HTTP version"); expect(response.status()).toMatchSnapshot("response status"); diff --git a/test/e2e/https.test.js b/test/e2e/https.test.js index b6e384e13a..23b4e0a146 100644 --- a/test/e2e/https.test.js +++ b/test/e2e/https.test.js @@ -2,6 +2,7 @@ const https = require("https"); const path = require("path"); +const util = require("util"); const fs = require("graceful-fs"); const request = require("supertest"); const webpack = require("webpack"); @@ -30,10 +31,13 @@ describe("https option", () => { let browser; let pageErrors; let consoleMessages; + let utilSpy; beforeEach(async () => { compiler = webpack(config); + utilSpy = jest.spyOn(util, "deprecate"); + server = new Server( { static: { @@ -72,6 +76,10 @@ describe("https option", () => { waitUntil: "networkidle0", }); + expect(utilSpy.mock.calls[0][1]).toBe( + "'https' option is deprecated. Please use the 'server' option." + ); + expect(response.status()).toMatchSnapshot("response status"); expect(await response.text()).toMatchSnapshot("response text"); From 6b7e78efeeb91f71fffef3c8a379993be1cb6912 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 3 Nov 2021 03:41:35 -0700 Subject: [PATCH 2/2] chore: add TODO --- lib/Server.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Server.js b/lib/Server.js index 45ac4e46bc..c767a06e72 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -524,6 +524,7 @@ class Server { const isSPDY = Boolean(options.http2); if (isHTTPs || isSPDY) { + // TODO: remove in the next major release util.deprecate( () => {}, `'${