Skip to content

Commit 521cf85

Browse files
authored
feat: show deprecation warning for https/http2 option (#4003)
1 parent 19cc6a5 commit 521cf85

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

lib/Server.js

+11
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,17 @@ class Server {
523523
const isHTTPs = Boolean(options.https);
524524
const isSPDY = Boolean(options.http2);
525525

526+
if (isHTTPs || isSPDY) {
527+
// TODO: remove in the next major release
528+
util.deprecate(
529+
() => {},
530+
`'${
531+
isHTTPs ? "https" : "http2"
532+
}' option is deprecated. Please use the 'server' option.`,
533+
`DEP_WEBPACK_DEV_SERVER_${isHTTPs ? "HTTPS" : "HTTP2"}`
534+
)();
535+
}
536+
526537
options.server = {
527538
type:
528539
// eslint-disable-next-line no-nested-ternary

test/e2e/http2.test.js

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const path = require("path");
44
const http2 = require("http2");
5+
const util = require("util");
56
const webpack = require("webpack");
67
const Server = require("../../lib/Server");
78
const config = require("../fixtures/static-config/webpack.config");
@@ -92,10 +93,13 @@ describe("http2 option", () => {
9293
let browser;
9394
let pageErrors;
9495
let consoleMessages;
96+
let utilSpy;
9597

9698
beforeEach(async () => {
9799
compiler = webpack(config);
98100

101+
utilSpy = jest.spyOn(util, "deprecate");
102+
99103
server = new Server(
100104
{
101105
static: staticDirectory,
@@ -135,6 +139,10 @@ describe("http2 option", () => {
135139
() => performance.getEntries()[0].nextHopProtocol
136140
);
137141

142+
expect(utilSpy.mock.calls[0][1]).toBe(
143+
"'http2' option is deprecated. Please use the 'server' option."
144+
);
145+
138146
expect(HTTPVersion).toMatchSnapshot("HTTP version");
139147

140148
expect(response.status()).toMatchSnapshot("response status");

test/e2e/https.test.js

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const https = require("https");
44
const path = require("path");
5+
const util = require("util");
56
const fs = require("graceful-fs");
67
const request = require("supertest");
78
const webpack = require("webpack");
@@ -30,10 +31,13 @@ describe("https option", () => {
3031
let browser;
3132
let pageErrors;
3233
let consoleMessages;
34+
let utilSpy;
3335

3436
beforeEach(async () => {
3537
compiler = webpack(config);
3638

39+
utilSpy = jest.spyOn(util, "deprecate");
40+
3741
server = new Server(
3842
{
3943
static: {
@@ -72,6 +76,10 @@ describe("https option", () => {
7276
waitUntil: "networkidle0",
7377
});
7478

79+
expect(utilSpy.mock.calls[0][1]).toBe(
80+
"'https' option is deprecated. Please use the 'server' option."
81+
);
82+
7583
expect(response.status()).toMatchSnapshot("response status");
7684

7785
expect(await response.text()).toMatchSnapshot("response text");

0 commit comments

Comments
 (0)