Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): upgrade some deps #2542

Merged
merged 9 commits into from Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I like this change to the hot option because webpack core CLI also has --hot boolean flag (https://webpack.js.org/api/cli/) and I don't think it's great for usage of a flag of the same name to diverge. This will be annoying to deal with on the webpack-cli serve side, since we parse the webpack flags, then pass any unknown flags along to the dev server. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Loonride we should implement hot: only on webpack-cli side too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main problem is that we already have a lot of options and setting up everything is terribly complicated and redundant, we must simplify everything as much as possible

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And in some edge cases it is normal what package have same arguments but with many values

}
]
},
"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