webpack-dev-server 3.7.2 → 3.9.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 CHANGED
@@ -2,6 +2,61 @@
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.9.0](https://github.com/webpack/webpack-dev-server/compare/v3.8.2...v3.9.0) (2019-10-22)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * add `hostname` and `port` to bonjour name to prevent name collisions ([#2276](https://github.com/webpack/webpack-dev-server/issues/2276)) ([d8af2d9](https://github.com/webpack/webpack-dev-server/commit/d8af2d9))
11
+ * add `extKeyUsage` to self-signed cert ([#2274](https://github.com/webpack/webpack-dev-server/issues/2274)) ([a4dbc3b](https://github.com/webpack/webpack-dev-server/commit/a4dbc3b))
12
+
13
+
14
+ ### Features
15
+
16
+ * add multiple `openPage` support ([#2266](https://github.com/webpack/webpack-dev-server/issues/2266)) ([c9e9178](https://github.com/webpack/webpack-dev-server/commit/c9e9178))
17
+
18
+ ### [3.8.2](https://github.com/webpack/webpack-dev-server/compare/v3.8.1...v3.8.2) (2019-10-02)
19
+
20
+ ### Security
21
+
22
+ * update `selfsigned` package
23
+
24
+ ### [3.8.1](https://github.com/webpack/webpack-dev-server/compare/v3.8.0...v3.8.1) (2019-09-16)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * add null check for connection.headers ([#2200](https://github.com/webpack/webpack-dev-server/issues/2200)) ([7964997](https://github.com/webpack/webpack-dev-server/commit/7964997))
30
+ * false positive for an absolute path in the `ContentBase` option on windows ([#2202](https://github.com/webpack/webpack-dev-server/issues/2202)) ([68ecf78](https://github.com/webpack/webpack-dev-server/commit/68ecf78))
31
+ * add status in quiet log level ([#2235](https://github.com/webpack/webpack-dev-server/issues/2235)) ([7e2224e](https://github.com/webpack/webpack-dev-server/commit/7e2224e))
32
+ * scriptHost in client ([#2246](https://github.com/webpack/webpack-dev-server/issues/2246)) ([00903f6](https://github.com/webpack/webpack-dev-server/commit/00903f6))
33
+
34
+ ## [3.8.0](https://github.com/webpack/webpack-dev-server/compare/v3.7.2...v3.8.0) (2019-08-09)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * **server:** fix setupExitSignals usage ([#2181](https://github.com/webpack/webpack-dev-server/issues/2181)) ([bbe410e](https://github.com/webpack/webpack-dev-server/commit/bbe410e))
40
+ * **server:** set port before instantiating server ([#2143](https://github.com/webpack/webpack-dev-server/issues/2143)) ([cfbf229](https://github.com/webpack/webpack-dev-server/commit/cfbf229))
41
+ * check for name of HotModuleReplacementPlugin to avoid RangeError ([#2146](https://github.com/webpack/webpack-dev-server/issues/2146)) ([4579775](https://github.com/webpack/webpack-dev-server/commit/4579775))
42
+ * **server:** check for external urls in array ([#1980](https://github.com/webpack/webpack-dev-server/issues/1980)) ([fa78347](https://github.com/webpack/webpack-dev-server/commit/fa78347))
43
+ * **server:** fix header check for socket server ([#2077](https://github.com/webpack/webpack-dev-server/issues/2077)) ([7f51859](https://github.com/webpack/webpack-dev-server/commit/7f51859))
44
+ * **server:** stricter headers security check ([#2092](https://github.com/webpack/webpack-dev-server/issues/2092)) ([078ddca](https://github.com/webpack/webpack-dev-server/commit/078ddca))
45
+
46
+
47
+ ### Features
48
+
49
+ * **server:** add transportMode ([#2116](https://github.com/webpack/webpack-dev-server/issues/2116)) ([b5b9cb4](https://github.com/webpack/webpack-dev-server/commit/b5b9cb4))
50
+ * **server:** serverMode 'ws' option ([#2082](https://github.com/webpack/webpack-dev-server/issues/2082)) ([04483f4](https://github.com/webpack/webpack-dev-server/commit/04483f4))
51
+ * **server/client:** made progress option available to API ([#1961](https://github.com/webpack/webpack-dev-server/issues/1961)) ([56274e4](https://github.com/webpack/webpack-dev-server/commit/56274e4))
52
+
53
+ ### Potential Breaking changes
54
+
55
+ We have migrated `serverMode` and `clientMode` to `transportMode` as an experimental option. If you want to use this feature, you have to change your settings.
56
+
57
+ Related PR: https://github.com/webpack/webpack-dev-server/pull/2116
58
+
59
+
5
60
  ### [3.7.2](https://github.com/webpack/webpack-dev-server/compare/v3.7.1...v3.7.2) (2019-06-17)
6
61
 
7
62
 
@@ -0,0 +1,195 @@
1
+ 'use strict';
2
+
3
+ const ADVANCED_GROUP = 'Advanced options:';
4
+ const DISPLAY_GROUP = 'Stats options:';
5
+ const SSL_GROUP = 'SSL options:';
6
+ const CONNECTION_GROUP = 'Connection options:';
7
+ const RESPONSE_GROUP = 'Response options:';
8
+ const BASIC_GROUP = 'Basic options:';
9
+
10
+ module.exports = {
11
+ devServer: [
12
+ {
13
+ name: 'bonjour',
14
+ type: Boolean,
15
+ describe: 'Broadcasts the server via ZeroConf networking on start',
16
+ },
17
+ {
18
+ name: 'lazy',
19
+ type: Boolean,
20
+ describe: 'Lazy',
21
+ },
22
+ {
23
+ name: 'liveReload',
24
+ type: Boolean,
25
+ defaultValue: true,
26
+ describe: 'Enables/Disables live reloading on changing files',
27
+ },
28
+ {
29
+ name: 'serveIndex',
30
+ type: Boolean,
31
+ describe: 'Enables/Disables serveIndex middleware',
32
+ defaultValue: true,
33
+ },
34
+ {
35
+ name: 'inline',
36
+ type: Boolean,
37
+ defaultValue: true,
38
+ describe:
39
+ 'Inline mode (set to false to disable including client scripts like livereload)',
40
+ },
41
+ {
42
+ name: 'profile',
43
+ type: Boolean,
44
+ describe: 'Print compilation profile data for progress steps',
45
+ },
46
+ {
47
+ name: 'progress',
48
+ type: Boolean,
49
+ describe: 'Print compilation progress in percentage',
50
+ group: BASIC_GROUP,
51
+ },
52
+ {
53
+ name: 'hot-only',
54
+ type: Boolean,
55
+ describe: 'Do not refresh page if HMR fails',
56
+ group: ADVANCED_GROUP,
57
+ },
58
+ {
59
+ name: 'stdin',
60
+ type: Boolean,
61
+ describe: 'close when stdin ends',
62
+ },
63
+ {
64
+ name: 'open',
65
+ type: String,
66
+ describe:
67
+ 'Open the default browser, or optionally specify a browser name',
68
+ },
69
+ {
70
+ name: 'useLocalIp',
71
+ type: Boolean,
72
+ describe: 'Open default browser with local IP',
73
+ },
74
+ {
75
+ name: 'open-page',
76
+ type: String,
77
+ describe: 'Open default browser with the specified page',
78
+ },
79
+ {
80
+ name: 'client-log-level',
81
+ type: String,
82
+ group: DISPLAY_GROUP,
83
+ defaultValue: 'info',
84
+ describe:
85
+ 'Log level in the browser (trace, debug, info, warn, error or silent)',
86
+ },
87
+ {
88
+ name: 'https',
89
+ type: Boolean,
90
+ group: SSL_GROUP,
91
+ describe: 'HTTPS',
92
+ },
93
+ {
94
+ name: 'http2',
95
+ type: Boolean,
96
+ group: SSL_GROUP,
97
+ describe: 'HTTP/2, must be used with HTTPS',
98
+ },
99
+ {
100
+ name: 'key',
101
+ type: String,
102
+ describe: 'Path to a SSL key.',
103
+ group: SSL_GROUP,
104
+ },
105
+ {
106
+ name: 'cert',
107
+ type: String,
108
+ describe: 'Path to a SSL certificate.',
109
+ group: SSL_GROUP,
110
+ },
111
+ {
112
+ name: 'cacert',
113
+ type: String,
114
+ describe: 'Path to a SSL CA certificate.',
115
+ group: SSL_GROUP,
116
+ },
117
+ {
118
+ name: 'pfx',
119
+ type: String,
120
+ describe: 'Path to a SSL pfx file.',
121
+ group: SSL_GROUP,
122
+ },
123
+ {
124
+ name: 'pfx-passphrase',
125
+ type: String,
126
+ describe: 'Passphrase for pfx file.',
127
+ group: SSL_GROUP,
128
+ },
129
+ {
130
+ name: 'content-base',
131
+ type: String,
132
+ describe: 'A directory or URL to serve HTML content from.',
133
+ group: RESPONSE_GROUP,
134
+ },
135
+ {
136
+ name: 'watch-content-base',
137
+ type: Boolean,
138
+ describe: 'Enable live-reloading of the content-base.',
139
+ group: RESPONSE_GROUP,
140
+ },
141
+ {
142
+ name: 'history-api-fallback',
143
+ type: Boolean,
144
+ describe: 'Fallback to /index.html for Single Page Applications.',
145
+ group: RESPONSE_GROUP,
146
+ },
147
+ {
148
+ name: 'compress',
149
+ type: Boolean,
150
+ describe: 'Enable gzip compression',
151
+ group: RESPONSE_GROUP,
152
+ },
153
+ // findPort is currently not set up
154
+ {
155
+ name: 'port',
156
+ type: Number,
157
+ describe: 'The port',
158
+ group: CONNECTION_GROUP,
159
+ },
160
+ {
161
+ name: 'disable-host-check',
162
+ type: Boolean,
163
+ describe: 'Will not check the host',
164
+ group: CONNECTION_GROUP,
165
+ },
166
+ {
167
+ name: 'socket',
168
+ type: String,
169
+ describe: 'Socket to listen',
170
+ group: CONNECTION_GROUP,
171
+ },
172
+ {
173
+ name: 'public',
174
+ type: String,
175
+ describe: 'The public hostname/ip address of the server',
176
+ group: CONNECTION_GROUP,
177
+ },
178
+ {
179
+ name: 'host',
180
+ type: String,
181
+ describe: 'The hostname/ip address the server will bind to',
182
+ group: CONNECTION_GROUP,
183
+ },
184
+ // use command-line-args "multiple" option, allowing the usage: --allowed-hosts host1 host2 host3
185
+ // instead of the old, comma-separated syntax: --allowed-hosts host1,host2,host3
186
+ {
187
+ name: 'allowed-hosts',
188
+ type: String,
189
+ describe:
190
+ 'A list of hosts that are allowed to access the dev server, separated by spaces',
191
+ group: CONNECTION_GROUP,
192
+ multiple: true,
193
+ },
194
+ ],
195
+ };
package/bin/options.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  /* eslint-disable
4
- global-require,
5
4
  multiline-ternary,
6
5
  space-before-function-paren
7
6
  */
@@ -37,6 +36,10 @@ const options = {
37
36
  describe:
38
37
  'Inline mode (set to false to disable including client scripts like livereload)',
39
38
  },
39
+ profile: {
40
+ type: 'boolean',
41
+ describe: 'Print compilation profile data for progress steps',
42
+ },
40
43
  progress: {
41
44
  type: 'boolean',
42
45
  describe: 'Print compilation progress in percentage',
@@ -15,13 +15,18 @@ const setupExitSignals = require('../lib/utils/setupExitSignals');
15
15
  const colors = require('../lib/utils/colors');
16
16
  const processOptions = require('../lib/utils/processOptions');
17
17
  const createLogger = require('../lib/utils/createLogger');
18
- const findPort = require('../lib/utils/findPort');
19
18
  const getVersions = require('../lib/utils/getVersions');
20
19
  const options = require('./options');
21
20
 
22
21
  let server;
23
-
24
- setupExitSignals(server);
22
+ const serverData = {
23
+ server: null,
24
+ };
25
+ // we must pass an object that contains the server object as a property so that
26
+ // we can update this server property later, and setupExitSignals will be able to
27
+ // recognize that the server has been instantiated, because we will set
28
+ // serverData.server to the new server object.
29
+ setupExitSignals(serverData);
25
30
 
26
31
  // Prefer the local installation of webpack-dev-server
27
32
  if (importLocal(__filename)) {
@@ -97,14 +102,9 @@ function startDevServer(config, options) {
97
102
  throw err;
98
103
  }
99
104
 
100
- if (options.progress) {
101
- new webpack.ProgressPlugin({
102
- profile: argv.profile,
103
- }).apply(compiler);
104
- }
105
-
106
105
  try {
107
106
  server = new Server(compiler, options, log);
107
+ serverData.server = server;
108
108
  } catch (err) {
109
109
  if (err.name === 'ValidationError') {
110
110
  log.error(colors.error(options.stats.colors, err.message));
@@ -154,18 +154,11 @@ function startDevServer(config, options) {
154
154
  });
155
155
  });
156
156
  } else {
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) => {
157
+ server.listen(options.port, options.host, (err) => {
158
+ if (err) {
167
159
  throw err;
168
- });
160
+ }
161
+ });
169
162
  }
170
163
  }
171
164
 
@@ -37,6 +37,11 @@ function (_BaseClient) {
37
37
 
38
38
  _this = _possibleConstructorReturn(this, _getPrototypeOf(SockJSClient).call(this));
39
39
  _this.sock = new SockJS(url);
40
+
41
+ _this.sock.onerror = function (err) {// TODO: use logger to log the error event once client and client-src
42
+ // are reorganized to have the same directory structure
43
+ };
44
+
40
45
  return _this;
41
46
  }
42
47
 
@@ -1,9 +1,18 @@
1
1
  'use strict';
2
+ /* global WebSocket */
3
+
4
+ /* eslint-disable
5
+ no-unused-vars
6
+ */
2
7
 
3
8
  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
9
 
5
10
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
11
 
12
+ 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); } }
13
+
14
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15
+
7
16
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
8
17
 
9
18
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
@@ -21,11 +30,45 @@ module.exports =
21
30
  function (_BaseClient) {
22
31
  _inherits(WebsocketClient, _BaseClient);
23
32
 
24
- function WebsocketClient() {
33
+ function WebsocketClient(url) {
34
+ var _this;
35
+
25
36
  _classCallCheck(this, WebsocketClient);
26
37
 
27
- return _possibleConstructorReturn(this, _getPrototypeOf(WebsocketClient).apply(this, arguments));
38
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(WebsocketClient).call(this));
39
+ _this.client = new WebSocket(url.replace(/^http/, 'ws'));
40
+
41
+ _this.client.onerror = function (err) {// TODO: use logger to log the error event once client and client-src
42
+ // are reorganized to have the same directory structure
43
+ };
44
+
45
+ return _this;
28
46
  }
29
47
 
48
+ _createClass(WebsocketClient, [{
49
+ key: "onOpen",
50
+ value: function onOpen(f) {
51
+ this.client.onopen = f;
52
+ }
53
+ }, {
54
+ key: "onClose",
55
+ value: function onClose(f) {
56
+ this.client.onclose = f;
57
+ } // call f with the message string as the first argument
58
+
59
+ }, {
60
+ key: "onMessage",
61
+ value: function onMessage(f) {
62
+ this.client.onmessage = function (e) {
63
+ f(e.data);
64
+ };
65
+ }
66
+ }], [{
67
+ key: "getClientPath",
68
+ value: function getClientPath(options) {
69
+ return require.resolve('./WebsocketClient');
70
+ }
71
+ }]);
72
+
30
73
  return WebsocketClient;
31
74
  }(BaseClient);