webpack-dev-server 2.10.0 → 2.11.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/bin/webpack-dev-server.js +2 -1
- package/client/index.bundle.js +1 -1
- package/client/index.js +81 -70
- package/client/live.bundle.js +2 -2
- package/client/overlay.js +13 -16
- package/client/socket.js +14 -10
- package/lib/util/addDevServerEntrypoints.js +14 -8
- package/package.json +12 -8
- package/ssl/.DS_Store +0 -0
- package/client/live.js +0 -124
- package/client/page.pug +0 -7
- package/client/sockjs.js +0 -3
- package/client/style.css +0 -58
- package/client/web_modules/jquery/index.js +0 -2
- package/client/web_modules/jquery/jquery-1.8.1.js +0 -9301
- package/client/webpack.config.js +0 -38
- package/client/webpack.sockjs.config.js +0 -14
package/client/overlay.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
// The error overlay is inspired (and mostly copied) from Create React App (https://github.com/facebookincubator/create-react-app)
|
|
4
4
|
// They, in turn, got inspired by webpack-hot-middleware (https://github.com/glenjamin/webpack-hot-middleware).
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var ansiHTML = require('ansi-html');
|
|
7
|
+
var Entities = require('html-entities').AllHtmlEntities;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
var entities = new Entities();
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
var colors = {
|
|
12
12
|
reset: ['transparent', 'transparent'],
|
|
13
13
|
black: '181818',
|
|
14
14
|
red: 'E36049',
|
|
@@ -23,7 +23,7 @@ const colors = {
|
|
|
23
23
|
ansiHTML.setColors(colors);
|
|
24
24
|
|
|
25
25
|
function createOverlayIframe(onIframeLoad) {
|
|
26
|
-
|
|
26
|
+
var iframe = document.createElement('iframe');
|
|
27
27
|
iframe.id = 'webpack-dev-server-client-overlay';
|
|
28
28
|
iframe.src = 'about:blank';
|
|
29
29
|
iframe.style.position = 'fixed';
|
|
@@ -40,7 +40,7 @@ function createOverlayIframe(onIframeLoad) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function addOverlayDivTo(iframe) {
|
|
43
|
-
|
|
43
|
+
var div = iframe.contentDocument.createElement('div');
|
|
44
44
|
div.id = 'webpack-dev-server-client-overlay-div';
|
|
45
45
|
div.style.position = 'fixed';
|
|
46
46
|
div.style.boxSizing = 'border-box';
|
|
@@ -62,9 +62,9 @@ function addOverlayDivTo(iframe) {
|
|
|
62
62
|
return div;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
var overlayIframe = null;
|
|
66
|
+
var overlayDiv = null;
|
|
67
|
+
var lastOnOverlayDivReady = null;
|
|
68
68
|
|
|
69
69
|
function ensureOverlayDivExists(onOverlayDivReady) {
|
|
70
70
|
if (overlayDiv) {
|
|
@@ -83,7 +83,7 @@ function ensureOverlayDivExists(onOverlayDivReady) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// Create iframe and, when it is ready, a div inside it.
|
|
86
|
-
overlayIframe = createOverlayIframe(()
|
|
86
|
+
overlayIframe = createOverlayIframe(function () {
|
|
87
87
|
overlayDiv = addOverlayDivTo(overlayIframe);
|
|
88
88
|
// Now we can talk!
|
|
89
89
|
lastOnOverlayDivReady(overlayDiv);
|
|
@@ -96,12 +96,9 @@ function ensureOverlayDivExists(onOverlayDivReady) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
function showMessageOverlay(message) {
|
|
99
|
-
ensureOverlayDivExists((div)
|
|
99
|
+
ensureOverlayDivExists(function (div) {
|
|
100
100
|
// Make it look similar to our terminal.
|
|
101
|
-
div.innerHTML =
|
|
102
|
-
colors.red
|
|
103
|
-
}">Failed to compile.</span><br><br>${
|
|
104
|
-
ansiHTML(entities.encode(message))}`;
|
|
101
|
+
div.innerHTML = '<span style="color: #' + colors.red + '">Failed to compile.</span><br><br>' + ansiHTML(entities.encode(message));
|
|
105
102
|
});
|
|
106
103
|
}
|
|
107
104
|
|
|
@@ -126,4 +123,4 @@ exports.clear = function handleSuccess() {
|
|
|
126
123
|
// Compilation with errors (e.g. syntax error or missing modules).
|
|
127
124
|
exports.showMessage = function handleMessage(messages) {
|
|
128
125
|
showMessageOverlay(messages[0]);
|
|
129
|
-
};
|
|
126
|
+
};
|
package/client/socket.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var SockJS = require('sockjs-client/dist/sockjs');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var retries = 0;
|
|
6
|
+
var sock = null;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
var socket = function initSocket(url, handlers) {
|
|
9
9
|
sock = new SockJS(url);
|
|
10
10
|
|
|
11
11
|
sock.onopen = function onopen() {
|
|
@@ -13,7 +13,9 @@ const socket = function initSocket(url, handlers) {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
sock.onclose = function onclose() {
|
|
16
|
-
if (retries === 0) {
|
|
16
|
+
if (retries === 0) {
|
|
17
|
+
handlers.close();
|
|
18
|
+
}
|
|
17
19
|
|
|
18
20
|
// Try to reconnect.
|
|
19
21
|
sock = null;
|
|
@@ -23,10 +25,10 @@ const socket = function initSocket(url, handlers) {
|
|
|
23
25
|
// Exponentially increase timeout to reconnect.
|
|
24
26
|
// Respectfully copied from the package `got`.
|
|
25
27
|
// eslint-disable-next-line no-mixed-operators, no-restricted-properties
|
|
26
|
-
|
|
28
|
+
var retryInMs = 1000 * Math.pow(2, retries) + Math.random() * 100;
|
|
27
29
|
retries += 1;
|
|
28
30
|
|
|
29
|
-
setTimeout(()
|
|
31
|
+
setTimeout(function () {
|
|
30
32
|
socket(url, handlers);
|
|
31
33
|
}, retryInMs);
|
|
32
34
|
}
|
|
@@ -34,9 +36,11 @@ const socket = function initSocket(url, handlers) {
|
|
|
34
36
|
|
|
35
37
|
sock.onmessage = function onmessage(e) {
|
|
36
38
|
// This assumes that all data sent via the websocket is JSON.
|
|
37
|
-
|
|
38
|
-
if (handlers[msg.type]) {
|
|
39
|
+
var msg = JSON.parse(e.data);
|
|
40
|
+
if (handlers[msg.type]) {
|
|
41
|
+
handlers[msg.type](msg.data);
|
|
42
|
+
}
|
|
39
43
|
};
|
|
40
44
|
};
|
|
41
45
|
|
|
42
|
-
module.exports = socket;
|
|
46
|
+
module.exports = socket;
|
|
@@ -19,16 +19,22 @@ module.exports = function addDevServerEntrypoints(webpackOptions, devServerOptio
|
|
|
19
19
|
|
|
20
20
|
if (devServerOptions.hotOnly) { devClient.push('webpack/hot/only-dev-server'); } else if (devServerOptions.hot) { devClient.push('webpack/hot/dev-server'); }
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
if (typeof
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const prependDevClient = (entry) => {
|
|
23
|
+
if (typeof entry === 'function') {
|
|
24
|
+
return () => Promise.resolve(entry()).then(prependDevClient);
|
|
25
|
+
}
|
|
26
|
+
if (typeof entry === 'object' && !Array.isArray(entry)) {
|
|
27
|
+
const entryClone = {};
|
|
28
|
+
Object.keys(entry).forEach((key) => {
|
|
29
|
+
entryClone[key] = devClient.concat(entry[key]);
|
|
26
30
|
});
|
|
27
|
-
|
|
28
|
-
wpOpt.entry = wpOpt.entry(devClient);
|
|
29
|
-
} else {
|
|
30
|
-
wpOpt.entry = devClient.concat(wpOpt.entry);
|
|
31
|
+
return entryClone;
|
|
31
32
|
}
|
|
33
|
+
return devClient.concat(entry);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
[].concat(webpackOptions).forEach((wpOpt) => {
|
|
37
|
+
wpOpt.entry = prependDevClient(wpOpt.entry);
|
|
32
38
|
});
|
|
33
39
|
}
|
|
34
40
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-dev-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.2",
|
|
4
4
|
"description": "Serves a webpack app. Updates the browser on changes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack/webpack-dev-server",
|
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
"beautify": "npm run lint -- --fix",
|
|
23
23
|
"ci": "npm run cover -- --report lcovonly && npm run test",
|
|
24
24
|
"cover": "istanbul cover node_modules/mocha/bin/_mocha",
|
|
25
|
-
"lint": "eslint bin lib test examples client
|
|
25
|
+
"lint": "eslint bin lib test examples client-src",
|
|
26
26
|
"mocha": "mocha --full-trace --check-leaks",
|
|
27
|
-
"prepublish": "(rm ssl/*.pem || true) && npm run -s build:live && npm run -s build:index && npm run -s build:sockjs",
|
|
27
|
+
"prepublish": "(rm ssl/*.pem || true) && npm run -s transpile:index && npm run -s build:live && npm run -s build:index && npm run -s build:sockjs",
|
|
28
28
|
"test": "npm run lint && npm run mocha",
|
|
29
|
-
"
|
|
30
|
-
"build:index": "webpack ./client/index.js client/index.bundle.js --color --config client/webpack.config.js",
|
|
31
|
-
"build:
|
|
29
|
+
"transpile:index": "babel client-src/default --out-dir client --ignore *.config.js",
|
|
30
|
+
"build:index": "webpack ./client-src/default/index.js client/index.bundle.js --color --config client-src/default/webpack.config.js",
|
|
31
|
+
"build:live": "webpack ./client-src/live/index.js client/live.bundle.js --color --config client-src/live/webpack.config.js",
|
|
32
|
+
"build:sockjs": "webpack ./client-src/sockjs/index.js client/sockjs.bundle.js --color --config client-src/sockjs/webpack.config.js",
|
|
32
33
|
"webpack-dev-server": "cd $INIT_CWD && node ../../../bin/webpack-dev-server.js"
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
@@ -64,16 +65,18 @@
|
|
|
64
65
|
"sockjs": "0.3.19",
|
|
65
66
|
"sockjs-client": "1.1.4",
|
|
66
67
|
"spdy": "^3.4.1",
|
|
67
|
-
"strip-ansi": "^
|
|
68
|
+
"strip-ansi": "^3.0.0",
|
|
68
69
|
"supports-color": "^5.1.0",
|
|
69
70
|
"webpack-dev-middleware": "1.12.2",
|
|
70
|
-
"yargs": "
|
|
71
|
+
"yargs": "6.6.0"
|
|
71
72
|
},
|
|
72
73
|
"devDependencies": {
|
|
74
|
+
"babel-cli": "^6.26.0",
|
|
73
75
|
"babel-core": "^6.26.0",
|
|
74
76
|
"babel-loader": "^7.1.2",
|
|
75
77
|
"babel-preset-env": "^1.6.1",
|
|
76
78
|
"codecov.io": "^0.1.6",
|
|
79
|
+
"copy-webpack-plugin": "^4.3.1",
|
|
77
80
|
"css-loader": "^0.28.5",
|
|
78
81
|
"eslint": "^4.5.0",
|
|
79
82
|
"eslint-config-webpack": "^1.2.5",
|
|
@@ -90,6 +93,7 @@
|
|
|
90
93
|
"mocha-sinon": "^2.0.0",
|
|
91
94
|
"pug": "^2.0.0-beta5",
|
|
92
95
|
"pug-loader": "^2.3.0",
|
|
96
|
+
"semver": "^5.4.1",
|
|
93
97
|
"should": "^13.2.0",
|
|
94
98
|
"sinon": "^4.1.3",
|
|
95
99
|
"style-loader": "^0.19.1",
|
package/ssl/.DS_Store
ADDED
|
Binary file
|
package/client/live.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/* eslint import/no-extraneous-dependencies: off, global-require: off */
|
|
4
|
-
|
|
5
|
-
const $ = require('jquery');
|
|
6
|
-
const stripAnsi = require('strip-ansi');
|
|
7
|
-
const socket = require('./socket');
|
|
8
|
-
require('./style.css');
|
|
9
|
-
|
|
10
|
-
let hot = false;
|
|
11
|
-
let currentHash = '';
|
|
12
|
-
|
|
13
|
-
$(() => {
|
|
14
|
-
$('body').html(require('./page.pug')());
|
|
15
|
-
const status = $('#status');
|
|
16
|
-
const okness = $('#okness');
|
|
17
|
-
const $errors = $('#errors');
|
|
18
|
-
const iframe = $('#iframe');
|
|
19
|
-
const header = $('.header');
|
|
20
|
-
|
|
21
|
-
const contentPage = window.location.pathname.substr('/webpack-dev-server'.length) + window.location.search;
|
|
22
|
-
|
|
23
|
-
status.text('Connecting to sockjs server...');
|
|
24
|
-
$errors.hide();
|
|
25
|
-
iframe.hide();
|
|
26
|
-
header.css({
|
|
27
|
-
borderColor: '#96b5b4'
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const onSocketMsg = {
|
|
31
|
-
hot() {
|
|
32
|
-
hot = true;
|
|
33
|
-
iframe.attr('src', contentPage + window.location.hash);
|
|
34
|
-
},
|
|
35
|
-
invalid() {
|
|
36
|
-
okness.text('');
|
|
37
|
-
status.text('App updated. Recompiling...');
|
|
38
|
-
header.css({
|
|
39
|
-
borderColor: '#96b5b4'
|
|
40
|
-
});
|
|
41
|
-
$errors.hide();
|
|
42
|
-
if (!hot) iframe.hide();
|
|
43
|
-
},
|
|
44
|
-
hash(hash) {
|
|
45
|
-
currentHash = hash;
|
|
46
|
-
},
|
|
47
|
-
'still-ok': function stillOk() {
|
|
48
|
-
okness.text('');
|
|
49
|
-
status.text('App ready.');
|
|
50
|
-
header.css({
|
|
51
|
-
borderColor: ''
|
|
52
|
-
});
|
|
53
|
-
$errors.hide();
|
|
54
|
-
if (!hot) iframe.show();
|
|
55
|
-
},
|
|
56
|
-
ok() {
|
|
57
|
-
okness.text('');
|
|
58
|
-
$errors.hide();
|
|
59
|
-
reloadApp();
|
|
60
|
-
},
|
|
61
|
-
warnings() {
|
|
62
|
-
okness.text('Warnings while compiling.');
|
|
63
|
-
$errors.hide();
|
|
64
|
-
reloadApp();
|
|
65
|
-
},
|
|
66
|
-
errors: function msgErrors(errors) {
|
|
67
|
-
status.text('App updated with errors. No reload!');
|
|
68
|
-
okness.text('Errors while compiling.');
|
|
69
|
-
$errors.text(`\n${stripAnsi(errors.join('\n\n\n'))}\n\n`);
|
|
70
|
-
header.css({
|
|
71
|
-
borderColor: '#ebcb8b'
|
|
72
|
-
});
|
|
73
|
-
$errors.show();
|
|
74
|
-
iframe.hide();
|
|
75
|
-
},
|
|
76
|
-
close() {
|
|
77
|
-
status.text('');
|
|
78
|
-
okness.text('Disconnected.');
|
|
79
|
-
$errors.text('\n\n\n Lost connection to webpack-dev-server.\n Please restart the server to reestablish connection...\n\n\n\n');
|
|
80
|
-
header.css({
|
|
81
|
-
borderColor: '#ebcb8b'
|
|
82
|
-
});
|
|
83
|
-
$errors.show();
|
|
84
|
-
iframe.hide();
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
socket('/sockjs-node', onSocketMsg);
|
|
89
|
-
|
|
90
|
-
iframe.on('load', () => {
|
|
91
|
-
status.text('App ready.');
|
|
92
|
-
header.css({
|
|
93
|
-
borderColor: ''
|
|
94
|
-
});
|
|
95
|
-
iframe.show();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
function reloadApp() {
|
|
99
|
-
if (hot) {
|
|
100
|
-
status.text('App hot update.');
|
|
101
|
-
try {
|
|
102
|
-
iframe[0].contentWindow.postMessage(`webpackHotUpdate${currentHash}`, '*');
|
|
103
|
-
} catch (e) {
|
|
104
|
-
console.warn(e); // eslint-disable-line
|
|
105
|
-
}
|
|
106
|
-
iframe.show();
|
|
107
|
-
} else {
|
|
108
|
-
status.text('App updated. Reloading app...');
|
|
109
|
-
header.css({
|
|
110
|
-
borderColor: '#96b5b4'
|
|
111
|
-
});
|
|
112
|
-
try {
|
|
113
|
-
let old = `${iframe[0].contentWindow.location}`;
|
|
114
|
-
if (old.indexOf('about') === 0) old = null;
|
|
115
|
-
iframe.attr('src', old || (contentPage + window.location.hash));
|
|
116
|
-
if (old) {
|
|
117
|
-
iframe[0].contentWindow.location.reload();
|
|
118
|
-
}
|
|
119
|
-
} catch (e) {
|
|
120
|
-
iframe.attr('src', contentPage + window.location.hash);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
package/client/page.pug
DELETED
package/client/sockjs.js
DELETED
package/client/style.css
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
*,
|
|
2
|
-
*:before,
|
|
3
|
-
*:after {
|
|
4
|
-
-webkit-box-sizing: border-box;
|
|
5
|
-
-moz-box-sizing: border-box;
|
|
6
|
-
box-sizing: border-box;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
body,
|
|
10
|
-
html {
|
|
11
|
-
margin: 0;
|
|
12
|
-
padding: 0;
|
|
13
|
-
height: 100%;
|
|
14
|
-
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.header {
|
|
18
|
-
width: 100%;
|
|
19
|
-
height: 30px;
|
|
20
|
-
padding: 0 10px;
|
|
21
|
-
border-left: 10px solid #a3be8c;
|
|
22
|
-
font-size: 12px;
|
|
23
|
-
line-height: 30px;
|
|
24
|
-
color: #eff1f5;
|
|
25
|
-
background: #343d46;
|
|
26
|
-
overflow: hidden;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
#iframe {
|
|
30
|
-
position: absolute;
|
|
31
|
-
top: 30px;
|
|
32
|
-
right: 0;
|
|
33
|
-
bottom: 0;
|
|
34
|
-
left: 0;
|
|
35
|
-
width: 100%;
|
|
36
|
-
height: -webkit-calc(100% - 30px);
|
|
37
|
-
height: -moz-calc(100% - 30px);
|
|
38
|
-
height: -ms-calc(100% - 30px);
|
|
39
|
-
height: -o-calc(100% - 30px);
|
|
40
|
-
height: calc(100% - 30px);
|
|
41
|
-
border: 0;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
#errors {
|
|
45
|
-
width: 100%;
|
|
46
|
-
margin: 0;
|
|
47
|
-
padding: 10px;
|
|
48
|
-
font-family: monospace;
|
|
49
|
-
font-size: 14px;
|
|
50
|
-
line-height: 1.4;
|
|
51
|
-
color: #eff1f5;
|
|
52
|
-
background: #bf616a;
|
|
53
|
-
overflow: auto;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
#okness {
|
|
57
|
-
font-weight: bold;
|
|
58
|
-
}
|