webpack-dev-server 2.8.1 → 2.9.2
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/README.md +111 -25
- package/bin/webpack-dev-server.js +2 -2
- package/client/.eslintrc +7 -0
- package/client/index.bundle.js +1 -1
- package/client/index.js +40 -23
- package/client/live.bundle.js +3 -3
- package/client/live.js +12 -12
- package/client/overlay.js +6 -8
- package/client/socket.js +1 -1
- package/lib/Server.js +18 -10
- package/lib/optionsSchema.json +8 -3
- package/lib/polyfills.js +3 -4
- package/lib/util/createDomain.js +5 -1
- package/package.json +4 -4
- package/ssl/server.pem +46 -0
package/client/index.js
CHANGED
|
@@ -65,24 +65,24 @@ function sendMsg(type, data) {
|
|
|
65
65
|
!(self instanceof WorkerGlobalScope))
|
|
66
66
|
) {
|
|
67
67
|
self.postMessage({
|
|
68
|
-
type:
|
|
69
|
-
data
|
|
68
|
+
type: 'webpack' + type,
|
|
69
|
+
data: data
|
|
70
70
|
}, '*');
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const onSocketMsg = {
|
|
75
|
-
hot() {
|
|
75
|
+
hot: function msgHot() {
|
|
76
76
|
hot = true;
|
|
77
77
|
log.info('[WDS] Hot Module Replacement enabled.');
|
|
78
78
|
},
|
|
79
|
-
invalid() {
|
|
79
|
+
invalid: function msgInvalid() {
|
|
80
80
|
log.info('[WDS] App updated. Recompiling...');
|
|
81
81
|
// fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
|
|
82
82
|
if (useWarningOverlay || useErrorOverlay) overlay.clear();
|
|
83
83
|
sendMsg('Invalid');
|
|
84
84
|
},
|
|
85
|
-
hash(hash) {
|
|
85
|
+
hash: function msgHash(hash) {
|
|
86
86
|
currentHash = hash;
|
|
87
87
|
},
|
|
88
88
|
'still-ok': function stillOk() {
|
|
@@ -92,8 +92,7 @@ const onSocketMsg = {
|
|
|
92
92
|
},
|
|
93
93
|
'log-level': function logLevel(level) {
|
|
94
94
|
const hotCtx = require.context('webpack/hot', false, /^\.\/log$/);
|
|
95
|
-
|
|
96
|
-
if (contextKeys.length && contextKeys['./log']) {
|
|
95
|
+
if (hotCtx.keys().indexOf('./log') !== -1) {
|
|
97
96
|
hotCtx('./log').setLogLevel(level);
|
|
98
97
|
}
|
|
99
98
|
switch (level) {
|
|
@@ -109,10 +108,10 @@ const onSocketMsg = {
|
|
|
109
108
|
log.disableAll();
|
|
110
109
|
break;
|
|
111
110
|
default:
|
|
112
|
-
log.error(
|
|
111
|
+
log.error('[WDS] Unknown clientLogLevel \'' + level + '\'');
|
|
113
112
|
}
|
|
114
113
|
},
|
|
115
|
-
overlay(value) {
|
|
114
|
+
overlay: function msgOverlay(value) {
|
|
116
115
|
if (typeof document !== 'undefined') {
|
|
117
116
|
if (typeof (value) === 'boolean') {
|
|
118
117
|
useWarningOverlay = false;
|
|
@@ -123,15 +122,15 @@ const onSocketMsg = {
|
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
124
|
},
|
|
126
|
-
progress(progress) {
|
|
125
|
+
progress: function msgProgress(progress) {
|
|
127
126
|
if (typeof document !== 'undefined') {
|
|
128
127
|
useProgress = progress;
|
|
129
128
|
}
|
|
130
129
|
},
|
|
131
130
|
'progress-update': function progressUpdate(data) {
|
|
132
|
-
if (useProgress) log.info(
|
|
131
|
+
if (useProgress) log.info('[WDS] ' + data.percent + '% - ' + data.msg + '.');
|
|
133
132
|
},
|
|
134
|
-
ok() {
|
|
133
|
+
ok: function msgOk() {
|
|
135
134
|
sendMsg('Ok');
|
|
136
135
|
if (useWarningOverlay || useErrorOverlay) overlay.clear();
|
|
137
136
|
if (initial) return initial = false; // eslint-disable-line no-return-assign
|
|
@@ -141,9 +140,9 @@ const onSocketMsg = {
|
|
|
141
140
|
log.info('[WDS] Content base changed. Reloading...');
|
|
142
141
|
self.location.reload();
|
|
143
142
|
},
|
|
144
|
-
warnings(warnings) {
|
|
143
|
+
warnings: function msgWarnings(warnings) {
|
|
145
144
|
log.warn('[WDS] Warnings while compiling.');
|
|
146
|
-
const strippedWarnings = warnings.map(warning
|
|
145
|
+
const strippedWarnings = warnings.map(function map(warning) { return stripAnsi(warning); });
|
|
147
146
|
sendMsg('Warnings', strippedWarnings);
|
|
148
147
|
for (let i = 0; i < strippedWarnings.length; i++) { log.warn(strippedWarnings[i]); }
|
|
149
148
|
if (useWarningOverlay) overlay.showMessage(warnings);
|
|
@@ -151,17 +150,17 @@ const onSocketMsg = {
|
|
|
151
150
|
if (initial) return initial = false; // eslint-disable-line no-return-assign
|
|
152
151
|
reloadApp();
|
|
153
152
|
},
|
|
154
|
-
errors(errors) {
|
|
153
|
+
errors: function msgErrors(errors) {
|
|
155
154
|
log.error('[WDS] Errors while compiling. Reload prevented.');
|
|
156
|
-
const strippedErrors = errors.map(error
|
|
155
|
+
const strippedErrors = errors.map(function map(error) { return stripAnsi(error); });
|
|
157
156
|
sendMsg('Errors', strippedErrors);
|
|
158
157
|
for (let i = 0; i < strippedErrors.length; i++) { log.error(strippedErrors[i]); }
|
|
159
158
|
if (useErrorOverlay) overlay.showMessage(errors);
|
|
160
159
|
},
|
|
161
|
-
error(error) {
|
|
160
|
+
error: function msgError(error) {
|
|
162
161
|
log.error(error);
|
|
163
162
|
},
|
|
164
|
-
close() {
|
|
163
|
+
close: function msgClose() {
|
|
165
164
|
log.error('[WDS] Disconnected!');
|
|
166
165
|
sendMsg('Close');
|
|
167
166
|
}
|
|
@@ -191,9 +190,9 @@ if (hostname && (self.location.protocol === 'https:' || urlParts.hostname === '0
|
|
|
191
190
|
}
|
|
192
191
|
|
|
193
192
|
const socketUrl = url.format({
|
|
194
|
-
protocol,
|
|
193
|
+
protocol: protocol,
|
|
195
194
|
auth: urlParts.auth,
|
|
196
|
-
hostname,
|
|
195
|
+
hostname: hostname,
|
|
197
196
|
port: urlParts.port,
|
|
198
197
|
pathname: urlParts.path == null || urlParts.path === '/' ? '/sockjs-node' : urlParts.path
|
|
199
198
|
});
|
|
@@ -201,7 +200,7 @@ const socketUrl = url.format({
|
|
|
201
200
|
socket(socketUrl, onSocketMsg);
|
|
202
201
|
|
|
203
202
|
let isUnloading = false;
|
|
204
|
-
self.addEventListener('beforeunload', ()
|
|
203
|
+
self.addEventListener('beforeunload', function beforeUnload() {
|
|
205
204
|
isUnloading = true;
|
|
206
205
|
});
|
|
207
206
|
|
|
@@ -216,10 +215,28 @@ function reloadApp() {
|
|
|
216
215
|
hotEmitter.emit('webpackHotUpdate', currentHash);
|
|
217
216
|
if (typeof self !== 'undefined' && self.window) {
|
|
218
217
|
// broadcast update to window
|
|
219
|
-
self.postMessage(
|
|
218
|
+
self.postMessage('webpackHotUpdate' + currentHash, '*');
|
|
220
219
|
}
|
|
221
220
|
} else {
|
|
221
|
+
let rootWindow = self;
|
|
222
|
+
// use parent window for reload (in case we're in an iframe with no valid src)
|
|
223
|
+
const intervalId = self.setInterval(function findRootWindow() {
|
|
224
|
+
if (rootWindow.location.protocol !== 'about:') {
|
|
225
|
+
// reload immediately if protocol is valid
|
|
226
|
+
applyReload(rootWindow, intervalId);
|
|
227
|
+
} else {
|
|
228
|
+
rootWindow = rootWindow.parent;
|
|
229
|
+
if (rootWindow.parent === rootWindow) {
|
|
230
|
+
// if parent equals current window we've reached the root which would continue forever, so trigger a reload anyways
|
|
231
|
+
applyReload(rootWindow, intervalId);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function applyReload(rootWindow, intervalId) {
|
|
238
|
+
clearInterval(intervalId);
|
|
222
239
|
log.info('[WDS] App updated. Reloading...');
|
|
223
|
-
|
|
240
|
+
rootWindow.location.reload();
|
|
224
241
|
}
|
|
225
242
|
}
|