webpack-dev-server 4.0.0-rc.1 → 4.0.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 +6 -14
- package/client/utils/createSocketURL.js +1 -1
- package/client/utils/reloadApp.js +21 -6
- package/lib/Server.js +8 -6
- package/package.json +1 -1
package/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* global __resourceQuery */
|
|
1
|
+
/* global __resourceQuery, __webpack_hash__ */
|
|
2
2
|
import webpackHotLog from "webpack/hot/log.js";
|
|
3
3
|
import stripAnsi from "./modules/strip-ansi/index.js";
|
|
4
4
|
import parseURL from "./utils/parseURL.js";
|
|
@@ -10,12 +10,14 @@ import reloadApp from "./utils/reloadApp.js";
|
|
|
10
10
|
import createSocketURL from "./utils/createSocketURL.js";
|
|
11
11
|
var status = {
|
|
12
12
|
isUnloading: false,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// TODO Workaround for webpack v4, `__webpack_hash__` is not replaced without HotModuleReplacement
|
|
14
|
+
// eslint-disable-next-line camelcase
|
|
15
|
+
currentHash: typeof __webpack_hash__ !== "undefined" ? __webpack_hash__ : ""
|
|
16
|
+
}; // console.log(__webpack_hash__);
|
|
17
|
+
|
|
15
18
|
var options = {
|
|
16
19
|
hot: false,
|
|
17
20
|
liveReload: false,
|
|
18
|
-
initial: true,
|
|
19
21
|
progress: false,
|
|
20
22
|
overlay: false
|
|
21
23
|
};
|
|
@@ -101,10 +103,6 @@ var onSocketMessage = {
|
|
|
101
103
|
hide();
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
if (options.initial) {
|
|
105
|
-
return options.initial = false;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
106
|
reloadApp(options, status);
|
|
109
107
|
},
|
|
110
108
|
// TODO: remove in v5 in favor of 'static-changed'
|
|
@@ -135,10 +133,6 @@ var onSocketMessage = {
|
|
|
135
133
|
show(_warnings, "warnings");
|
|
136
134
|
}
|
|
137
135
|
|
|
138
|
-
if (options.initial) {
|
|
139
|
-
return options.initial = false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
136
|
reloadApp(options, status);
|
|
143
137
|
},
|
|
144
138
|
errors: function errors(_errors) {
|
|
@@ -159,8 +153,6 @@ var onSocketMessage = {
|
|
|
159
153
|
if (needShowOverlay) {
|
|
160
154
|
show(_errors, "errors");
|
|
161
155
|
}
|
|
162
|
-
|
|
163
|
-
options.initial = false;
|
|
164
156
|
},
|
|
165
157
|
error: function error(_error) {
|
|
166
158
|
log.error(_error);
|
|
@@ -13,7 +13,7 @@ function createSocketURL(parsedURL) {
|
|
|
13
13
|
hostname = self.location.hostname;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
var socketURLProtocol = parsedURL.protocol ||
|
|
16
|
+
var socketURLProtocol = parsedURL.protocol || self.location.protocol; // When https is used in the app, secure web sockets are always necessary because the browser doesn't accept non-secure web sockets.
|
|
17
17
|
|
|
18
18
|
if (socketURLProtocol === "auto:" || hostname && isInAddrAny && self.location.protocol === "https:") {
|
|
19
19
|
socketURLProtocol = self.location.protocol;
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
+
/* global __webpack_hash__ */
|
|
1
2
|
import hotEmitter from "webpack/hot/emitter.js";
|
|
2
3
|
import { log } from "./log.js";
|
|
3
4
|
|
|
4
|
-
function reloadApp(_ref,
|
|
5
|
+
function reloadApp(_ref, status) {
|
|
5
6
|
var hot = _ref.hot,
|
|
6
7
|
liveReload = _ref.liveReload;
|
|
7
|
-
var isUnloading = _ref2.isUnloading,
|
|
8
|
-
currentHash = _ref2.currentHash;
|
|
9
8
|
|
|
10
|
-
if (isUnloading) {
|
|
9
|
+
if (status.isUnloading) {
|
|
10
|
+
return;
|
|
11
|
+
} // TODO Workaround for webpack v4, `__webpack_hash__` is not replaced without HotModuleReplacement plugin
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var webpackHash = // eslint-disable-next-line camelcase
|
|
15
|
+
typeof __webpack_hash__ !== "undefined" ? // eslint-disable-next-line camelcase
|
|
16
|
+
__webpack_hash__ : status.previousHash || "";
|
|
17
|
+
var isInitial = status.currentHash.indexOf(webpackHash) === 0;
|
|
18
|
+
|
|
19
|
+
if (isInitial) {
|
|
20
|
+
var isLegacyInitial = webpackHash === "" && hot === false && liveReload === true;
|
|
21
|
+
|
|
22
|
+
if (isLegacyInitial) {
|
|
23
|
+
status.previousHash = status.currentHash;
|
|
24
|
+
}
|
|
25
|
+
|
|
11
26
|
return;
|
|
12
27
|
}
|
|
13
28
|
|
|
@@ -23,11 +38,11 @@ function reloadApp(_ref, _ref2) {
|
|
|
23
38
|
|
|
24
39
|
if (hot && allowToHot) {
|
|
25
40
|
log.info("App hot update...");
|
|
26
|
-
hotEmitter.emit("webpackHotUpdate", currentHash);
|
|
41
|
+
hotEmitter.emit("webpackHotUpdate", status.currentHash);
|
|
27
42
|
|
|
28
43
|
if (typeof self !== "undefined" && self.window) {
|
|
29
44
|
// broadcast update to window
|
|
30
|
-
self.postMessage("webpackHotUpdate".concat(currentHash), "*");
|
|
45
|
+
self.postMessage("webpackHotUpdate".concat(status.currentHash), "*");
|
|
31
46
|
}
|
|
32
47
|
} // allow refreshing the page only if liveReload isn't disabled
|
|
33
48
|
else if (liveReload && allowToLiveReload) {
|
package/lib/Server.js
CHANGED
|
@@ -329,7 +329,7 @@ class Server {
|
|
|
329
329
|
const del = require("del");
|
|
330
330
|
|
|
331
331
|
this.logger.info(
|
|
332
|
-
"SSL Certificate is more than 30 days old. Removing
|
|
332
|
+
"SSL Certificate is more than 30 days old. Removing..."
|
|
333
333
|
);
|
|
334
334
|
|
|
335
335
|
del.sync([certificatePath], { force: true });
|
|
@@ -339,7 +339,7 @@ class Server {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
if (!certificateExists) {
|
|
342
|
-
this.logger.info("Generating SSL Certificate");
|
|
342
|
+
this.logger.info("Generating SSL Certificate...");
|
|
343
343
|
|
|
344
344
|
const selfsigned = require("selfsigned");
|
|
345
345
|
const attributes = [{ name: "commonName", value: "localhost" }];
|
|
@@ -348,10 +348,10 @@ class Server {
|
|
|
348
348
|
days: 30,
|
|
349
349
|
keySize: 2048,
|
|
350
350
|
extensions: [
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
351
|
+
{
|
|
352
|
+
name: "basicConstraints",
|
|
353
|
+
cA: true,
|
|
354
|
+
},
|
|
355
355
|
{
|
|
356
356
|
name: "keyUsage",
|
|
357
357
|
keyCertSign: true,
|
|
@@ -412,6 +412,8 @@ class Server {
|
|
|
412
412
|
}
|
|
413
413
|
|
|
414
414
|
fakeCert = fs.readFileSync(certificatePath);
|
|
415
|
+
|
|
416
|
+
this.logger.info(`SSL certificate: ${certificatePath}`);
|
|
415
417
|
}
|
|
416
418
|
|
|
417
419
|
options.https.key = options.https.key || fakeCert;
|