Skip to content

Commit

Permalink
fix: show deprecation warning for both https and http2 (#4069)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Dec 2, 2021
1 parent d096b0e commit d8d5d71
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,14 +674,21 @@ class Server {
const isHTTPs = Boolean(options.https);
const isSPDY = Boolean(options.http2);

if (isHTTPs || isSPDY) {
if (isHTTPs) {
// TODO: remove in the next major release
util.deprecate(
() => {},
`'${
isHTTPs ? "https" : "http2"
}' option is deprecated. Please use the 'server' option.`,
`DEP_WEBPACK_DEV_SERVER_${isHTTPs ? "HTTPS" : "HTTP2"}`
"'https' option is deprecated. Please use the 'server' option.",
"DEP_WEBPACK_DEV_SERVER_HTTPS"
)();
}

if (isSPDY) {
// TODO: remove in the next major release
util.deprecate(
() => {},
"'http2' option is deprecated. Please use the 'server' option.",
"DEP_WEBPACK_DEV_SERVER_HTTP2"
)();
}

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/http2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ describe("http2 option", () => {
let page;
let browser;
let HTTPVersion;
let utilSpy;

beforeEach(async () => {
compiler = webpack(config);

utilSpy = jest.spyOn(util, "deprecate");

server = new Server(
{
static: staticDirectory,
Expand All @@ -49,6 +52,7 @@ describe("http2 option", () => {
});

afterEach(async () => {
utilSpy.mockRestore();
await browser.close();
await server.stop();
});
Expand Down Expand Up @@ -82,6 +86,15 @@ describe("http2 option", () => {

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

// should show deprecated warning for both `https` and `http2`
expect(utilSpy.mock.calls[0][1]).toBe(
"'https' option is deprecated. Please use the 'server' option."
);

expect(utilSpy.mock.calls[1][1]).toBe(
"'http2' option is deprecated. Please use the 'server' option."
);

http2Req.end();
});
});
Expand Down Expand Up @@ -118,6 +131,7 @@ describe("http2 option", () => {
});

afterEach(async () => {
utilSpy.mockRestore();
await browser.close();
await server.stop();
});
Expand Down

0 comments on commit d8d5d71

Please sign in to comment.