Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show deprecation warning for both https and http2 #4069

Merged
merged 1 commit into from Dec 2, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/Server.js
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
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