Skip to content

Commit d8d5d71

Browse files
authored
fix: show deprecation warning for both https and http2 (#4069)
1 parent d096b0e commit d8d5d71

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

lib/Server.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -674,14 +674,21 @@ class Server {
674674
const isHTTPs = Boolean(options.https);
675675
const isSPDY = Boolean(options.http2);
676676

677-
if (isHTTPs || isSPDY) {
677+
if (isHTTPs) {
678678
// TODO: remove in the next major release
679679
util.deprecate(
680680
() => {},
681-
`'${
682-
isHTTPs ? "https" : "http2"
683-
}' option is deprecated. Please use the 'server' option.`,
684-
`DEP_WEBPACK_DEV_SERVER_${isHTTPs ? "HTTPS" : "HTTP2"}`
681+
"'https' option is deprecated. Please use the 'server' option.",
682+
"DEP_WEBPACK_DEV_SERVER_HTTPS"
683+
)();
684+
}
685+
686+
if (isSPDY) {
687+
// TODO: remove in the next major release
688+
util.deprecate(
689+
() => {},
690+
"'http2' option is deprecated. Please use the 'server' option.",
691+
"DEP_WEBPACK_DEV_SERVER_HTTP2"
685692
)();
686693
}
687694

test/e2e/http2.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ describe("http2 option", () => {
2121
let page;
2222
let browser;
2323
let HTTPVersion;
24+
let utilSpy;
2425

2526
beforeEach(async () => {
2627
compiler = webpack(config);
2728

29+
utilSpy = jest.spyOn(util, "deprecate");
30+
2831
server = new Server(
2932
{
3033
static: staticDirectory,
@@ -49,6 +52,7 @@ describe("http2 option", () => {
4952
});
5053

5154
afterEach(async () => {
55+
utilSpy.mockRestore();
5256
await browser.close();
5357
await server.stop();
5458
});
@@ -82,6 +86,15 @@ describe("http2 option", () => {
8286

8387
expect(HTTPVersion).toEqual("h2");
8488

89+
// should show deprecated warning for both `https` and `http2`
90+
expect(utilSpy.mock.calls[0][1]).toBe(
91+
"'https' option is deprecated. Please use the 'server' option."
92+
);
93+
94+
expect(utilSpy.mock.calls[1][1]).toBe(
95+
"'http2' option is deprecated. Please use the 'server' option."
96+
);
97+
8598
http2Req.end();
8699
});
87100
});
@@ -118,6 +131,7 @@ describe("http2 option", () => {
118131
});
119132

120133
afterEach(async () => {
134+
utilSpy.mockRestore();
121135
await browser.close();
122136
await server.stop();
123137
});

0 commit comments

Comments
 (0)