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 8 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
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
20 changes: 13 additions & 7 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 @@ -69,6 +69,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 +92,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 +136,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 +264,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 +392,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 +737,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 Down
15 changes: 9 additions & 6 deletions lib/options.json
Expand Up @@ -134,10 +134,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 @@ -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)",
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
6 changes: 0 additions & 6 deletions lib/utils/createConfig.js
Expand Up @@ -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) {
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