Skip to content

Commit 77af842

Browse files
hiroppyalexander-akait
authored andcommitted
chore(deps): upgrade some deps (#2542)
* chore(deps): upgrade deps * style: run prettier * test: update * ci: remove Node@8 * test(cli): add windows support * chore(deps): downgrade puppeteer * chore(deps): downgrade some deps * fix(hot): enable hot option as default (#2546) BREAKING CHANGE: the `hot` option is `true` by default, the `hotOnly` option was removed in favor `{ hot: 'only' }` * fix: remove lazy and filename options (#2544) BREAKING CHANGE: `lazy` and `filename` options was removed
1 parent fb79bb5 commit 77af842

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+10315
-7715
lines changed

azure-pipelines.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ jobs:
5252
node-10:
5353
node_version: ^10.13.0
5454
webpack_version: latest
55-
node-8:
56-
node_version: ^8.9.0
57-
webpack_version: latest
5855
node-10-canary:
5956
node_version: ^10.13.0
6057
webpack_version: next
@@ -108,9 +105,6 @@ jobs:
108105
node-10:
109106
node_version: ^10.13.0
110107
webpack_version: latest
111-
node-8:
112-
node_version: ^8.9.0
113-
webpack_version: latest
114108
node-10-canary:
115109
node_version: ^10.13.0
116110
webpack_version: next
@@ -164,9 +158,6 @@ jobs:
164158
node-10:
165159
node_version: ^10.13.0
166160
webpack_version: latest
167-
node-8:
168-
node_version: ^8.9.0
169-
webpack_version: latest
170161
node-10-canary:
171162
node_version: ^10.13.0
172163
webpack_version: next

bin/cli-flags.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ module.exports = {
1414
type: Boolean,
1515
describe: 'Broadcasts the server via ZeroConf networking on start',
1616
},
17-
{
18-
name: 'lazy',
19-
type: Boolean,
20-
describe: 'Lazy',
21-
},
2217
{
2318
name: 'liveReload',
2419
type: Boolean,

bin/options.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ const options = {
1616
type: 'boolean',
1717
describe: 'Broadcasts the server via ZeroConf networking on start',
1818
},
19-
lazy: {
20-
type: 'boolean',
21-
describe: 'Lazy',
22-
},
2319
liveReload: {
2420
type: 'boolean',
2521
describe: 'Enables/Disables live reloading on changing files',

client-src/default/overlay.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,9 @@ function clear() {
113113
function showMessage(messages) {
114114
ensureOverlayDivExists((div) => {
115115
// Make it look similar to our terminal.
116-
div.innerHTML = `<span style="color: #${
117-
colors.red
118-
}">Failed to compile.</span><br><br>${ansiHTML(
119-
entities.encode(messages[0])
120-
)}`;
116+
const text = ansiHTML(entities.encode(messages[0]));
117+
118+
div.innerHTML = `<span style="color: #${colors.red}">Failed to compile.</span><br><br>${text}`;
121119
});
122120
}
123121

examples/cli/lazy/README.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/cli/lazy/app.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/cli/lazy/webpack.config.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/Server.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const semver = require('semver');
1616
const killable = require('killable');
1717
const chokidar = require('chokidar');
1818
const express = require('express');
19-
const httpProxyMiddleware = require('http-proxy-middleware');
19+
const { createProxyMiddleware } = require('http-proxy-middleware');
2020
const historyApiFallback = require('connect-history-api-fallback');
2121
const compress = require('compression');
2222
const serveIndex = require('serve-index');
@@ -50,10 +50,6 @@ if (!process.env.WEBPACK_DEV_SERVER) {
5050

5151
class Server {
5252
constructor(compiler, options = {}, _log) {
53-
if (options.lazy && !options.filename) {
54-
throw new Error("'filename' option must be set in lazy mode.");
55-
}
56-
5753
validateOptions(schema, options, 'webpack Dev Server');
5854

5955
this.compiler = compiler;
@@ -69,6 +65,12 @@ class Server {
6965

7066
normalizeOptions(this.compiler, this.options);
7167

68+
// don't move this position because addEntries called by updateCompiler checks this.options.hot|hotOnly
69+
this.options.hot =
70+
typeof this.options.hot === 'boolean' || this.options.hot === 'only'
71+
? this.options.hot
72+
: true;
73+
7274
updateCompiler(this.compiler, this.options);
7375

7476
this.heartbeatInterval = 30000;
@@ -86,7 +88,6 @@ class Server {
8688
this.contentBaseWatchers = [];
8789

8890
// TODO this.<property> is deprecated (remove them in next major release.) in favor this.options.<property>
89-
this.hot = this.options.hot || this.options.hotOnly;
9091
this.headers = this.options.headers;
9192
this.progress = this.options.progress;
9293

@@ -131,7 +132,7 @@ class Server {
131132

132133
// Proxy websockets without the initial http request
133134
// https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade
134-
this.websocketProxies.forEach(function(wsProxy) {
135+
this.websocketProxies.forEach(function (wsProxy) {
135136
this.listeningApp.on('upgrade', wsProxy.upgrade);
136137
}, this);
137138
}
@@ -259,7 +260,7 @@ class Server {
259260
// It is possible to use the `bypass` method without a `target`.
260261
// However, the proxy middleware has no use in this case, and will fail to instantiate.
261262
if (proxyConfig.target) {
262-
return httpProxyMiddleware(context, proxyConfig);
263+
return createProxyMiddleware(context, proxyConfig);
263264
}
264265
};
265266
/**
@@ -387,8 +388,9 @@ class Server {
387388
// Redirect every request to the port contentBase
388389
this.app.get('*', (req, res) => {
389390
res.writeHead(302, {
390-
Location: `//localhost:${contentBase}${req.path}${req._parsedUrl
391-
.search || ''}`,
391+
Location: `//localhost:${contentBase}${req.path}${
392+
req._parsedUrl.search || ''
393+
}`,
392394
});
393395

394396
res.end();
@@ -731,7 +733,7 @@ class Server {
731733
this.sockWrite([connection], 'log-level', this.clientLogLevel);
732734
}
733735

734-
if (this.hot) {
736+
if (this.options.hot === true || this.options.hot === 'only') {
735737
this.sockWrite([connection], 'hot');
736738
}
737739

@@ -757,10 +759,7 @@ class Server {
757759
}
758760

759761
showStatus() {
760-
const suffix =
761-
this.options.inline !== false || this.options.lazy === true
762-
? '/'
763-
: '/webpack-dev-server/';
762+
const suffix = this.options.inline !== false ? '/' : '/webpack-dev-server/';
764763
const uri = `${createDomain(this.options, this.listeningApp)}${suffix}`;
765764

766765
status(

lib/options.json

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,6 @@
9494
"type": "string"
9595
}
9696
},
97-
"filename": {
98-
"anyOf": [
99-
{
100-
"type": "string"
101-
},
102-
{
103-
"instanceof": "RegExp"
104-
},
105-
{
106-
"instanceof": "Function"
107-
}
108-
]
109-
},
11097
"fs": {
11198
"type": "object"
11299
},
@@ -134,10 +121,14 @@
134121
]
135122
},
136123
"hot": {
137-
"type": "boolean"
138-
},
139-
"hotOnly": {
140-
"type": "boolean"
124+
"anyOf": [
125+
{
126+
"type": "boolean"
127+
},
128+
{
129+
"enum": ["only"]
130+
}
131+
]
141132
},
142133
"http2": {
143134
"type": "boolean"
@@ -188,9 +179,6 @@
188179
}
189180
]
190181
},
191-
"lazy": {
192-
"type": "boolean"
193-
},
194182
"liveReload": {
195183
"type": "boolean"
196184
},
@@ -441,21 +429,18 @@
441429
"contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)",
442430
"disableHostCheck": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck)",
443431
"features": "should be {Array}",
444-
"filename": "should be {String|RegExp|Function} (https://webpack.js.org/configuration/dev-server/#devserverfilename-)",
445432
"fs": "should be {Object} (https://github.com/webpack/webpack-dev-middleware#fs)",
446433
"headers": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverheaders-)",
447434
"historyApiFallback": "should be {Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserverhistoryapifallback)",
448435
"host": "should be {String|Null} (https://webpack.js.org/configuration/dev-server/#devserverhost)",
449-
"hot": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhot)",
450-
"hotOnly": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhotonly)",
436+
"hot": "should be {Boolean|String} (https://webpack.js.org/configuration/dev-server/#devserverhot)",
451437
"http2": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhttp2)",
452438
"https": "should be {Object|Boolean} (https://webpack.js.org/configuration/dev-server/#devserverhttps)",
453439
"index": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverindex)",
454440
"injectClient": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjectclient)",
455441
"injectHot": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjecthot)",
456442
"inline": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverinline)",
457443
"key": "should be {String|Buffer}",
458-
"lazy": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverlazy-)",
459444
"liveReload": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverlivereload-)",
460445
"log": "should be {Function}",
461446
"logLevel": "should be {String} and equal to one of the allowed values\n\n [ 'info', 'warn', 'error', 'debug', 'trace', 'silent' ]\n\n (https://github.com/webpack/webpack-dev-middleware#loglevel)",

lib/servers/SockJSServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const BaseServer = require('./BaseServer');
1313
{
1414
const SockjsSession = require('sockjs/lib/transport').Session;
1515
const decorateConnection = SockjsSession.prototype.decorateConnection;
16-
SockjsSession.prototype.decorateConnection = function(req) {
16+
SockjsSession.prototype.decorateConnection = function (req) {
1717
decorateConnection.call(this, req);
1818
const connection = this.connection;
1919
if (

lib/utils/addEntries.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function addEntries(config, options, server) {
4343
/** @type {(string[] | string)} */
4444
let hotEntry;
4545

46-
if (options.hotOnly) {
46+
if (options.hot === 'only') {
4747
hotEntry = require.resolve('webpack/hot/only-dev-server');
4848
} else if (options.hot) {
4949
hotEntry = require.resolve('webpack/hot/dev-server');
@@ -141,7 +141,7 @@ function addEntries(config, options, server) {
141141

142142
config.entry = prependEntry(config.entry || './src', additionalEntries);
143143

144-
if (options.hot || options.hotOnly) {
144+
if (options.hot || options.hot === 'only') {
145145
config.plugins = config.plugins || [];
146146
if (
147147
!config.plugins.find(

lib/utils/createConfig.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ function createConfig(config, argv, { port }) {
7272
}
7373
}
7474

75-
if (!options.filename && firstWpOpt.output && firstWpOpt.output.filename) {
76-
options.filename = firstWpOpt.output && firstWpOpt.output.filename;
77-
}
78-
7975
if (!options.watchOptions && firstWpOpt.watchOptions) {
8076
options.watchOptions = firstWpOpt.watchOptions;
8177
}
@@ -95,12 +91,6 @@ function createConfig(config, argv, { port }) {
9591
options.hot = argv.hot;
9692
}
9793

98-
// TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
99-
// We should prefer CLI arg under config, now we always prefer `hotOnly` from `devServer`
100-
if (!options.hotOnly) {
101-
options.hotOnly = argv.hotOnly;
102-
}
103-
10494
// TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
10595
// We should prefer CLI arg under config, now we always prefer `clientLogLevel` from `devServer`
10696
if (!options.clientLogLevel && argv.clientLogLevel) {
@@ -143,10 +133,6 @@ function createConfig(config, argv, { port }) {
143133
options.stats = Object.assign({}, options.stats, { colors: argv.color });
144134
}
145135

146-
if (argv.lazy) {
147-
options.lazy = true;
148-
}
149-
150136
// TODO remove in `v4`
151137
if (!argv.info) {
152138
options.noInfo = true;

lib/utils/updateCompiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function updateCompiler(compiler, options) {
5757
});
5858

5959
// do not apply the plugin unless it didn't exist before.
60-
if (options.hot || options.hotOnly) {
60+
if (options.hot === true || options.hot === 'only') {
6161
compilersWithoutHMR.forEach((compiler) => {
6262
// addDevServerEntrypoints above should have added the plugin
6363
// to the compiler options

0 commit comments

Comments
 (0)