Skip to content

Commit

Permalink
chore(deps): upgrade some deps (#2542)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hiroppy authored and alexander-akait committed May 8, 2020
1 parent fb79bb5 commit 77af842
Show file tree
Hide file tree
Showing 46 changed files with 10,315 additions and 7,715 deletions.
9 changes: 0 additions & 9 deletions azure-pipelines.yml
Expand Up @@ -52,9 +52,6 @@ jobs:
node-10:
node_version: ^10.13.0
webpack_version: latest
node-8:
node_version: ^8.9.0
webpack_version: latest
node-10-canary:
node_version: ^10.13.0
webpack_version: next
Expand Down Expand Up @@ -108,9 +105,6 @@ jobs:
node-10:
node_version: ^10.13.0
webpack_version: latest
node-8:
node_version: ^8.9.0
webpack_version: latest
node-10-canary:
node_version: ^10.13.0
webpack_version: next
Expand Down Expand Up @@ -164,9 +158,6 @@ jobs:
node-10:
node_version: ^10.13.0
webpack_version: latest
node-8:
node_version: ^8.9.0
webpack_version: latest
node-10-canary:
node_version: ^10.13.0
webpack_version: next
Expand Down
5 changes: 0 additions & 5 deletions bin/cli-flags.js
Expand Up @@ -14,11 +14,6 @@ module.exports = {
type: Boolean,
describe: 'Broadcasts the server via ZeroConf networking on start',
},
{
name: 'lazy',
type: Boolean,
describe: 'Lazy',
},
{
name: 'liveReload',
type: Boolean,
Expand Down
4 changes: 0 additions & 4 deletions bin/options.js
Expand Up @@ -16,10 +16,6 @@ const options = {
type: 'boolean',
describe: 'Broadcasts the server via ZeroConf networking on start',
},
lazy: {
type: 'boolean',
describe: 'Lazy',
},
liveReload: {
type: 'boolean',
describe: 'Enables/Disables live reloading on changing files',
Expand Down
8 changes: 3 additions & 5 deletions client-src/default/overlay.js
Expand Up @@ -113,11 +113,9 @@ function clear() {
function showMessage(messages) {
ensureOverlayDivExists((div) => {
// Make it look similar to our terminal.
div.innerHTML = `<span style="color: #${
colors.red
}">Failed to compile.</span><br><br>${ansiHTML(
entities.encode(messages[0])
)}`;
const text = ansiHTML(entities.encode(messages[0]));

div.innerHTML = `<span style="color: #${colors.red}">Failed to compile.</span><br><br>${text}`;
});
}

Expand Down
19 changes: 0 additions & 19 deletions examples/cli/lazy/README.md

This file was deleted.

12 changes: 0 additions & 12 deletions examples/cli/lazy/app.js

This file was deleted.

10 changes: 0 additions & 10 deletions examples/cli/lazy/webpack.config.js

This file was deleted.

29 changes: 14 additions & 15 deletions lib/Server.js
Expand Up @@ -16,7 +16,7 @@ const semver = require('semver');
const killable = require('killable');
const chokidar = require('chokidar');
const express = require('express');
const httpProxyMiddleware = require('http-proxy-middleware');
const { createProxyMiddleware } = require('http-proxy-middleware');
const historyApiFallback = require('connect-history-api-fallback');
const compress = require('compression');
const serveIndex = require('serve-index');
Expand Down Expand Up @@ -50,10 +50,6 @@ if (!process.env.WEBPACK_DEV_SERVER) {

class Server {
constructor(compiler, options = {}, _log) {
if (options.lazy && !options.filename) {
throw new Error("'filename' option must be set in lazy mode.");
}

validateOptions(schema, options, 'webpack Dev Server');

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

normalizeOptions(this.compiler, this.options);

// don't move this position because addEntries called by updateCompiler checks this.options.hot|hotOnly
this.options.hot =
typeof this.options.hot === 'boolean' || this.options.hot === 'only'
? this.options.hot
: true;

updateCompiler(this.compiler, this.options);

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

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

Expand Down Expand Up @@ -131,7 +132,7 @@ class Server {

// Proxy websockets without the initial http request
// https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade
this.websocketProxies.forEach(function(wsProxy) {
this.websocketProxies.forEach(function (wsProxy) {
this.listeningApp.on('upgrade', wsProxy.upgrade);
}, this);
}
Expand Down Expand Up @@ -259,7 +260,7 @@ class Server {
// It is possible to use the `bypass` method without a `target`.
// However, the proxy middleware has no use in this case, and will fail to instantiate.
if (proxyConfig.target) {
return httpProxyMiddleware(context, proxyConfig);
return createProxyMiddleware(context, proxyConfig);
}
};
/**
Expand Down Expand Up @@ -387,8 +388,9 @@ class Server {
// Redirect every request to the port contentBase
this.app.get('*', (req, res) => {
res.writeHead(302, {
Location: `//localhost:${contentBase}${req.path}${req._parsedUrl
.search || ''}`,
Location: `//localhost:${contentBase}${req.path}${
req._parsedUrl.search || ''
}`,
});

res.end();
Expand Down Expand Up @@ -731,7 +733,7 @@ class Server {
this.sockWrite([connection], 'log-level', this.clientLogLevel);
}

if (this.hot) {
if (this.options.hot === true || this.options.hot === 'only') {
this.sockWrite([connection], 'hot');
}

Expand All @@ -757,10 +759,7 @@ class Server {
}

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

status(
Expand Down
33 changes: 9 additions & 24 deletions lib/options.json
Expand Up @@ -94,19 +94,6 @@
"type": "string"
}
},
"filename": {
"anyOf": [
{
"type": "string"
},
{
"instanceof": "RegExp"
},
{
"instanceof": "Function"
}
]
},
"fs": {
"type": "object"
},
Expand Down Expand Up @@ -134,10 +121,14 @@
]
},
"hot": {
"type": "boolean"
},
"hotOnly": {
"type": "boolean"
"anyOf": [
{
"type": "boolean"
},
{
"enum": ["only"]
}
]
},
"http2": {
"type": "boolean"
Expand Down Expand Up @@ -188,9 +179,6 @@
}
]
},
"lazy": {
"type": "boolean"
},
"liveReload": {
"type": "boolean"
},
Expand Down Expand Up @@ -441,21 +429,18 @@
"contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)",
"disableHostCheck": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck)",
"features": "should be {Array}",
"filename": "should be {String|RegExp|Function} (https://webpack.js.org/configuration/dev-server/#devserverfilename-)",
"fs": "should be {Object} (https://github.com/webpack/webpack-dev-middleware#fs)",
"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)",
"injectClient": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjectclient)",
"injectHot": "should be {Boolean|Function} (https://webpack.js.org/configuration/dev-server/#devserverinjecthot)",
"inline": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverinline)",
"key": "should be {String|Buffer}",
"lazy": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverlazy-)",
"liveReload": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverlivereload-)",
"log": "should be {Function}",
"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)",
Expand Down
2 changes: 1 addition & 1 deletion lib/servers/SockJSServer.js
Expand Up @@ -13,7 +13,7 @@ const BaseServer = require('./BaseServer');
{
const SockjsSession = require('sockjs/lib/transport').Session;
const decorateConnection = SockjsSession.prototype.decorateConnection;
SockjsSession.prototype.decorateConnection = function(req) {
SockjsSession.prototype.decorateConnection = function (req) {
decorateConnection.call(this, req);
const connection = this.connection;
if (
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/addEntries.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 0 additions & 14 deletions lib/utils/createConfig.js
Expand Up @@ -72,10 +72,6 @@ function createConfig(config, argv, { port }) {
}
}

if (!options.filename && firstWpOpt.output && firstWpOpt.output.filename) {
options.filename = firstWpOpt.output && firstWpOpt.output.filename;
}

if (!options.watchOptions && firstWpOpt.watchOptions) {
options.watchOptions = firstWpOpt.watchOptions;
}
Expand All @@ -95,12 +91,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) {
Expand Down Expand Up @@ -143,10 +133,6 @@ function createConfig(config, argv, { port }) {
options.stats = Object.assign({}, options.stats, { colors: argv.color });
}

if (argv.lazy) {
options.lazy = true;
}

// TODO remove in `v4`
if (!argv.info) {
options.noInfo = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/updateCompiler.js
Expand Up @@ -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 === true || options.hot === 'only') {
compilersWithoutHMR.forEach((compiler) => {
// addDevServerEntrypoints above should have added the plugin
// to the compiler options
Expand Down

0 comments on commit 77af842

Please sign in to comment.