Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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