webpack-dev-server 3.4.1 → 3.7.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/CHANGELOG.md +56 -0
- package/bin/webpack-dev-server.js +21 -77
- package/client/clients/BaseClient.js +27 -0
- package/client/clients/SockJSClient.js +69 -0
- package/client/clients/WebsocketClient.js +31 -0
- package/client/index.bundle.js +1 -1
- package/client/index.js +55 -216
- package/client/live.bundle.js +3 -3
- package/client/socket.js +15 -15
- package/client/utils/createSocketUrl.js +78 -0
- package/client/utils/getCurrentScriptSource.js +22 -0
- package/client/utils/log.js +49 -0
- package/client/utils/reloadApp.js +55 -0
- package/client/utils/sendMessage.js +14 -0
- package/lib/Server.js +54 -65
- package/lib/options.json +17 -2
- package/lib/servers/BaseServer.js +9 -0
- package/lib/servers/SockJSServer.js +64 -0
- package/lib/servers/WebsocketServer.js +8 -0
- package/lib/utils/addEntries.js +2 -0
- package/lib/utils/createConfig.js +4 -0
- package/lib/utils/defaultPort.js +3 -0
- package/lib/utils/findPort.js +22 -29
- package/lib/utils/getSocketServerImplementation.js +41 -0
- package/lib/utils/processOptions.js +29 -0
- package/lib/utils/runOpen.js +21 -0
- package/lib/utils/setupExitSignals.js +21 -0
- package/lib/utils/status.js +2 -14
- package/lib/utils/updateCompiler.js +8 -0
- package/package.json +19 -18
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [3.7.0](https://github.com/webpack/webpack-dev-server/compare/v3.5.1...v3.7.0) (2019-06-06)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* change clientLogLevel order to be called first ([#1973](https://github.com/webpack/webpack-dev-server/issues/1973)) ([57c8c92](https://github.com/webpack/webpack-dev-server/commit/57c8c92))
|
|
11
|
+
* es6 syntax in client ([#1982](https://github.com/webpack/webpack-dev-server/issues/1982)) ([802aa30](https://github.com/webpack/webpack-dev-server/commit/802aa30))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **server:** add serverMode option ([#1937](https://github.com/webpack/webpack-dev-server/issues/1937)) ([44a8cde](https://github.com/webpack/webpack-dev-server/commit/44a8cde))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## [3.6.0](https://github.com/webpack/webpack-dev-server/compare/v3.5.1...v3.6.0) (2019-06-05)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* **config:** enable `--overlay` ([#1968](https://github.com/webpack/webpack-dev-server/issues/1968)) ([dc81e23](https://github.com/webpack/webpack-dev-server/commit/dc81e23))
|
|
26
|
+
* **server:** don't ignore node_modules by default ([#1970](https://github.com/webpack/webpack-dev-server/issues/1970)) ([699f8b4](https://github.com/webpack/webpack-dev-server/commit/699f8b4)), closes [#1794](https://github.com/webpack/webpack-dev-server/issues/1794)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* **server:** add serverMode option ([#1937](https://github.com/webpack/webpack-dev-server/issues/1937)) ([44a8cde](https://github.com/webpack/webpack-dev-server/commit/44a8cde))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### [3.5.1](https://github.com/webpack/webpack-dev-server/compare/v3.5.0...v3.5.1) (2019-06-01)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Bug Fixes
|
|
39
|
+
|
|
40
|
+
* allow passing promise function of webpack.config.js ([#1947](https://github.com/webpack/webpack-dev-server/issues/1947)) ([8cf1053](https://github.com/webpack/webpack-dev-server/commit/8cf1053))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## [3.5.0](https://github.com/webpack/webpack-dev-server/compare/v3.4.1...v3.5.0) (2019-05-31)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Bug Fixes
|
|
48
|
+
|
|
49
|
+
* add client code for `electron-renderer` target ([#1935](https://github.com/webpack/webpack-dev-server/issues/1935)) ([9297988](https://github.com/webpack/webpack-dev-server/commit/9297988))
|
|
50
|
+
* add client code for `node-webkit` target ([#1942](https://github.com/webpack/webpack-dev-server/issues/1942)) ([c6b2b1f](https://github.com/webpack/webpack-dev-server/commit/c6b2b1f))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Features
|
|
54
|
+
|
|
55
|
+
* **server:** `onListening` option ([#1930](https://github.com/webpack/webpack-dev-server/issues/1930)) ([61d0cdf](https://github.com/webpack/webpack-dev-server/commit/61d0cdf))
|
|
56
|
+
* **server:** add callback support for invalidate ([#1900](https://github.com/webpack/webpack-dev-server/issues/1900)) ([cd218ef](https://github.com/webpack/webpack-dev-server/commit/cd218ef))
|
|
57
|
+
* **server:** add `WEBPACK_DEV_SERVER` env variable ([#1929](https://github.com/webpack/webpack-dev-server/issues/1929)) ([856169e](https://github.com/webpack/webpack-dev-server/commit/856169e))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
5
61
|
### [3.4.1](https://github.com/webpack/webpack-dev-server/compare/v3.4.0...v3.4.1) (2019-05-17)
|
|
6
62
|
|
|
7
63
|
|
|
@@ -2,49 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
/* eslint-disable
|
|
6
|
-
import/order,
|
|
7
|
-
no-shadow,
|
|
8
|
-
no-console
|
|
9
|
-
*/
|
|
10
|
-
const debug = require('debug')('webpack-dev-server');
|
|
5
|
+
/* eslint-disable no-shadow, no-console */
|
|
11
6
|
|
|
12
7
|
const fs = require('fs');
|
|
13
8
|
const net = require('net');
|
|
14
|
-
|
|
9
|
+
const debug = require('debug')('webpack-dev-server');
|
|
15
10
|
const importLocal = require('import-local');
|
|
16
|
-
|
|
17
11
|
const yargs = require('yargs');
|
|
18
12
|
const webpack = require('webpack');
|
|
19
|
-
|
|
20
|
-
const options = require('./options');
|
|
21
13
|
const Server = require('../lib/Server');
|
|
22
|
-
|
|
14
|
+
const setupExitSignals = require('../lib/utils/setupExitSignals');
|
|
23
15
|
const colors = require('../lib/utils/colors');
|
|
24
|
-
const
|
|
16
|
+
const processOptions = require('../lib/utils/processOptions');
|
|
25
17
|
const createLogger = require('../lib/utils/createLogger');
|
|
26
|
-
const defaultTo = require('../lib/utils/defaultTo');
|
|
27
18
|
const findPort = require('../lib/utils/findPort');
|
|
28
19
|
const getVersions = require('../lib/utils/getVersions');
|
|
29
|
-
const
|
|
20
|
+
const options = require('./options');
|
|
30
21
|
|
|
31
22
|
let server;
|
|
32
23
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
signals.forEach((signal) => {
|
|
36
|
-
process.on(signal, () => {
|
|
37
|
-
if (server) {
|
|
38
|
-
server.close(() => {
|
|
39
|
-
// eslint-disable-next-line no-process-exit
|
|
40
|
-
process.exit();
|
|
41
|
-
});
|
|
42
|
-
} else {
|
|
43
|
-
// eslint-disable-next-line no-process-exit
|
|
44
|
-
process.exit();
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
24
|
+
setupExitSignals(server);
|
|
48
25
|
|
|
49
26
|
// Prefer the local installation of webpack-dev-server
|
|
50
27
|
if (importLocal(__filename)) {
|
|
@@ -103,36 +80,6 @@ const config = require(convertArgvPath)(yargs, argv, {
|
|
|
103
80
|
outputFilename: '/bundle.js',
|
|
104
81
|
});
|
|
105
82
|
|
|
106
|
-
// Taken out of yargs because we must know if
|
|
107
|
-
// it wasn't given by the user, in which case
|
|
108
|
-
// we should use portfinder.
|
|
109
|
-
const DEFAULT_PORT = 8080;
|
|
110
|
-
|
|
111
|
-
// Try to find unused port and listen on it for 3 times,
|
|
112
|
-
// if port is not specified in options.
|
|
113
|
-
// Because NaN == null is false, defaultTo fails if parseInt returns NaN
|
|
114
|
-
// so the tryParseInt function is introduced to handle NaN
|
|
115
|
-
const defaultPortRetry = defaultTo(
|
|
116
|
-
tryParseInt(process.env.DEFAULT_PORT_RETRY),
|
|
117
|
-
3
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
function processOptions(config) {
|
|
121
|
-
// processOptions {Promise}
|
|
122
|
-
if (typeof config.then === 'function') {
|
|
123
|
-
config.then(processOptions).catch((err) => {
|
|
124
|
-
console.error(err.stack || err);
|
|
125
|
-
// eslint-disable-next-line no-process-exit
|
|
126
|
-
process.exit();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const options = createConfig(config, argv, { port: DEFAULT_PORT });
|
|
133
|
-
startDevServer(config, options);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
83
|
function startDevServer(config, options) {
|
|
137
84
|
const log = createLogger(options);
|
|
138
85
|
|
|
@@ -196,6 +143,7 @@ function startDevServer(config, options) {
|
|
|
196
143
|
if (err) {
|
|
197
144
|
throw err;
|
|
198
145
|
}
|
|
146
|
+
|
|
199
147
|
// chmod 666 (rw rw rw)
|
|
200
148
|
const READ_WRITE = 438;
|
|
201
149
|
|
|
@@ -205,26 +153,22 @@ function startDevServer(config, options) {
|
|
|
205
153
|
}
|
|
206
154
|
});
|
|
207
155
|
});
|
|
208
|
-
} else if (options.port) {
|
|
209
|
-
runServer();
|
|
210
156
|
} else {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
function runServer() {
|
|
222
|
-
server.listen(options.port, options.host, (err) => {
|
|
223
|
-
if (err) {
|
|
157
|
+
findPort(options.port)
|
|
158
|
+
.then((port) => {
|
|
159
|
+
options.port = port;
|
|
160
|
+
server.listen(options.port, options.host, (err) => {
|
|
161
|
+
if (err) {
|
|
162
|
+
throw err;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
})
|
|
166
|
+
.catch((err) => {
|
|
224
167
|
throw err;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
168
|
+
});
|
|
227
169
|
}
|
|
228
170
|
}
|
|
229
171
|
|
|
230
|
-
processOptions(config)
|
|
172
|
+
processOptions(config, argv, (config, options) => {
|
|
173
|
+
startDevServer(config, options);
|
|
174
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* eslint-disable
|
|
3
|
+
no-unused-vars
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7
|
+
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
9
|
+
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
11
|
+
|
|
12
|
+
module.exports =
|
|
13
|
+
/*#__PURE__*/
|
|
14
|
+
function () {
|
|
15
|
+
function BaseClient() {
|
|
16
|
+
_classCallCheck(this, BaseClient);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_createClass(BaseClient, null, [{
|
|
20
|
+
key: "getClientPath",
|
|
21
|
+
value: function getClientPath(options) {
|
|
22
|
+
throw new Error('Client needs implementation');
|
|
23
|
+
}
|
|
24
|
+
}]);
|
|
25
|
+
|
|
26
|
+
return BaseClient;
|
|
27
|
+
}();
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* eslint-disable
|
|
3
|
+
no-unused-vars
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
7
|
+
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
|
|
10
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
+
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
13
|
+
|
|
14
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
15
|
+
|
|
16
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
17
|
+
|
|
18
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
|
+
|
|
20
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
21
|
+
|
|
22
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
23
|
+
|
|
24
|
+
var SockJS = require('sockjs-client/dist/sockjs');
|
|
25
|
+
|
|
26
|
+
var BaseClient = require('./BaseClient');
|
|
27
|
+
|
|
28
|
+
module.exports =
|
|
29
|
+
/*#__PURE__*/
|
|
30
|
+
function (_BaseClient) {
|
|
31
|
+
_inherits(SockJSClient, _BaseClient);
|
|
32
|
+
|
|
33
|
+
function SockJSClient(url) {
|
|
34
|
+
var _this;
|
|
35
|
+
|
|
36
|
+
_classCallCheck(this, SockJSClient);
|
|
37
|
+
|
|
38
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(SockJSClient).call(this));
|
|
39
|
+
_this.sock = new SockJS(url);
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_createClass(SockJSClient, [{
|
|
44
|
+
key: "onOpen",
|
|
45
|
+
value: function onOpen(f) {
|
|
46
|
+
this.sock.onopen = f;
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "onClose",
|
|
50
|
+
value: function onClose(f) {
|
|
51
|
+
this.sock.onclose = f;
|
|
52
|
+
} // call f with the message string as the first argument
|
|
53
|
+
|
|
54
|
+
}, {
|
|
55
|
+
key: "onMessage",
|
|
56
|
+
value: function onMessage(f) {
|
|
57
|
+
this.sock.onmessage = function (e) {
|
|
58
|
+
f(e.data);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}], [{
|
|
62
|
+
key: "getClientPath",
|
|
63
|
+
value: function getClientPath(options) {
|
|
64
|
+
return require.resolve('./SockJSClient');
|
|
65
|
+
}
|
|
66
|
+
}]);
|
|
67
|
+
|
|
68
|
+
return SockJSClient;
|
|
69
|
+
}(BaseClient);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
|
|
7
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
8
|
+
|
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10
|
+
|
|
11
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
12
|
+
|
|
13
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
14
|
+
|
|
15
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
16
|
+
|
|
17
|
+
var BaseClient = require('./BaseClient');
|
|
18
|
+
|
|
19
|
+
module.exports =
|
|
20
|
+
/*#__PURE__*/
|
|
21
|
+
function (_BaseClient) {
|
|
22
|
+
_inherits(WebsocketClient, _BaseClient);
|
|
23
|
+
|
|
24
|
+
function WebsocketClient() {
|
|
25
|
+
_classCallCheck(this, WebsocketClient);
|
|
26
|
+
|
|
27
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(WebsocketClient).apply(this, arguments));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return WebsocketClient;
|
|
31
|
+
}(BaseClient);
|