From 6f89bb6c6217e0f1be53a778be7d3cc46aeeb2ae Mon Sep 17 00:00:00 2001 From: Yuta Hiroto Date: Tue, 28 Apr 2020 17:57:06 +0900 Subject: [PATCH 1/5] fix(hot): enable hot option as a default --- client-src/default/index.js | 3 +-- lib/Server.js | 12 +++++++++++- test/client/__snapshots__/index.test.js.snap | 2 +- test/e2e/Client.test.js | 4 ---- test/e2e/__snapshots__/ClientOptions.test.js.snap | 4 ++++ test/e2e/__snapshots__/Iframe.test.js.snap | 4 ++++ test/e2e/__snapshots__/TransportMode.test.js.snap | 7 +++++++ .../__snapshots__/transportMode-option.test.js.snap | 13 +++++++++++-- test/server/hot-option.test.js | 4 ---- test/server/transportMode-option.test.js | 12 +++++++----- 10 files changed, 46 insertions(+), 19 deletions(-) diff --git a/client-src/default/index.js b/client-src/default/index.js index dede6f0763..cde1dd1dbe 100644 --- a/client-src/default/index.js +++ b/client-src/default/index.js @@ -15,7 +15,7 @@ const status = { currentHash: '', }; const options = { - hot: false, + hot: true, hotReload: true, liveReload: false, initial: true, @@ -36,7 +36,6 @@ if (typeof window !== 'undefined') { const onSocketMessage = { hot() { - options.hot = true; log.info('[WDS] Hot Module Replacement enabled.'); }, liveReload() { diff --git a/lib/Server.js b/lib/Server.js index e8be8393e0..51244392bd 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -69,6 +69,17 @@ class Server { normalizeOptions(this.compiler, this.options); + // don't move this position because addEntries called by updateCompiler checks this.options.hot|hotOnly + this.hot = + typeof this.options.hot === 'boolean' || + typeof this.options.hotOnly === 'boolean' + ? this.options.hot || this.options.hotOnly + : true; + + if (this.hot) { + this.options.hot = true; + } + updateCompiler(this.compiler, this.options); this.heartbeatInterval = 30000; @@ -86,7 +97,6 @@ class Server { this.contentBaseWatchers = []; // TODO this. is deprecated (remove them in next major release.) in favor this.options. - this.hot = this.options.hot || this.options.hotOnly; this.headers = this.options.headers; this.progress = this.options.progress; diff --git a/test/client/__snapshots__/index.test.js.snap b/test/client/__snapshots__/index.test.js.snap index cc267a2ce7..575f85c19b 100644 --- a/test/client/__snapshots__/index.test.js.snap +++ b/test/client/__snapshots__/index.test.js.snap @@ -36,7 +36,7 @@ exports[`index should run onSocketMessage.ok 1`] = `"Ok"`; exports[`index should run onSocketMessage.ok 2`] = ` Object { - "hot": false, + "hot": true, "hotReload": true, "initial": false, "liveReload": false, diff --git a/test/e2e/Client.test.js b/test/e2e/Client.test.js index efc90dee1c..620743e8e8 100644 --- a/test/e2e/Client.test.js +++ b/test/e2e/Client.test.js @@ -24,15 +24,11 @@ describe('reload', () => { const modes = [ { title: 'hot with default transportMode.client (sockjs)', - options: { - hot: true, - }, shouldRefresh: false, }, { title: 'hot with transportMode.client ws', options: { - hot: true, transportMode: 'ws', }, shouldRefresh: false, diff --git a/test/e2e/__snapshots__/ClientOptions.test.js.snap b/test/e2e/__snapshots__/ClientOptions.test.js.snap index 27b5c3406b..c84849e45f 100644 --- a/test/e2e/__snapshots__/ClientOptions.test.js.snap +++ b/test/e2e/__snapshots__/ClientOptions.test.js.snap @@ -25,12 +25,16 @@ Array [ exports[`Client console.log liveReload disabled 1`] = ` Array [ "Hey.", + "[HMR] Waiting for update signal from WDS...", + "[WDS] Hot Module Replacement enabled.", ] `; exports[`Client console.log liveReload enabled 1`] = ` Array [ "Hey.", + "[HMR] Waiting for update signal from WDS...", + "[WDS] Hot Module Replacement enabled.", "[WDS] Live Reloading enabled.", ] `; diff --git a/test/e2e/__snapshots__/Iframe.test.js.snap b/test/e2e/__snapshots__/Iframe.test.js.snap index ba2007f1ca..98eca562be 100644 --- a/test/e2e/__snapshots__/Iframe.test.js.snap +++ b/test/e2e/__snapshots__/Iframe.test.js.snap @@ -25,12 +25,16 @@ Array [ exports[`Client iframe console.log liveReload disabled 1`] = ` Array [ "Hey.", + "[HMR] Waiting for update signal from WDS...", + "[WDS] Hot Module Replacement enabled.", ] `; exports[`Client iframe console.log liveReload enabled 1`] = ` Array [ "Hey.", + "[HMR] Waiting for update signal from WDS...", + "[WDS] Hot Module Replacement enabled.", "[WDS] Live Reloading enabled.", ] `; diff --git a/test/e2e/__snapshots__/TransportMode.test.js.snap b/test/e2e/__snapshots__/TransportMode.test.js.snap index b3c92fa7fd..f519cfd19a 100644 --- a/test/e2e/__snapshots__/TransportMode.test.js.snap +++ b/test/e2e/__snapshots__/TransportMode.test.js.snap @@ -2,8 +2,11 @@ exports[`transportMode client custom client on browser client logs correctly 1`] = ` Array [ + "[HMR] Waiting for update signal from WDS...", "Hey.", "open", + "hot", + "[WDS] Hot Module Replacement enabled.", "liveReload", "[WDS] Live Reloading enabled.", "hash", @@ -15,7 +18,9 @@ Array [ exports[`transportMode client sockjs on browser client logs correctly 1`] = ` Array [ + "[HMR] Waiting for update signal from WDS...", "Hey.", + "[WDS] Hot Module Replacement enabled.", "[WDS] Live Reloading enabled.", "[WDS] Disconnected!", ] @@ -23,7 +28,9 @@ Array [ exports[`transportMode client ws on browser client logs correctly 1`] = ` Array [ + "[HMR] Waiting for update signal from WDS...", "Hey.", + "[WDS] Hot Module Replacement enabled.", "[WDS] Live Reloading enabled.", "[WDS] Disconnected!", ] diff --git a/test/server/__snapshots__/transportMode-option.test.js.snap b/test/server/__snapshots__/transportMode-option.test.js.snap index 0a07287ada..cb0a1037ca 100644 --- a/test/server/__snapshots__/transportMode-option.test.js.snap +++ b/test/server/__snapshots__/transportMode-option.test.js.snap @@ -87,7 +87,7 @@ Array [ Object { "foo": "bar", }, - "{\\"type\\":\\"liveReload\\"}", + "{\\"type\\":\\"hot\\"}", ] `; @@ -96,11 +96,20 @@ Array [ Object { "foo": "bar", }, - "{\\"type\\":\\"ok\\"}", + "{\\"type\\":\\"liveReload\\"}", ] `; exports[`transportMode server server should use server implementation correctly 5`] = ` +Array [ + Object { + "foo": "bar", + }, + "{\\"type\\":\\"ok\\"}", +] +`; + +exports[`transportMode server server should use server implementation correctly 6`] = ` Array [ Array [ Object { diff --git a/test/server/hot-option.test.js b/test/server/hot-option.test.js index 979bbad12c..310613af80 100644 --- a/test/server/hot-option.test.js +++ b/test/server/hot-option.test.js @@ -15,7 +15,6 @@ describe('hot option', () => { const options = { port, inline: true, - hot: true, watchOptions: { poll: true, }, @@ -36,7 +35,6 @@ describe('hot option', () => { const options = { port, inline: true, - hot: true, watchOptions: { poll: true, }, @@ -92,7 +90,6 @@ describe('hot option', () => { const options = { port, inline: true, - hot: true, watchOptions: { poll: true, }, @@ -126,7 +123,6 @@ describe('hot option', () => { const options = { port, inline: true, - hot: true, watchOptions: { poll: true, }, diff --git a/test/server/transportMode-option.test.js b/test/server/transportMode-option.test.js index d4a54ffc12..185f334c0f 100644 --- a/test/server/transportMode-option.test.js +++ b/test/server/transportMode-option.test.js @@ -487,12 +487,14 @@ describe('transportMode', () => { expect(MockSockJSServer.mock.calls[0][0].options.port).toEqual(port); expect(mockServerInstance.onConnection.mock.calls).toMatchSnapshot(); - expect(mockServerInstance.send.mock.calls.length).toEqual(3); - // call 0 to the send() method is liveReload + expect(mockServerInstance.send.mock.calls.length).toEqual(4); + // call 0 to the send() method is hot expect(mockServerInstance.send.mock.calls[0]).toMatchSnapshot(); - // call 1 to the send() method is hash data, so we skip it - // call 2 to the send() method is the "ok" message - expect(mockServerInstance.send.mock.calls[2]).toMatchSnapshot(); + // call 1 to the send() method is liveReload + expect(mockServerInstance.send.mock.calls[1]).toMatchSnapshot(); + // call 2 to the send() method is hash data, so we skip it + // call 3 to the send() method is the "ok" message + expect(mockServerInstance.send.mock.calls[3]).toMatchSnapshot(); // close should not be called because the server never forcefully closes // a successful client connection expect(mockServerInstance.close.mock.calls.length).toEqual(0); From fac6b792409b95a675a99b049adb5015d4f6826d Mon Sep 17 00:00:00 2001 From: Yuta Hiroto Date: Tue, 28 Apr 2020 23:11:31 +0900 Subject: [PATCH 2/5] fix: delete hotOnly option --- lib/Server.js | 13 +- lib/options.json | 15 ++- lib/utils/addEntries.js | 4 +- lib/utils/createConfig.js | 6 - lib/utils/updateCompiler.js | 2 +- test/__snapshots__/Validation.test.js.snap | 8 +- .../schema/webpack.config.no-dev-stats.js | 1 - test/helpers/test-server.js | 1 - test/options.test.js | 8 +- test/ports-map.js | 1 - test/server/Server.test.js | 4 +- test/server/__snapshots__/Server.test.js.snap | 2 +- test/server/hot-option.test.js | 23 ++++ test/server/hotOnly-option.test.js | 68 ---------- test/server/open-option.test.js | 2 +- .../WebsocketServer.test.js.snap | 2 +- .../__snapshots__/createConfig.test.js.snap | 122 ------------------ test/server/utils/addEntries.test.js | 4 +- test/server/utils/createConfig.test.js | 24 ---- 19 files changed, 54 insertions(+), 256 deletions(-) delete mode 100644 test/server/hotOnly-option.test.js diff --git a/lib/Server.js b/lib/Server.js index 51244392bd..f3cb987563 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -70,16 +70,11 @@ class Server { normalizeOptions(this.compiler, this.options); // don't move this position because addEntries called by updateCompiler checks this.options.hot|hotOnly - this.hot = - typeof this.options.hot === 'boolean' || - typeof this.options.hotOnly === 'boolean' - ? this.options.hot || this.options.hotOnly + this.options.hot = + typeof this.options.hot === 'boolean' || this.options.hot === 'only' + ? this.options.hot : true; - if (this.hot) { - this.options.hot = true; - } - updateCompiler(this.compiler, this.options); this.heartbeatInterval = 30000; @@ -742,7 +737,7 @@ class Server { this.sockWrite([connection], 'log-level', this.clientLogLevel); } - if (this.hot) { + if (this.options.hot) { this.sockWrite([connection], 'hot'); } diff --git a/lib/options.json b/lib/options.json index 43c8d30b94..3e7d05214c 100644 --- a/lib/options.json +++ b/lib/options.json @@ -134,10 +134,14 @@ ] }, "hot": { - "type": "boolean" - }, - "hotOnly": { - "type": "boolean" + "anyOf": [ + { + "type": "boolean" + }, + { + "enum": ["only"] + } + ] }, "http2": { "type": "boolean" @@ -446,8 +450,7 @@ "headers": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverheaders-)", "historyApiFallback": "should be {Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserverhistoryapifallback)", "host": "should be {String|Null} (https://webpack.js.org/configuration/dev-server/#devserverhost)", - "hot": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhot)", - "hotOnly": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhotonly)", + "hot": "should be {Boolean|String} (https://webpack.js.org/configuration/dev-server/#devserverhot)", "http2": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhttp2)", "https": "should be {Object|Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhttps)", "index": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverindex)", diff --git a/lib/utils/addEntries.js b/lib/utils/addEntries.js index 7eaac33003..02c070576b 100644 --- a/lib/utils/addEntries.js +++ b/lib/utils/addEntries.js @@ -43,7 +43,7 @@ function addEntries(config, options, server) { /** @type {(string[] | string)} */ let hotEntry; - if (options.hotOnly) { + if (options.hot === 'only') { hotEntry = require.resolve('webpack/hot/only-dev-server'); } else if (options.hot) { hotEntry = require.resolve('webpack/hot/dev-server'); @@ -141,7 +141,7 @@ function addEntries(config, options, server) { config.entry = prependEntry(config.entry || './src', additionalEntries); - if (options.hot || options.hotOnly) { + if (options.hot || options.hot === 'only') { config.plugins = config.plugins || []; if ( !config.plugins.find( diff --git a/lib/utils/createConfig.js b/lib/utils/createConfig.js index 5c15b35c39..e3a06b767e 100644 --- a/lib/utils/createConfig.js +++ b/lib/utils/createConfig.js @@ -95,12 +95,6 @@ function createConfig(config, argv, { port }) { options.hot = argv.hot; } - // TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4) - // We should prefer CLI arg under config, now we always prefer `hotOnly` from `devServer` - if (!options.hotOnly) { - options.hotOnly = argv.hotOnly; - } - // TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4) // We should prefer CLI arg under config, now we always prefer `clientLogLevel` from `devServer` if (!options.clientLogLevel && argv.clientLogLevel) { diff --git a/lib/utils/updateCompiler.js b/lib/utils/updateCompiler.js index 9f701e81b4..d093ffba24 100644 --- a/lib/utils/updateCompiler.js +++ b/lib/utils/updateCompiler.js @@ -57,7 +57,7 @@ function updateCompiler(compiler, options) { }); // do not apply the plugin unless it didn't exist before. - if (options.hot || options.hotOnly) { + if (options.hot || options.hot === 'only') { compilersWithoutHMR.forEach((compiler) => { // addDevServerEntrypoints above should have added the plugin // to the compiler options diff --git a/test/__snapshots__/Validation.test.js.snap b/test/__snapshots__/Validation.test.js.snap index 29cb3ed1e1..374cb086a9 100644 --- a/test/__snapshots__/Validation.test.js.snap +++ b/test/__snapshots__/Validation.test.js.snap @@ -7,7 +7,11 @@ exports[`Validation validation should fail validation for invalid \`contentBase\ exports[`Validation validation should fail validation for invalid \`hot\` configuration 1`] = ` "Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - - configuration.hot should be a boolean." + - configuration.hot should be one of these: + boolean | \\"only\\" + Details: + * configuration.hot should be a boolean. + * configuration.hot should be \\"only\\"." `; exports[`Validation validation should fail validation for invalid \`logLevel\` configuration 1`] = ` @@ -33,5 +37,5 @@ exports[`Validation validation should fail validation for invalid \`writeToDisk\ exports[`Validation validation should fail validation for no additional properties 1`] = ` "Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration has an unknown property 'additional'. These properties are valid: - object { after?, allowedHosts?, before?, bonjour?, ca?, cert?, clientLogLevel?, compress?, contentBasePublicPath?, contentBase?, disableHostCheck?, features?, filename?, fs?, headers?, historyApiFallback?, host?, hot?, hotOnly?, http2?, https?, index?, injectClient?, injectHot?, inline?, key?, lazy?, liveReload?, log?, logLevel?, logTime?, mimeTypes?, noInfo?, onListening?, open?, openPage?, overlay?, pfx?, pfxPassphrase?, port?, profile?, progress?, proxy?, public?, publicPath?, quiet?, reporter?, requestCert?, serveIndex?, serverSideRender?, setup?, sockHost?, sockPath?, sockPort?, socket?, staticOptions?, stats?, transportMode?, useLocalIp?, warn?, watchContentBase?, watchOptions?, writeToDisk? }" + object { after?, allowedHosts?, before?, bonjour?, ca?, cert?, clientLogLevel?, compress?, contentBasePublicPath?, contentBase?, disableHostCheck?, features?, filename?, fs?, headers?, historyApiFallback?, host?, hot?, http2?, https?, index?, injectClient?, injectHot?, inline?, key?, lazy?, liveReload?, log?, logLevel?, logTime?, mimeTypes?, noInfo?, onListening?, open?, openPage?, overlay?, pfx?, pfxPassphrase?, port?, profile?, progress?, proxy?, public?, publicPath?, quiet?, reporter?, requestCert?, serveIndex?, serverSideRender?, setup?, sockHost?, sockPath?, sockPort?, socket?, staticOptions?, stats?, transportMode?, useLocalIp?, warn?, watchContentBase?, watchOptions?, writeToDisk? }" `; diff --git a/test/fixtures/schema/webpack.config.no-dev-stats.js b/test/fixtures/schema/webpack.config.no-dev-stats.js index ca5a83b7da..553607cbe9 100644 --- a/test/fixtures/schema/webpack.config.no-dev-stats.js +++ b/test/fixtures/schema/webpack.config.no-dev-stats.js @@ -13,7 +13,6 @@ module.exports = { publicPath: '_publicPath', filename: '_filename', hot: '_hot', - hotOnly: '_hotOnly', clientLogLevel: '_clientLogLevel', contentBase: '_contentBase', watchContentBase: '_watchContentBase', diff --git a/test/helpers/test-server.js b/test/helpers/test-server.js index f9284c4fca..701c3912f2 100644 --- a/test/helpers/test-server.js +++ b/test/helpers/test-server.js @@ -23,7 +23,6 @@ function startFullSetup(config, options, done) { if ( options.inline === undefined && options.hot === undefined && - options.hotOnly === undefined && options.liveReload === undefined ) { options.inline = false; diff --git a/test/options.test.js b/test/options.test.js index 9c54380624..ce899f8dd4 100644 --- a/test/options.test.js +++ b/test/options.test.js @@ -188,12 +188,8 @@ describe('options', () => { failure: [false], }, hot: { - success: [true], - failure: [''], - }, - hotOnly: { - success: [true], - failure: [''], + success: [true, 'only'], + failure: ['', 'foo'], }, http2: { success: [true], diff --git a/test/ports-map.js b/test/ports-map.js index ac73aaa142..0917c02e88 100644 --- a/test/ports-map.js +++ b/test/ports-map.js @@ -21,7 +21,6 @@ const portsList = { 'historyApiFallback-option': 1, 'host-option': 1, 'hot-option': 1, - 'hotOnly-option': 1, 'http2-option': 1, 'https-option': 1, 'inline-option': 1, diff --git a/test/server/Server.test.js b/test/server/Server.test.js index 518de50e92..c3135448b3 100644 --- a/test/server/Server.test.js +++ b/test/server/Server.test.js @@ -50,12 +50,12 @@ describe('Server', () => { compiler.run(() => {}); }); - it('add hotOnly option', (done) => { + it('add hot-only option', (done) => { const compiler = webpack(config); const server = new Server( compiler, Object.assign({}, baseDevConfig, { - hotOnly: true, + hot: 'only', }) ); diff --git a/test/server/__snapshots__/Server.test.js.snap b/test/server/__snapshots__/Server.test.js.snap index 6b69e950ff..8a378414db 100644 --- a/test/server/__snapshots__/Server.test.js.snap +++ b/test/server/__snapshots__/Server.test.js.snap @@ -19,7 +19,7 @@ Array [ ] `; -exports[`Server addEntries add hotOnly option 1`] = ` +exports[`Server addEntries add hot-only option 1`] = ` Array [ Array [ "client", diff --git a/test/server/hot-option.test.js b/test/server/hot-option.test.js index 310613af80..643c9d2afe 100644 --- a/test/server/hot-option.test.js +++ b/test/server/hot-option.test.js @@ -30,6 +30,29 @@ describe('hot option', () => { }); }); + describe('simple hot-only config entries', () => { + beforeAll((done) => { + const options = { + port, + inline: true, + hot: 'only', + watchOptions: { + poll: true, + }, + }; + server = testServer.startAwaitingCompilation(config, options, done); + req = request(server.app); + }); + + afterAll(testServer.close); + + it('should include hot-only script in the bundle', (done) => { + req + .get('/main.js') + .expect(200, /webpack\/hot\/only-dev-server\.js/, done); + }); + }); + describe('multi compiler hot config entries', () => { beforeAll((done) => { const options = { diff --git a/test/server/hotOnly-option.test.js b/test/server/hotOnly-option.test.js deleted file mode 100644 index e601325fd3..0000000000 --- a/test/server/hotOnly-option.test.js +++ /dev/null @@ -1,68 +0,0 @@ -'use strict'; - -const request = require('supertest'); -const testServer = require('../helpers/test-server'); -const config = require('../fixtures/client-config/webpack.config'); -const port = require('../ports-map')['hotOnly-option']; - -describe('hotOnly options', () => { - let server; - let req; - - describe('simple hotOnly config entries', () => { - beforeAll((done) => { - const options = { - port, - inline: true, - hotOnly: true, - watchOptions: { - poll: true, - }, - }; - server = testServer.startAwaitingCompilation(config, options, done); - req = request(server.app); - }); - - afterAll(testServer.close); - - it('should include hotOnly script in the bundle', (done) => { - req - .get('/main.js') - .expect(200, /webpack\/hot\/only-dev-server\.js/, done); - }); - }); - - describe('simple hotOnly config HMR plugin', () => { - it('should register the HMR plugin before compilation is complete', (done) => { - let pluginFound = false; - const options = { - port, - inline: true, - hotOnly: true, - watchOptions: { - poll: true, - }, - }; - const fullSetup = testServer.startAwaitingCompilationFullSetup( - config, - options, - () => { - expect(pluginFound).toBeTruthy(); - done(); - } - ); - - const compiler = fullSetup.compiler; - compiler.hooks.compilation.intercept({ - register: (tapInfo) => { - if (tapInfo.name === 'HotModuleReplacementPlugin') { - pluginFound = true; - } - return tapInfo; - }, - }); - }); - - afterAll(testServer.close); - }); -}); diff --git a/test/server/open-option.test.js b/test/server/open-option.test.js index 01f7d88b8a..76658eb35c 100644 --- a/test/server/open-option.test.js +++ b/test/server/open-option.test.js @@ -27,7 +27,7 @@ describe('open option', () => { server.close(() => { expect(open.mock.calls[0]).toMatchInlineSnapshot(` Array [ - "http://localhost:8120/", + "http://localhost:8119/", Object { "wait": false, }, diff --git a/test/server/servers/__snapshots__/WebsocketServer.test.js.snap b/test/server/servers/__snapshots__/WebsocketServer.test.js.snap index 64f2a65dc9..16b78745af 100644 --- a/test/server/servers/__snapshots__/WebsocketServer.test.js.snap +++ b/test/server/servers/__snapshots__/WebsocketServer.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`WebsocketServer should receive connection, send message, and close client 1`] = `"localhost:8131"`; +exports[`WebsocketServer should receive connection, send message, and close client 1`] = `"localhost:8130"`; exports[`WebsocketServer should receive connection, send message, and close client 2`] = ` Array [ diff --git a/test/server/utils/__snapshots__/createConfig.test.js.snap b/test/server/utils/__snapshots__/createConfig.test.js.snap index 7fde2cf238..9c7daf4ae5 100644 --- a/test/server/utils/__snapshots__/createConfig.test.js.snap +++ b/test/server/utils/__snapshots__/createConfig.test.js.snap @@ -7,7 +7,6 @@ Object { "host2.com", ], "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -25,7 +24,6 @@ Object { "host2.com", ], "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -40,7 +38,6 @@ exports[`createConfig bonjour option (devServer config) 1`] = ` Object { "bonjour": true, "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -55,7 +52,6 @@ exports[`createConfig bonjour option 1`] = ` Object { "bonjour": true, "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -70,7 +66,6 @@ exports[`createConfig cacert option (in devServer config) 1`] = ` Object { "ca": "/path/to/ca.pem", "hot": true, - "hotOnly": false, "https": true, "noInfo": true, "port": 8080, @@ -86,7 +81,6 @@ exports[`createConfig cacert option 1`] = ` Object { "ca": "/path/to/ca.pem", "hot": true, - "hotOnly": false, "https": true, "noInfo": true, "port": 8080, @@ -102,7 +96,6 @@ exports[`createConfig cert option (in devServer config) 1`] = ` Object { "cert": "/path/to/server.crt", "hot": true, - "hotOnly": false, "https": true, "noInfo": true, "port": 8080, @@ -118,7 +111,6 @@ exports[`createConfig cert option 1`] = ` Object { "cert": "/path/to/server.crt", "hot": true, - "hotOnly": false, "https": true, "noInfo": true, "port": 8080, @@ -134,7 +126,6 @@ exports[`createConfig clientLogLevel option (in devServer config) 1`] = ` Object { "clientLogLevel": "none", "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -149,7 +140,6 @@ exports[`createConfig clientLogLevel option 1`] = ` Object { "clientLogLevel": "none", "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -164,7 +154,6 @@ exports[`createConfig compress option (in devServer config) 1`] = ` Object { "compress": true, "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -179,7 +168,6 @@ exports[`createConfig compress option 1`] = ` Object { "compress": true, "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -197,7 +185,6 @@ Object { "static", ], "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -212,7 +199,6 @@ exports[`createConfig contentBase option (boolean) 1`] = ` Object { "contentBase": false, "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -227,7 +213,6 @@ exports[`createConfig contentBase option (string) (in devServer config) 1`] = ` Object { "contentBase": "assets", "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -242,7 +227,6 @@ exports[`createConfig contentBase option (string) 1`] = ` Object { "contentBase": "assets", "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -257,7 +241,6 @@ exports[`createConfig disableHostCheck option (in devServer config) 1`] = ` Object { "disableHostCheck": true, "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -272,7 +255,6 @@ exports[`createConfig disableHostCheck option 1`] = ` Object { "disableHostCheck": true, "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -287,7 +269,6 @@ exports[`createConfig filename option (in devServer config) 1`] = ` Object { "filename": "[name]-dev-server-bundle.js", "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -302,7 +283,6 @@ exports[`createConfig filename option (in output config) 1`] = ` Object { "filename": "[name]-output-bundle.js", "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -317,7 +297,6 @@ exports[`createConfig filename option (in webpack config) 1`] = ` Object { "filename": "[name]-bundle.js", "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -332,7 +311,6 @@ exports[`createConfig historyApiFallback option (in devServer config) 1`] = ` Object { "historyApiFallback": true, "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -347,7 +325,6 @@ exports[`createConfig historyApiFallback option 1`] = ` Object { "historyApiFallback": true, "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -362,7 +339,6 @@ exports[`createConfig host option (devServer config) 1`] = ` Object { "host": "example.dev", "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -377,7 +353,6 @@ exports[`createConfig host option (localhost) 1`] = ` Object { "host": "localhost", "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -391,7 +366,6 @@ Object { exports[`createConfig host option (null) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -406,7 +380,6 @@ exports[`createConfig host option (specify for CLI and devServer config) 1`] = ` Object { "host": "other.dev", "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -420,7 +393,6 @@ Object { exports[`createConfig host option (undefined) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -435,7 +407,6 @@ exports[`createConfig host option 1`] = ` Object { "host": "example.dev", "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -449,7 +420,6 @@ Object { exports[`createConfig hot option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -463,35 +433,6 @@ Object { exports[`createConfig hot option 1`] = ` Object { "hot": true, - "hotOnly": false, - "noInfo": true, - "port": 8080, - "publicPath": "/", - "stats": Object { - "cached": false, - "cachedAssets": false, - }, -} -`; - -exports[`createConfig hotOnly option (in devServer config) 1`] = ` -Object { - "hot": true, - "hotOnly": true, - "noInfo": true, - "port": 8080, - "publicPath": "/", - "stats": Object { - "cached": false, - "cachedAssets": false, - }, -} -`; - -exports[`createConfig hotOnly option 1`] = ` -Object { - "hot": true, - "hotOnly": true, "noInfo": true, "port": 8080, "publicPath": "/", @@ -505,7 +446,6 @@ Object { exports[`createConfig http2 option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "http2": true, "https": true, "noInfo": true, @@ -521,7 +461,6 @@ Object { exports[`createConfig http2 option 1`] = ` Object { "hot": true, - "hotOnly": false, "http2": true, "https": true, "noInfo": true, @@ -537,7 +476,6 @@ Object { exports[`createConfig https option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "https": true, "noInfo": true, "port": 8080, @@ -552,7 +490,6 @@ Object { exports[`createConfig https option (in devServer config) 2`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "pfxPassphrase": "passphrase", "port": 8080, @@ -567,7 +504,6 @@ Object { exports[`createConfig https option 1`] = ` Object { "hot": true, - "hotOnly": false, "https": true, "noInfo": true, "port": 8080, @@ -582,7 +518,6 @@ Object { exports[`createConfig info option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -596,7 +531,6 @@ Object { exports[`createConfig info option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -610,7 +544,6 @@ Object { exports[`createConfig inline option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "inline": false, "noInfo": true, "port": 8080, @@ -625,7 +558,6 @@ Object { exports[`createConfig inline option 1`] = ` Object { "hot": true, - "hotOnly": false, "inline": false, "noInfo": true, "port": 8080, @@ -640,7 +572,6 @@ Object { exports[`createConfig key option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "https": true, "key": "/path/to/server.key", "noInfo": true, @@ -656,7 +587,6 @@ Object { exports[`createConfig key option 1`] = ` Object { "hot": true, - "hotOnly": false, "https": true, "key": "/path/to/server.key", "noInfo": true, @@ -672,7 +602,6 @@ Object { exports[`createConfig lazy option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "lazy": true, "noInfo": true, "port": 8080, @@ -687,7 +616,6 @@ Object { exports[`createConfig lazy option 1`] = ` Object { "hot": true, - "hotOnly": false, "lazy": true, "noInfo": true, "port": 8080, @@ -702,7 +630,6 @@ Object { exports[`createConfig liveReload option 1`] = ` Object { "hot": true, - "hotOnly": false, "liveReload": false, "noInfo": true, "port": 8080, @@ -717,7 +644,6 @@ Object { exports[`createConfig mimeTypes option - with force 1`] = ` Object { "hot": true, - "hotOnly": false, "mimeTypes": Object { "force": true, "typeMap": Object { @@ -739,7 +665,6 @@ Object { exports[`createConfig mimeTypes option 1`] = ` Object { "hot": true, - "hotOnly": false, "mimeTypes": Object { "text/html": Array [ "phtml", @@ -758,7 +683,6 @@ Object { exports[`createConfig onListening option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "onListening": [Function], "port": 8080, @@ -773,7 +697,6 @@ Object { exports[`createConfig open option (boolean) (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "open": true, "openPage": "", @@ -789,7 +712,6 @@ Object { exports[`createConfig open option (boolean) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "open": true, "openPage": "", @@ -805,7 +727,6 @@ Object { exports[`createConfig open option (object) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "open": Object { "app": Array [ @@ -826,7 +747,6 @@ Object { exports[`createConfig open option (string) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "open": "Google Chrome", "openPage": "", @@ -842,7 +762,6 @@ Object { exports[`createConfig openPage multiple option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "open": true, "openPage": Array [ @@ -861,7 +780,6 @@ Object { exports[`createConfig openPage option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "open": true, "openPage": "/different/page", @@ -877,7 +795,6 @@ Object { exports[`createConfig openPage option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "open": true, "openPage": Array [ @@ -895,7 +812,6 @@ Object { exports[`createConfig overlay option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "overlay": true, "port": 8080, @@ -910,7 +826,6 @@ Object { exports[`createConfig overlay option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "overlay": true, "port": 8080, @@ -925,7 +840,6 @@ Object { exports[`createConfig pfx option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "https": true, "noInfo": true, "pfx": "/path/to/file.pfx", @@ -941,7 +855,6 @@ Object { exports[`createConfig pfx option 1`] = ` Object { "hot": true, - "hotOnly": false, "https": true, "noInfo": true, "pfx": "/path/to/file.pfx", @@ -957,7 +870,6 @@ Object { exports[`createConfig pfxPassphrase option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "pfxPassphrase": "passphrase", "port": 8080, @@ -972,7 +884,6 @@ Object { exports[`createConfig port option (difference) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 7070, "publicPath": "/", @@ -986,7 +897,6 @@ Object { exports[`createConfig port option (same) (null) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": null, "publicPath": "/", @@ -1000,7 +910,6 @@ Object { exports[`createConfig port option (same) (string) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": "9090", "publicPath": "/", @@ -1014,7 +923,6 @@ Object { exports[`createConfig port option (same) (undefined) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": undefined, "publicPath": "/", @@ -1028,7 +936,6 @@ Object { exports[`createConfig port option (same) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 9090, "publicPath": "/", @@ -1042,7 +949,6 @@ Object { exports[`createConfig profile option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "profile": "profile", @@ -1057,7 +963,6 @@ Object { exports[`createConfig progress option (devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "progress": true, @@ -1072,7 +977,6 @@ Object { exports[`createConfig progress option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "progress": true, @@ -1087,7 +991,6 @@ Object { exports[`createConfig public option (devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "public": true, @@ -1102,7 +1005,6 @@ Object { exports[`createConfig public option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "public": true, @@ -1117,7 +1019,6 @@ Object { exports[`createConfig publicPath option (not specify) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1131,7 +1032,6 @@ Object { exports[`createConfig publicPath option (path in devServer option) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/assets/", @@ -1145,7 +1045,6 @@ Object { exports[`createConfig publicPath option (path in output option) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/assets/", @@ -1159,7 +1058,6 @@ Object { exports[`createConfig publicPath option (path without starting slash in output option) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/assets/", @@ -1173,7 +1071,6 @@ Object { exports[`createConfig publicPath option (url in devServer option) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "http://localhost:8080/assets/", @@ -1187,7 +1084,6 @@ Object { exports[`createConfig publicPath option (url in output option) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "http://localhost:8080/assets/", @@ -1201,7 +1097,6 @@ Object { exports[`createConfig quiet option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1216,7 +1111,6 @@ Object { exports[`createConfig quiet option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1231,7 +1125,6 @@ Object { exports[`createConfig simple 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1245,7 +1138,6 @@ Object { exports[`createConfig sockHost option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1260,7 +1152,6 @@ Object { exports[`createConfig sockPath option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1275,7 +1166,6 @@ Object { exports[`createConfig sockPort option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1290,7 +1180,6 @@ Object { exports[`createConfig socket option (devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1305,7 +1194,6 @@ Object { exports[`createConfig socket option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1320,7 +1208,6 @@ Object { exports[`createConfig stats option (colors) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1334,7 +1221,6 @@ Object { exports[`createConfig stats option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1352,7 +1238,6 @@ Object { "historyApiFallback": "_historyApiFallback", "host": "_foo", "hot": "_hot", - "hotOnly": "_hotOnly", "https": "_https", "inline": "_inline", "lazy": "_lazy", @@ -1385,7 +1270,6 @@ Object { "historyApiFallback": "_historyApiFallback", "host": "_foo", "hot": "_hot", - "hotOnly": "_hotOnly", "https": "_https", "inline": "_inline", "lazy": "_lazy", @@ -1416,7 +1300,6 @@ Object { exports[`createConfig useLocalIp option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1431,7 +1314,6 @@ Object { exports[`createConfig useLocalIp option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1446,7 +1328,6 @@ Object { exports[`createConfig watchContentBase option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1461,7 +1342,6 @@ Object { exports[`createConfig watchContentBase option 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1476,7 +1356,6 @@ Object { exports[`createConfig watchOptions option (in devServer config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", @@ -1493,7 +1372,6 @@ Object { exports[`createConfig watchOptions option (in output config) 1`] = ` Object { "hot": true, - "hotOnly": false, "noInfo": true, "port": 8080, "publicPath": "/", diff --git a/test/server/utils/addEntries.test.js b/test/server/utils/addEntries.test.js index a5a375da2a..ffb577d12c 100644 --- a/test/server/utils/addEntries.test.js +++ b/test/server/utils/addEntries.test.js @@ -162,7 +162,7 @@ describe('addEntries util', () => { }); const devServerOptions = { - hotOnly: true, + hot: 'only', }; addEntries(webpackOptions, devServerOptions); @@ -223,7 +223,7 @@ describe('addEntries util', () => { it('should adds the HMR plugin if hot-only', () => { const webpackOptions = Object.assign({}, config); - const devServerOptions = { hotOnly: true }; + const devServerOptions = { hot: 'only' }; addEntries(webpackOptions, devServerOptions); diff --git a/test/server/utils/createConfig.test.js b/test/server/utils/createConfig.test.js index 7734250737..0b519c2bfc 100644 --- a/test/server/utils/createConfig.test.js +++ b/test/server/utils/createConfig.test.js @@ -9,8 +9,6 @@ const argv = { port: 8080, // Can be `--no-hot` in CLI (undocumented) hot: true, - // Can be `--no-hot-only` in CLI (misleading and undocumented) - hotOnly: false, }; describe('createConfig', () => { @@ -358,28 +356,6 @@ describe('createConfig', () => { expect(config).toMatchSnapshot(); }); - it('hotOnly option', () => { - const config = createConfig( - webpackConfig, - Object.assign({}, argv, { hotOnly: true }), - { port: 8080 } - ); - - expect(config).toMatchSnapshot(); - }); - - it('hotOnly option (in devServer config)', () => { - const config = createConfig( - Object.assign({}, webpackConfig, { - devServer: { hotOnly: true }, - }), - argv, - { port: 8080 } - ); - - expect(config).toMatchSnapshot(); - }); - it('clientLogLevel option', () => { const config = createConfig( webpackConfig, From 0c744470a4d3364af1cf0af8dfe2ddf2d293e476 Mon Sep 17 00:00:00 2001 From: Yuta Hiroto Date: Tue, 28 Apr 2020 23:31:23 +0900 Subject: [PATCH 3/5] test: fix e2e/client --- test/e2e/Client.test.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/e2e/Client.test.js b/test/e2e/Client.test.js index 620743e8e8..ca5dc5e249 100644 --- a/test/e2e/Client.test.js +++ b/test/e2e/Client.test.js @@ -106,15 +106,18 @@ describe('reload', () => { const bgColor = getComputedStyle(body)[ 'background-color' ]; + return bgColor; }) .then((color2) => { - browser.close().then(() => { - expect(color).toEqual('rgb(0, 0, 255)'); - expect(color2).toEqual('rgb(255, 0, 0)'); - expect(refreshed).toEqual(mode.shouldRefresh); - done(); - }); + expect(color).toEqual('rgb(0, 0, 255)'); + expect(color2).toEqual('rgb(255, 0, 0)'); + expect(refreshed).toEqual(mode.shouldRefresh); + + return browser.close(); + }) + .then(() => { + done(); }); }); }); From d627b887e4267ea8f58ba7a96fda8c56385385cc Mon Sep 17 00:00:00 2001 From: Yuta Hiroto Date: Tue, 28 Apr 2020 23:49:05 +0900 Subject: [PATCH 4/5] fix(client): set hot:false as a default --- client-src/default/index.js | 3 ++- test/client/__snapshots__/index.test.js.snap | 2 +- test/e2e/TransportMode.test.js | 10 ++++++++++ test/helpers/isWebpack5.js | 9 +++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 test/helpers/isWebpack5.js diff --git a/client-src/default/index.js b/client-src/default/index.js index cde1dd1dbe..dede6f0763 100644 --- a/client-src/default/index.js +++ b/client-src/default/index.js @@ -15,7 +15,7 @@ const status = { currentHash: '', }; const options = { - hot: true, + hot: false, hotReload: true, liveReload: false, initial: true, @@ -36,6 +36,7 @@ if (typeof window !== 'undefined') { const onSocketMessage = { hot() { + options.hot = true; log.info('[WDS] Hot Module Replacement enabled.'); }, liveReload() { diff --git a/test/client/__snapshots__/index.test.js.snap b/test/client/__snapshots__/index.test.js.snap index 575f85c19b..cc267a2ce7 100644 --- a/test/client/__snapshots__/index.test.js.snap +++ b/test/client/__snapshots__/index.test.js.snap @@ -36,7 +36,7 @@ exports[`index should run onSocketMessage.ok 1`] = `"Ok"`; exports[`index should run onSocketMessage.ok 2`] = ` Object { - "hot": true, + "hot": false, "hotReload": true, "initial": false, "liveReload": false, diff --git a/test/e2e/TransportMode.test.js b/test/e2e/TransportMode.test.js index 8b9ec973c3..1058e0292d 100644 --- a/test/e2e/TransportMode.test.js +++ b/test/e2e/TransportMode.test.js @@ -8,6 +8,7 @@ const { initConsoleDelay, awaitServerCloseDelay, } = require('../helpers/puppeteer-constants'); +const isWebpack5 = require('../helpers/isWebpack5'); describe('transportMode client', () => { const modes = [ @@ -77,7 +78,16 @@ describe('transportMode client', () => { res.splice(i, 1); } } + + // TODO: delete this code when getting rid of webpack5 + if (isWebpack5) { + const swap = res[0]; + res[0] = res[1]; + res[1] = swap; + } + expect(res).toMatchSnapshot(); + done(); }); }); diff --git a/test/helpers/isWebpack5.js b/test/helpers/isWebpack5.js new file mode 100644 index 0000000000..8225dc5bb3 --- /dev/null +++ b/test/helpers/isWebpack5.js @@ -0,0 +1,9 @@ +'use strict'; + +const webpack = require('webpack'); + +function isWebpack() { + return webpack.version[0] === '5'; +} + +module.exports = isWebpack; From 1ce649cf7d77f65427af8827e41b8471fc082d7c Mon Sep 17 00:00:00 2001 From: Yuta Hiroto Date: Wed, 29 Apr 2020 00:32:33 +0900 Subject: [PATCH 5/5] test: update --- lib/Server.js | 2 +- lib/utils/updateCompiler.js | 2 +- test/e2e/TransportMode.test.js | 13 +++---------- test/e2e/__snapshots__/TransportMode.test.js.snap | 7 ------- test/helpers/isWebpack5.js | 9 --------- 5 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 test/helpers/isWebpack5.js diff --git a/lib/Server.js b/lib/Server.js index f3cb987563..37cdd61f17 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -737,7 +737,7 @@ class Server { this.sockWrite([connection], 'log-level', this.clientLogLevel); } - if (this.options.hot) { + if (this.options.hot === true || this.options.hot === 'only') { this.sockWrite([connection], 'hot'); } diff --git a/lib/utils/updateCompiler.js b/lib/utils/updateCompiler.js index d093ffba24..6be78efee9 100644 --- a/lib/utils/updateCompiler.js +++ b/lib/utils/updateCompiler.js @@ -57,7 +57,7 @@ function updateCompiler(compiler, options) { }); // do not apply the plugin unless it didn't exist before. - if (options.hot || options.hot === 'only') { + if (options.hot === true || options.hot === 'only') { compilersWithoutHMR.forEach((compiler) => { // addDevServerEntrypoints above should have added the plugin // to the compiler options diff --git a/test/e2e/TransportMode.test.js b/test/e2e/TransportMode.test.js index 1058e0292d..f3a13dbb31 100644 --- a/test/e2e/TransportMode.test.js +++ b/test/e2e/TransportMode.test.js @@ -8,25 +8,27 @@ const { initConsoleDelay, awaitServerCloseDelay, } = require('../helpers/puppeteer-constants'); -const isWebpack5 = require('../helpers/isWebpack5'); describe('transportMode client', () => { const modes = [ { title: 'sockjs', options: { + hot: false, transportMode: 'sockjs', }, }, { title: 'ws', options: { + hot: false, transportMode: 'ws', }, }, { title: 'custom client', options: { + hot: false, transportMode: { server: 'sockjs', client: require.resolve( @@ -78,16 +80,7 @@ describe('transportMode client', () => { res.splice(i, 1); } } - - // TODO: delete this code when getting rid of webpack5 - if (isWebpack5) { - const swap = res[0]; - res[0] = res[1]; - res[1] = swap; - } - expect(res).toMatchSnapshot(); - done(); }); }); diff --git a/test/e2e/__snapshots__/TransportMode.test.js.snap b/test/e2e/__snapshots__/TransportMode.test.js.snap index f519cfd19a..b3c92fa7fd 100644 --- a/test/e2e/__snapshots__/TransportMode.test.js.snap +++ b/test/e2e/__snapshots__/TransportMode.test.js.snap @@ -2,11 +2,8 @@ exports[`transportMode client custom client on browser client logs correctly 1`] = ` Array [ - "[HMR] Waiting for update signal from WDS...", "Hey.", "open", - "hot", - "[WDS] Hot Module Replacement enabled.", "liveReload", "[WDS] Live Reloading enabled.", "hash", @@ -18,9 +15,7 @@ Array [ exports[`transportMode client sockjs on browser client logs correctly 1`] = ` Array [ - "[HMR] Waiting for update signal from WDS...", "Hey.", - "[WDS] Hot Module Replacement enabled.", "[WDS] Live Reloading enabled.", "[WDS] Disconnected!", ] @@ -28,9 +23,7 @@ Array [ exports[`transportMode client ws on browser client logs correctly 1`] = ` Array [ - "[HMR] Waiting for update signal from WDS...", "Hey.", - "[WDS] Hot Module Replacement enabled.", "[WDS] Live Reloading enabled.", "[WDS] Disconnected!", ] diff --git a/test/helpers/isWebpack5.js b/test/helpers/isWebpack5.js deleted file mode 100644 index 8225dc5bb3..0000000000 --- a/test/helpers/isWebpack5.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -const webpack = require('webpack'); - -function isWebpack() { - return webpack.version[0] === '5'; -} - -module.exports = isWebpack;