From 4831f58a75d12f75f4d5e5064ff3245f1a3770ba Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 23 Aug 2021 18:21:27 +0530 Subject: [PATCH] feat: added `magicHtml` option (#3717) --- README.md | 2 + bin/cli-flags.js | 13 ++ lib/Server.js | 7 +- lib/options.json | 8 + .../validate-options.test.js.snap.webpack4 | 7 + .../validate-options.test.js.snap.webpack5 | 7 + .../__snapshots__/basic.test.js.snap.webpack4 | 2 + .../__snapshots__/basic.test.js.snap.webpack5 | 2 + test/cli/magicHtml-option.test.js | 18 ++ .../magic-html.test.js.snap.webpack4 | 40 +++++ .../magic-html.test.js.snap.webpack5 | 40 +++++ test/e2e/magic-html.test.js | 167 ++++++++++++++++++ test/ports-map.js | 2 + .../Server.test.js.snap.webpack4 | 55 +++++- .../Server.test.js.snap.webpack5 | 55 +++++- test/validate-options.test.js | 4 + 16 files changed, 422 insertions(+), 7 deletions(-) create mode 100644 test/cli/magicHtml-option.test.js create mode 100644 test/e2e/__snapshots__/magic-html.test.js.snap.webpack4 create mode 100644 test/e2e/__snapshots__/magic-html.test.js.snap.webpack5 create mode 100644 test/e2e/magic-html.test.js diff --git a/README.md b/README.md index 0d3ff793fd..731e2050a5 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,8 @@ Options: --ipc [value] Listen to a unix socket. --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default). --no-live-reload Negative 'live-reload' option. + --magic-html Enables/Disables magic HTML routes (enabled by default). + --no-magic-html Negative 'magic-html' option. --open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). --no-open Negative 'open' option. diff --git a/bin/cli-flags.js b/bin/cli-flags.js index c489acf063..36d94ca44f 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -534,6 +534,19 @@ module.exports = { simpleType: "boolean", multiple: false, }, + "magic-html": { + configs: [ + { + type: "boolean", + multiple: false, + description: "Enables/Disables magic HTML routes (enabled by default).", + path: "magicHtml", + }, + ], + description: "Enables/Disables magic HTML routes (enabled by default).", + simpleType: "boolean", + multiple: false, + }, open: { configs: [ { diff --git a/lib/Server.js b/lib/Server.js index b68cc46238..c2ecb07b60 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -431,6 +431,9 @@ class Server { options.liveReload = typeof options.liveReload !== "undefined" ? options.liveReload : true; + options.magicHtml = + typeof options.magicHtml !== "undefined" ? options.magicHtml : true; + // https://github.com/webpack/webpack-dev-server/issues/1990 const defaultOpenOptions = { wait: false }; const getOpenItemsFromObject = ({ target, ...rest }) => { @@ -1132,7 +1135,9 @@ class Server { runnableFeatures.push("staticServeIndex", "staticWatch"); } - runnableFeatures.push("magicHtml"); + if (this.options.magicHtml) { + runnableFeatures.push("magicHtml"); + } if (this.options.onAfterSetupMiddleware) { runnableFeatures.push("onAfterSetupMiddleware"); diff --git a/lib/options.json b/lib/options.json index e7dca85dc9..8cc59dc8ed 100644 --- a/lib/options.json +++ b/lib/options.json @@ -331,6 +331,11 @@ "description": "Enables reload/refresh the page(s) when file changes are detected (enabled by default).", "link": "https://webpack.js.org/configuration/dev-server/#devserverlivereload" }, + "MagicHTML": { + "type": "boolean", + "description": "Enables/Disables magic HTML routes (enabled by default).", + "link": "https://webpack.js.org/configuration/dev-server/#devservermagichtml" + }, "OnAfterSetupMiddleware": { "instanceof": "Function", "description": "Provides the ability to execute a custom function and apply custom middleware(s) after all other middlewares.", @@ -729,6 +734,9 @@ "liveReload": { "$ref": "#/definitions/LiveReload" }, + "magicHtml": { + "$ref": "#/definitions/MagicHTML" + }, "onAfterSetupMiddleware": { "$ref": "#/definitions/OnAfterSetupMiddleware" }, diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 77fc6bc030..2000a987b1 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -439,6 +439,13 @@ exports[`options validate should throw an error on the "liveReload" option with -> Read more at https://webpack.js.org/configuration/dev-server/#devserverlivereload" `; +exports[`options validate should throw an error on the "magicHtml" option with 'string' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.magicHtml should be a boolean. + -> Enables/Disables magic HTML routes (enabled by default). + -> Read more at https://webpack.js.org/configuration/dev-server/#devservermagichtml" +`; + exports[`options validate should throw an error on the "onAfterSetupMiddleware" option with 'false' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.onAfterSetupMiddleware should be an instance of function. diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 77fc6bc030..2000a987b1 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -439,6 +439,13 @@ exports[`options validate should throw an error on the "liveReload" option with -> Read more at https://webpack.js.org/configuration/dev-server/#devserverlivereload" `; +exports[`options validate should throw an error on the "magicHtml" option with 'string' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.magicHtml should be a boolean. + -> Enables/Disables magic HTML routes (enabled by default). + -> Read more at https://webpack.js.org/configuration/dev-server/#devservermagichtml" +`; + exports[`options validate should throw an error on the "onAfterSetupMiddleware" option with 'false' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.onAfterSetupMiddleware should be an instance of function. diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index 48c0573065..5d02f9c6e4 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -99,6 +99,8 @@ Options: --ipc [value] Listen to a unix socket. --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default). --no-live-reload Disables reload/refresh the page(s) when file changes are detected (enabled by default) + --magic-html Enables/Disables magic HTML routes (enabled by default). + --no-magic-html Negative 'magic-html' option. --open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). --no-open Does not open the default browser. --open-target Opens specified page in browser. diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index f3179d0008..3703b3570b 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -98,6 +98,8 @@ Options: --ipc [value] Listen to a unix socket. --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default). --no-live-reload Negative 'live-reload' option. + --magic-html Enables/Disables magic HTML routes (enabled by default). + --no-magic-html Negative 'magic-html' option. --open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). --no-open Negative 'open' option. --open-target Opens specified page in browser. diff --git a/test/cli/magicHtml-option.test.js b/test/cli/magicHtml-option.test.js new file mode 100644 index 0000000000..9b72103d1e --- /dev/null +++ b/test/cli/magicHtml-option.test.js @@ -0,0 +1,18 @@ +"use strict"; + +const { testBin } = require("../helpers/test-bin"); +const port = require("../ports-map")["cli-magic-html"]; + +describe('"liveReload" CLI option', () => { + it('should work using "--magic-html"', async () => { + const { exitCode } = await testBin(["--port", port, "--magic-html"]); + + expect(exitCode).toEqual(0); + }); + + it('should work using "--no-magic-html"', async () => { + const { exitCode } = await testBin(["--port", port, "--no-magic-html"]); + + expect(exitCode).toEqual(0); + }); +}); diff --git a/test/e2e/__snapshots__/magic-html.test.js.snap.webpack4 b/test/e2e/__snapshots__/magic-html.test.js.snap.webpack4 new file mode 100644 index 0000000000..e230836a56 --- /dev/null +++ b/test/e2e/__snapshots__/magic-html.test.js.snap.webpack4 @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`magicHtml option disabled should not handle GET request to magic async html: console messages 1`] = ` +Array [ + "Failed to load resource: the server responded with a status of 404 (Not Found)", +] +`; + +exports[`magicHtml option disabled should not handle GET request to magic async html: response headers content-type 1`] = `"text/html; charset=utf-8"`; + +exports[`magicHtml option disabled should not handle GET request to magic async html: response status 1`] = `404`; + +exports[`magicHtml option disabled should not handle HEAD request to magic async html: console messages 1`] = ` +Array [ + "Failed to load resource: the server responded with a status of 404 (Not Found)", +] +`; + +exports[`magicHtml option disabled should not handle HEAD request to magic async html: response headers content-type 1`] = `"text/html; charset=utf-8"`; + +exports[`magicHtml option disabled should not handle HEAD request to magic async html: response status 1`] = `404`; + +exports[`magicHtml option enabled should handle GET request to magic async html: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`magicHtml option enabled should handle GET request to magic async html: response headers content-type 1`] = `"text/html; charset=utf-8"`; + +exports[`magicHtml option enabled should handle GET request to magic async html: response status 1`] = `200`; + +exports[`magicHtml option enabled should handle HEAD request to magic async html: console messages 1`] = `Array []`; + +exports[`magicHtml option enabled should handle HEAD request to magic async html: response headers content-type 1`] = `"text/html; charset=utf-8"`; + +exports[`magicHtml option enabled should handle HEAD request to magic async html: response status 1`] = `200`; diff --git a/test/e2e/__snapshots__/magic-html.test.js.snap.webpack5 b/test/e2e/__snapshots__/magic-html.test.js.snap.webpack5 new file mode 100644 index 0000000000..e230836a56 --- /dev/null +++ b/test/e2e/__snapshots__/magic-html.test.js.snap.webpack5 @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`magicHtml option disabled should not handle GET request to magic async html: console messages 1`] = ` +Array [ + "Failed to load resource: the server responded with a status of 404 (Not Found)", +] +`; + +exports[`magicHtml option disabled should not handle GET request to magic async html: response headers content-type 1`] = `"text/html; charset=utf-8"`; + +exports[`magicHtml option disabled should not handle GET request to magic async html: response status 1`] = `404`; + +exports[`magicHtml option disabled should not handle HEAD request to magic async html: console messages 1`] = ` +Array [ + "Failed to load resource: the server responded with a status of 404 (Not Found)", +] +`; + +exports[`magicHtml option disabled should not handle HEAD request to magic async html: response headers content-type 1`] = `"text/html; charset=utf-8"`; + +exports[`magicHtml option disabled should not handle HEAD request to magic async html: response status 1`] = `404`; + +exports[`magicHtml option enabled should handle GET request to magic async html: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`magicHtml option enabled should handle GET request to magic async html: response headers content-type 1`] = `"text/html; charset=utf-8"`; + +exports[`magicHtml option enabled should handle GET request to magic async html: response status 1`] = `200`; + +exports[`magicHtml option enabled should handle HEAD request to magic async html: console messages 1`] = `Array []`; + +exports[`magicHtml option enabled should handle HEAD request to magic async html: response headers content-type 1`] = `"text/html; charset=utf-8"`; + +exports[`magicHtml option enabled should handle HEAD request to magic async html: response status 1`] = `200`; diff --git a/test/e2e/magic-html.test.js b/test/e2e/magic-html.test.js new file mode 100644 index 0000000000..5d1f8f9fb3 --- /dev/null +++ b/test/e2e/magic-html.test.js @@ -0,0 +1,167 @@ +"use strict"; + +const webpack = require("webpack"); +const Server = require("../../lib/Server"); +const config = require("../fixtures/client-config/webpack.config"); +const runBrowser = require("../helpers/run-browser"); +const port = require("../ports-map")["magic-html-option"]; + +describe("magicHtml option", () => { + describe("enabled", () => { + let compiler; + let server; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + server = new Server({ port, magicHtml: true }, compiler); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + await browser.close(); + await server.stop(); + }); + + it("should handle GET request to magic async html", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`http://127.0.0.1:${port}/main`, { + waitUntil: "networkidle0", + }); + + expect(response.headers()["content-type"]).toMatchSnapshot( + "response headers content-type" + ); + + expect(response.status()).toMatchSnapshot("response status"); + + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + }); + + it("should handle HEAD request to magic async html", async () => { + await page.setRequestInterception(true); + + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }) + .on("request", (interceptedRequest) => { + interceptedRequest.continue({ method: "HEAD" }); + }); + + const response = await page.goto(`http://127.0.0.1:${port}/main`, { + waitUntil: "networkidle0", + }); + + expect(response.headers()["content-type"]).toMatchSnapshot( + "response headers content-type" + ); + + expect(response.status()).toMatchSnapshot("response status"); + + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + }); + }); + + describe("disabled", () => { + let compiler; + let server; + let page; + let browser; + let pageErrors; + let consoleMessages; + + beforeEach(async () => { + compiler = webpack(config); + server = new Server({ port, magicHtml: false }, compiler); + + await server.start(); + + ({ page, browser } = await runBrowser()); + + pageErrors = []; + consoleMessages = []; + }); + + afterEach(async () => { + await browser.close(); + await server.stop(); + }); + + it("should not handle GET request to magic async html", async () => { + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + const response = await page.goto(`http://127.0.0.1:${port}/main`, { + waitUntil: "networkidle0", + }); + + expect(response.headers()["content-type"]).toMatchSnapshot( + "response headers content-type" + ); + + expect(response.status()).toMatchSnapshot("response status"); + + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + }); + + it("should not handle HEAD request to magic async html", async () => { + await page.setRequestInterception(true); + + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }) + .on("request", (interceptedRequest) => { + interceptedRequest.continue({ method: "HEAD" }); + }); + + const response = await page.goto(`http://127.0.0.1:${port}/main`, { + waitUntil: "networkidle0", + }); + + expect(response.headers()["content-type"]).toMatchSnapshot( + "response headers content-type" + ); + + expect(response.status()).toMatchSnapshot("response status"); + + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + }); + }); +}); diff --git a/test/ports-map.js b/test/ports-map.js index 9e877ea9cc..55dbe75568 100644 --- a/test/ports-map.js +++ b/test/ports-map.js @@ -30,6 +30,7 @@ const listOfTests = { "http2-option": 1, "https-option": 1, "mine-types-option": 1, + "magic-html-option": 1, "on-after-setup-middleware-option": 1, "on-before-setup-middleware-option": 1, "on-listening-option": 1, @@ -60,6 +61,7 @@ const listOfTests = { "cli-http2": 1, "cli-https": 1, "cli-live-reload": 1, + "cli-magic-html": 1, "cli-open": 1, "cli-static": 1, "cli-watch-files": 1, diff --git a/test/server/__snapshots__/Server.test.js.snap.webpack4 b/test/server/__snapshots__/Server.test.js.snap.webpack4 index 6956377a62..653339abf1 100644 --- a/test/server/__snapshots__/Server.test.js.snap.webpack4 +++ b/test/server/__snapshots__/Server.test.js.snap.webpack4 @@ -4,7 +4,7 @@ exports[`Server DevServerPlugin add hot option 1`] = ` Array [ Array [ "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info", + "index.js?protocol=ws%3A&hostname=localhost&port=8125&pathname=%2Fws&logging=info", ], Array [ "node_modules", @@ -22,7 +22,7 @@ exports[`Server DevServerPlugin add hot-only option 1`] = ` Array [ Array [ "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info", + "index.js?protocol=ws%3A&hostname=localhost&port=8125&pathname=%2Fws&logging=info", ], Array [ "node_modules", @@ -40,7 +40,7 @@ exports[`Server DevServerPlugin should create and run server with old parameters Array [ Array [ "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info", + "index.js?protocol=ws%3A&hostname=localhost&port=8125&pathname=%2Fws&logging=info", ], Array [ "node_modules", @@ -73,6 +73,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -114,6 +115,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -156,6 +158,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -200,6 +203,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -244,6 +248,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -287,6 +292,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -330,6 +336,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -372,6 +379,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -414,6 +422,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -456,6 +465,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -500,6 +510,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -544,6 +555,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -587,6 +599,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -628,6 +641,7 @@ Object { "host": undefined, "hot": false, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -669,6 +683,7 @@ Object { "host": undefined, "hot": "only", "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -710,6 +725,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -751,6 +767,7 @@ Object { "host": undefined, "hot": true, "liveReload": false, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -792,6 +809,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -833,6 +851,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -874,6 +893,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -915,6 +935,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -956,6 +977,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -997,6 +1019,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1038,6 +1061,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1079,6 +1103,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1120,6 +1145,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1161,6 +1187,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1202,6 +1229,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1245,6 +1273,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1288,6 +1317,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1331,6 +1361,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1374,6 +1405,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1426,6 +1458,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1478,6 +1511,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1530,6 +1564,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1571,6 +1606,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1600,6 +1636,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1641,6 +1678,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1682,6 +1720,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1723,6 +1762,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1765,6 +1805,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1806,6 +1847,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1845,6 +1887,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1886,6 +1929,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1929,6 +1973,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1970,6 +2015,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -2014,6 +2060,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -2055,6 +2102,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -2096,6 +2144,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, diff --git a/test/server/__snapshots__/Server.test.js.snap.webpack5 b/test/server/__snapshots__/Server.test.js.snap.webpack5 index 6956377a62..653339abf1 100644 --- a/test/server/__snapshots__/Server.test.js.snap.webpack5 +++ b/test/server/__snapshots__/Server.test.js.snap.webpack5 @@ -4,7 +4,7 @@ exports[`Server DevServerPlugin add hot option 1`] = ` Array [ Array [ "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info", + "index.js?protocol=ws%3A&hostname=localhost&port=8125&pathname=%2Fws&logging=info", ], Array [ "node_modules", @@ -22,7 +22,7 @@ exports[`Server DevServerPlugin add hot-only option 1`] = ` Array [ Array [ "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info", + "index.js?protocol=ws%3A&hostname=localhost&port=8125&pathname=%2Fws&logging=info", ], Array [ "node_modules", @@ -40,7 +40,7 @@ exports[`Server DevServerPlugin should create and run server with old parameters Array [ Array [ "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info", + "index.js?protocol=ws%3A&hostname=localhost&port=8125&pathname=%2Fws&logging=info", ], Array [ "node_modules", @@ -73,6 +73,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -114,6 +115,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -156,6 +158,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -200,6 +203,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -244,6 +248,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -287,6 +292,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -330,6 +336,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -372,6 +379,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -414,6 +422,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -456,6 +465,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -500,6 +510,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -544,6 +555,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -587,6 +599,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -628,6 +641,7 @@ Object { "host": undefined, "hot": false, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -669,6 +683,7 @@ Object { "host": undefined, "hot": "only", "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -710,6 +725,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -751,6 +767,7 @@ Object { "host": undefined, "hot": true, "liveReload": false, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -792,6 +809,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -833,6 +851,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -874,6 +893,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -915,6 +935,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -956,6 +977,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -997,6 +1019,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1038,6 +1061,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1079,6 +1103,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1120,6 +1145,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1161,6 +1187,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1202,6 +1229,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1245,6 +1273,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1288,6 +1317,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1331,6 +1361,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1374,6 +1405,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1426,6 +1458,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1478,6 +1511,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1530,6 +1564,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1571,6 +1606,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1600,6 +1636,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1641,6 +1678,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1682,6 +1720,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1723,6 +1762,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1765,6 +1805,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1806,6 +1847,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1845,6 +1887,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1886,6 +1929,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1929,6 +1973,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -1970,6 +2015,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -2014,6 +2060,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -2055,6 +2102,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, @@ -2096,6 +2144,7 @@ Object { "host": undefined, "hot": true, "liveReload": true, + "magicHtml": true, "open": Array [], "port": "", "setupExitSignals": true, diff --git a/test/validate-options.test.js b/test/validate-options.test.js index af6f513b26..d29126def2 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -241,6 +241,10 @@ const tests = { success: [true, false], failure: ["invalid"], }, + magicHtml: { + success: [true, false], + failure: ["string"], + }, onListening: { success: [() => {}], failure: [""],