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

feat: show deprecation warning for https/http2 option #4003

Merged
merged 2 commits into from Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions lib/Server.js
Expand Up @@ -523,6 +523,16 @@ class Server {
const isHTTPs = Boolean(options.https);
const isSPDY = Boolean(options.http2);

if (isHTTPs || isSPDY) {
util.deprecate(
() => {},
`'${
isHTTPs ? "https" : "http2"
}' option is deprecated. Please use the 'server' option.`,
`DEP_WEBPACK_DEV_SERVER_${isHTTPs ? "HTTPS" : "HTTP2"}`
)();
}
snitin315 marked this conversation as resolved.
Show resolved Hide resolved

options.server = {
type:
// eslint-disable-next-line no-nested-ternary
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/http2.test.js
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
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