webpack-dev-server 4.9.3 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/index.js +40 -6
- package/client/utils/log.js +36 -1
- package/lib/Server.js +47 -0
- package/package.json +1 -1
- package/types/lib/Server.d.ts +31 -33
package/client/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
1
7
|
/* global __resourceQuery, __webpack_hash__ */
|
|
2
8
|
/// <reference types="webpack/module" />
|
|
3
9
|
import webpackHotLog from "webpack/hot/log.js";
|
|
@@ -5,7 +11,7 @@ import stripAnsi from "./utils/stripAnsi.js";
|
|
|
5
11
|
import parseURL from "./utils/parseURL.js";
|
|
6
12
|
import socket from "./socket.js";
|
|
7
13
|
import { formatProblem, show, hide } from "./overlay.js";
|
|
8
|
-
import { log, setLogLevel } from "./utils/log.js";
|
|
14
|
+
import { log, logEnabledFeatures, setLogLevel } from "./utils/log.js";
|
|
9
15
|
import sendMessage from "./utils/sendMessage.js";
|
|
10
16
|
import reloadApp from "./utils/reloadApp.js";
|
|
11
17
|
import createSocketURL from "./utils/createSocketURL.js";
|
|
@@ -45,15 +51,44 @@ var options = {
|
|
|
45
51
|
overlay: false
|
|
46
52
|
};
|
|
47
53
|
var parsedResourceQuery = parseURL(__resourceQuery);
|
|
54
|
+
var enabledFeatures = {
|
|
55
|
+
"Hot Module Replacement": false,
|
|
56
|
+
"Live Reloading": false,
|
|
57
|
+
Progress: false,
|
|
58
|
+
Overlay: false
|
|
59
|
+
};
|
|
48
60
|
|
|
49
61
|
if (parsedResourceQuery.hot === "true") {
|
|
50
62
|
options.hot = true;
|
|
51
|
-
|
|
63
|
+
enabledFeatures["Hot Module Replacement"] = true;
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
if (parsedResourceQuery["live-reload"] === "true") {
|
|
55
67
|
options.liveReload = true;
|
|
56
|
-
|
|
68
|
+
enabledFeatures["Live Reloading"] = true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (parsedResourceQuery.progress === "true") {
|
|
72
|
+
options.progress = true;
|
|
73
|
+
enabledFeatures.Progress = true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (parsedResourceQuery.overlay) {
|
|
77
|
+
try {
|
|
78
|
+
options.overlay = JSON.parse(parsedResourceQuery.overlay);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
log.error("Error parsing overlay options from resource query:", e);
|
|
81
|
+
} // Fill in default "true" params for partially-specified objects.
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if (typeof options.overlay === "object") {
|
|
85
|
+
options.overlay = _objectSpread({
|
|
86
|
+
errors: true,
|
|
87
|
+
warnings: true
|
|
88
|
+
}, options.overlay);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
enabledFeatures.Overlay = true;
|
|
57
92
|
}
|
|
58
93
|
|
|
59
94
|
if (parsedResourceQuery.logging) {
|
|
@@ -63,11 +98,12 @@ if (parsedResourceQuery.logging) {
|
|
|
63
98
|
if (typeof parsedResourceQuery.reconnect !== "undefined") {
|
|
64
99
|
options.reconnect = Number(parsedResourceQuery.reconnect);
|
|
65
100
|
}
|
|
101
|
+
|
|
102
|
+
logEnabledFeatures(enabledFeatures);
|
|
66
103
|
/**
|
|
67
104
|
* @param {string} level
|
|
68
105
|
*/
|
|
69
106
|
|
|
70
|
-
|
|
71
107
|
function setAllLogLevel(level) {
|
|
72
108
|
// This is needed because the HMR logger operate separately from dev server logger
|
|
73
109
|
webpackHotLog.setLogLevel(level === "verbose" || level === "log" ? "info" : level);
|
|
@@ -88,7 +124,6 @@ var onSocketMessage = {
|
|
|
88
124
|
}
|
|
89
125
|
|
|
90
126
|
options.hot = true;
|
|
91
|
-
log.info("Hot Module Replacement enabled.");
|
|
92
127
|
},
|
|
93
128
|
liveReload: function liveReload() {
|
|
94
129
|
if (parsedResourceQuery["live-reload"] === "false") {
|
|
@@ -96,7 +131,6 @@ var onSocketMessage = {
|
|
|
96
131
|
}
|
|
97
132
|
|
|
98
133
|
options.liveReload = true;
|
|
99
|
-
log.info("Live Reloading enabled.");
|
|
100
134
|
},
|
|
101
135
|
invalid: function invalid() {
|
|
102
136
|
log.info("App updated. Recompiling..."); // Fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
|
package/client/utils/log.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
+
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
1
13
|
import logger from "../modules/logger/index.js";
|
|
2
14
|
var name = "webpack-dev-server"; // default level is set on the client side, so it does not need
|
|
3
15
|
// to be set by the CLI or API
|
|
@@ -17,4 +29,27 @@ function setLogLevel(level) {
|
|
|
17
29
|
|
|
18
30
|
setLogLevel(defaultLevel);
|
|
19
31
|
var log = logger.getLogger(name);
|
|
20
|
-
|
|
32
|
+
|
|
33
|
+
var logEnabledFeatures = function logEnabledFeatures(features) {
|
|
34
|
+
var enabledFeatures = Object.entries(features);
|
|
35
|
+
|
|
36
|
+
if (!features || enabledFeatures.length === 0) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var logString = "Server started:"; // Server started: Hot Module Replacement enabled, Live Reloading enabled, Overlay disabled.
|
|
41
|
+
|
|
42
|
+
for (var _i = 0, _Object$entries = Object.entries(features); _i < _Object$entries.length; _i++) {
|
|
43
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
44
|
+
key = _Object$entries$_i[0],
|
|
45
|
+
value = _Object$entries$_i[1];
|
|
46
|
+
|
|
47
|
+
logString += " ".concat(key, " ").concat(value ? "enabled" : "disabled", ",");
|
|
48
|
+
} // replace last comma with a period
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
logString = logString.slice(0, -1).concat(".");
|
|
52
|
+
log.info(logString);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { log, logEnabledFeatures, setLogLevel };
|
package/lib/Server.js
CHANGED
|
@@ -597,6 +597,19 @@ class Server {
|
|
|
597
597
|
searchParams.set("logging", client.logging);
|
|
598
598
|
}
|
|
599
599
|
|
|
600
|
+
if (typeof client.progress !== "undefined") {
|
|
601
|
+
searchParams.set("progress", String(client.progress));
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
if (typeof client.overlay !== "undefined") {
|
|
605
|
+
searchParams.set(
|
|
606
|
+
"overlay",
|
|
607
|
+
typeof client.overlay === "boolean"
|
|
608
|
+
? String(client.overlay)
|
|
609
|
+
: JSON.stringify(client.overlay)
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
|
|
600
613
|
if (typeof client.reconnect !== "undefined") {
|
|
601
614
|
searchParams.set(
|
|
602
615
|
"reconnect",
|
|
@@ -606,6 +619,14 @@ class Server {
|
|
|
606
619
|
);
|
|
607
620
|
}
|
|
608
621
|
|
|
622
|
+
if (typeof this.options.hot !== "undefined") {
|
|
623
|
+
searchParams.set("hot", String(this.options.hot));
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
if (typeof this.options.liveReload !== "undefined") {
|
|
627
|
+
searchParams.set("live-reload", String(this.options.liveReload));
|
|
628
|
+
}
|
|
629
|
+
|
|
609
630
|
webSocketURLStr = searchParams.toString();
|
|
610
631
|
}
|
|
611
632
|
|
|
@@ -2110,6 +2131,32 @@ class Server {
|
|
|
2110
2131
|
});
|
|
2111
2132
|
}
|
|
2112
2133
|
|
|
2134
|
+
{
|
|
2135
|
+
/**
|
|
2136
|
+
*
|
|
2137
|
+
* @param {Request} req
|
|
2138
|
+
* @param {Response} res
|
|
2139
|
+
* @param {NextFunction} next
|
|
2140
|
+
* @returns {void}
|
|
2141
|
+
*
|
|
2142
|
+
*/
|
|
2143
|
+
const optionsRequestResponseMiddleware = (req, res, next) => {
|
|
2144
|
+
if (req.method === "OPTIONS") {
|
|
2145
|
+
res.statusCode = 204;
|
|
2146
|
+
res.setHeader("Content-Length", "0");
|
|
2147
|
+
res.end();
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
next();
|
|
2151
|
+
};
|
|
2152
|
+
|
|
2153
|
+
middlewares.push({
|
|
2154
|
+
name: "options-middleware",
|
|
2155
|
+
path: "*",
|
|
2156
|
+
middleware: optionsRequestResponseMiddleware,
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2113
2160
|
middlewares.push({
|
|
2114
2161
|
name: "webpack-dev-middleware",
|
|
2115
2162
|
middleware:
|
package/package.json
CHANGED
package/types/lib/Server.d.ts
CHANGED
|
@@ -863,8 +863,14 @@ declare class Server {
|
|
|
863
863
|
type: string;
|
|
864
864
|
multiple: boolean;
|
|
865
865
|
description: string;
|
|
866
|
-
|
|
866
|
+
negatedDescription: string;
|
|
867
867
|
path: string;
|
|
868
|
+
/**
|
|
869
|
+
* prependEntry Method for webpack 4
|
|
870
|
+
* @param {any} originalEntry
|
|
871
|
+
* @param {any} newAdditionalEntries
|
|
872
|
+
* @returns {any}
|
|
873
|
+
*/
|
|
868
874
|
}[];
|
|
869
875
|
description: string;
|
|
870
876
|
simpleType: string;
|
|
@@ -875,13 +881,12 @@ declare class Server {
|
|
|
875
881
|
| {
|
|
876
882
|
type: string;
|
|
877
883
|
multiple: boolean;
|
|
878
|
-
/** @type {any} */
|
|
879
884
|
description: string;
|
|
880
885
|
path: string;
|
|
881
886
|
}
|
|
882
887
|
| {
|
|
883
888
|
type: string;
|
|
884
|
-
|
|
889
|
+
values: boolean[];
|
|
885
890
|
multiple: boolean;
|
|
886
891
|
description: string;
|
|
887
892
|
path: string;
|
|
@@ -920,7 +925,7 @@ declare class Server {
|
|
|
920
925
|
| {
|
|
921
926
|
type: string;
|
|
922
927
|
multiple: boolean;
|
|
923
|
-
description: string;
|
|
928
|
+
/** @type {MultiCompiler} */ description: string;
|
|
924
929
|
path: string;
|
|
925
930
|
}
|
|
926
931
|
| {
|
|
@@ -931,7 +936,7 @@ declare class Server {
|
|
|
931
936
|
path: string;
|
|
932
937
|
}
|
|
933
938
|
)[];
|
|
934
|
-
|
|
939
|
+
description: string;
|
|
935
940
|
simpleType: string;
|
|
936
941
|
multiple: boolean;
|
|
937
942
|
};
|
|
@@ -956,6 +961,10 @@ declare class Server {
|
|
|
956
961
|
description: string;
|
|
957
962
|
simpleType: string;
|
|
958
963
|
multiple: boolean;
|
|
964
|
+
/**
|
|
965
|
+
* @param {WatchOptions & { aggregateTimeout?: number, ignored?: WatchOptions["ignored"], poll?: number | boolean }} watchOptions
|
|
966
|
+
* @returns {WatchOptions}
|
|
967
|
+
*/
|
|
959
968
|
};
|
|
960
969
|
"open-app-name-reset": {
|
|
961
970
|
configs: {
|
|
@@ -987,7 +996,7 @@ declare class Server {
|
|
|
987
996
|
path: string;
|
|
988
997
|
}[];
|
|
989
998
|
description: string;
|
|
990
|
-
|
|
999
|
+
simpleType: string;
|
|
991
1000
|
multiple: boolean;
|
|
992
1001
|
};
|
|
993
1002
|
"open-target-reset": {
|
|
@@ -1162,9 +1171,8 @@ declare class Server {
|
|
|
1162
1171
|
}[];
|
|
1163
1172
|
description: string;
|
|
1164
1173
|
multiple: boolean;
|
|
1165
|
-
simpleType: string
|
|
1174
|
+
simpleType: string;
|
|
1166
1175
|
};
|
|
1167
|
-
/** @type {ServerOptions} */
|
|
1168
1176
|
"server-options-request-cert": {
|
|
1169
1177
|
configs: {
|
|
1170
1178
|
description: string;
|
|
@@ -1187,7 +1195,7 @@ declare class Server {
|
|
|
1187
1195
|
}[];
|
|
1188
1196
|
description: string;
|
|
1189
1197
|
multiple: boolean;
|
|
1190
|
-
simpleType: string
|
|
1198
|
+
simpleType: string /** @type {ServerOptions} */;
|
|
1191
1199
|
};
|
|
1192
1200
|
static: {
|
|
1193
1201
|
configs: (
|
|
@@ -1200,11 +1208,7 @@ declare class Server {
|
|
|
1200
1208
|
| {
|
|
1201
1209
|
type: string;
|
|
1202
1210
|
multiple: boolean;
|
|
1203
|
-
/**
|
|
1204
|
-
* @param {string | Buffer | undefined} item
|
|
1205
|
-
* @returns {string | Buffer | undefined}
|
|
1206
|
-
*/
|
|
1207
|
-
description: string;
|
|
1211
|
+
/** @type {ServerOptions} */ description: string;
|
|
1208
1212
|
negatedDescription: string;
|
|
1209
1213
|
path: string;
|
|
1210
1214
|
}
|
|
@@ -1216,11 +1220,15 @@ declare class Server {
|
|
|
1216
1220
|
"static-directory": {
|
|
1217
1221
|
configs: {
|
|
1218
1222
|
type: string;
|
|
1219
|
-
multiple: boolean;
|
|
1223
|
+
/** @type {any} */ multiple: boolean;
|
|
1220
1224
|
description: string;
|
|
1221
1225
|
path: string;
|
|
1222
1226
|
}[];
|
|
1223
|
-
/**
|
|
1227
|
+
/**
|
|
1228
|
+
* @param {string | Buffer | undefined} item
|
|
1229
|
+
* @returns {string | Buffer | undefined}
|
|
1230
|
+
*/
|
|
1231
|
+
description: string;
|
|
1224
1232
|
simpleType: string;
|
|
1225
1233
|
multiple: boolean;
|
|
1226
1234
|
};
|
|
@@ -1232,7 +1240,7 @@ declare class Server {
|
|
|
1232
1240
|
path: string;
|
|
1233
1241
|
}[];
|
|
1234
1242
|
description: string;
|
|
1235
|
-
simpleType: string;
|
|
1243
|
+
/** @type {any} */ simpleType: string;
|
|
1236
1244
|
multiple: boolean;
|
|
1237
1245
|
};
|
|
1238
1246
|
"static-public-path-reset": {
|
|
@@ -1327,9 +1335,7 @@ declare class Server {
|
|
|
1327
1335
|
type: string;
|
|
1328
1336
|
}
|
|
1329
1337
|
)[];
|
|
1330
|
-
/** @type {ServerOptions & { cacert?: ServerOptions["ca"] }} */
|
|
1331
1338
|
description: string;
|
|
1332
|
-
/** @type {ServerOptions} */
|
|
1333
1339
|
simpleType: string;
|
|
1334
1340
|
multiple: boolean;
|
|
1335
1341
|
};
|
|
@@ -1346,12 +1352,12 @@ declare class Server {
|
|
|
1346
1352
|
description: string;
|
|
1347
1353
|
multiple: boolean;
|
|
1348
1354
|
path: string;
|
|
1349
|
-
type: string
|
|
1355
|
+
type: string /** @type {ServerOptions & { cacert?: ServerOptions["ca"] }} */;
|
|
1350
1356
|
}
|
|
1351
1357
|
)[];
|
|
1352
1358
|
description: string;
|
|
1353
1359
|
simpleType: string;
|
|
1354
|
-
multiple: boolean
|
|
1360
|
+
multiple: boolean /** @type {ServerOptions} */;
|
|
1355
1361
|
};
|
|
1356
1362
|
};
|
|
1357
1363
|
readonly processArguments: (
|
|
@@ -2374,12 +2380,6 @@ declare class Server {
|
|
|
2374
2380
|
anyOf: (
|
|
2375
2381
|
| {
|
|
2376
2382
|
type: string;
|
|
2377
|
-
/**
|
|
2378
|
-
* prependEntry Method for webpack 4
|
|
2379
|
-
* @param {any} originalEntry
|
|
2380
|
-
* @param {any} newAdditionalEntries
|
|
2381
|
-
* @returns {any}
|
|
2382
|
-
*/
|
|
2383
2383
|
items: {
|
|
2384
2384
|
type: string;
|
|
2385
2385
|
minLength: number;
|
|
@@ -2421,7 +2421,6 @@ declare class Server {
|
|
|
2421
2421
|
};
|
|
2422
2422
|
};
|
|
2423
2423
|
};
|
|
2424
|
-
/** @type {any} */
|
|
2425
2424
|
OpenString: {
|
|
2426
2425
|
type: string;
|
|
2427
2426
|
minLength: number;
|
|
@@ -2480,7 +2479,7 @@ declare class Server {
|
|
|
2480
2479
|
};
|
|
2481
2480
|
Server: {
|
|
2482
2481
|
anyOf: {
|
|
2483
|
-
$ref: string
|
|
2482
|
+
$ref: string;
|
|
2484
2483
|
}[];
|
|
2485
2484
|
link: string;
|
|
2486
2485
|
description: string;
|
|
@@ -2631,7 +2630,6 @@ declare class Server {
|
|
|
2631
2630
|
anyOf: (
|
|
2632
2631
|
| {
|
|
2633
2632
|
type: string;
|
|
2634
|
-
/** @type {NormalizedStatic} */
|
|
2635
2633
|
instanceof?: undefined;
|
|
2636
2634
|
}
|
|
2637
2635
|
| {
|
|
@@ -2924,10 +2922,10 @@ declare class Server {
|
|
|
2924
2922
|
anyOf: (
|
|
2925
2923
|
| {
|
|
2926
2924
|
enum: boolean[];
|
|
2927
|
-
cli: {
|
|
2925
|
+
/** @type {ServerOptions} */ cli: {
|
|
2928
2926
|
negatedDescription: string;
|
|
2929
2927
|
};
|
|
2930
|
-
$ref?: undefined;
|
|
2928
|
+
/** @type {ServerOptions} */ $ref?: undefined;
|
|
2931
2929
|
}
|
|
2932
2930
|
| {
|
|
2933
2931
|
$ref: string;
|
|
@@ -2936,7 +2934,7 @@ declare class Server {
|
|
|
2936
2934
|
}
|
|
2937
2935
|
)[];
|
|
2938
2936
|
cli: {
|
|
2939
|
-
description: string
|
|
2937
|
+
description: string;
|
|
2940
2938
|
};
|
|
2941
2939
|
};
|
|
2942
2940
|
WebSocketServerFunction: {
|