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
11 changes: 11 additions & 0 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,17 @@ class Server {
const isHTTPs = Boolean(options.https);
const isSPDY = Boolean(options.http2);

if (isHTTPs || isSPDY) {
// 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"}`
)();
}

options.server = {
type:
// eslint-disable-next-line no-nested-ternary
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/http2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/https.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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");
Expand Down