webpack-dev-server 4.0.0 → 4.2.1

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/lib/options.json CHANGED
@@ -71,12 +71,14 @@
71
71
  },
72
72
  "ClientLogging": {
73
73
  "enum": ["none", "error", "warn", "info", "log", "verbose"],
74
- "decription": "Allows to set log level in the browser."
74
+ "decription": "Allows to set log level in the browser.",
75
+ "link": "https://webpack.js.org/configuration/dev-server/#logging"
75
76
  },
76
77
  "ClientOverlay": {
77
78
  "anyOf": [
78
79
  {
79
80
  "description": "Enables a full-screen overlay in the browser when there are compiler errors or warnings.",
81
+ "link": "https://webpack.js.org/configuration/dev-server/#overlay",
80
82
  "type": "boolean"
81
83
  },
82
84
  {
@@ -97,6 +99,7 @@
97
99
  },
98
100
  "ClientProgress": {
99
101
  "description": "Prints compilation progress in percentage in the browser.",
102
+ "link": "https://webpack.js.org/configuration/dev-server/#progress",
100
103
  "type": "boolean"
101
104
  },
102
105
  "ClientWebSocketTransport": {
@@ -108,7 +111,8 @@
108
111
  "$ref": "#/definitions/ClientWebSocketTransportString"
109
112
  }
110
113
  ],
111
- "description": "Allows to set custom web socket transport to communicate with dev server."
114
+ "description": "Allows to set custom web socket transport to communicate with dev server.",
115
+ "link": "https://webpack.js.org/configuration/dev-server/#websockettransport"
112
116
  },
113
117
  "ClientWebSocketTransportEnum": {
114
118
  "enum": ["sockjs", "ws"]
@@ -119,6 +123,7 @@
119
123
  },
120
124
  "ClientWebSocketURL": {
121
125
  "description": "Allows to specify URL to web socket server (useful when you're proxying dev server and client script does not always know where to connect to).",
126
+ "link": "https://webpack.js.org/configuration/dev-server/#websocketurl",
122
127
  "anyOf": [
123
128
  {
124
129
  "type": "string",
@@ -196,7 +201,7 @@
196
201
  },
197
202
  {
198
203
  "type": "object",
199
- "additionalProperties": false,
204
+ "additionalProperties": true,
200
205
  "properties": {
201
206
  "passphrase": {
202
207
  "type": "string",
@@ -206,8 +211,45 @@
206
211
  "type": "boolean",
207
212
  "description": "Request for an SSL certificate."
208
213
  },
214
+ "ca": {
215
+ "anyOf": [
216
+ {
217
+ "type": "array",
218
+ "items": {
219
+ "anyOf": [
220
+ {
221
+ "type": "string"
222
+ },
223
+ {
224
+ "instanceof": "Buffer"
225
+ }
226
+ ]
227
+ }
228
+ },
229
+ {
230
+ "type": "string"
231
+ },
232
+ {
233
+ "instanceof": "Buffer"
234
+ }
235
+ ],
236
+ "description": "Path to an SSL CA certificate or content of an SSL CA certificate."
237
+ },
209
238
  "cacert": {
210
239
  "anyOf": [
240
+ {
241
+ "type": "array",
242
+ "items": {
243
+ "anyOf": [
244
+ {
245
+ "type": "string"
246
+ },
247
+ {
248
+ "instanceof": "Buffer"
249
+ }
250
+ ]
251
+ }
252
+ },
211
253
  {
212
254
  "type": "string"
213
255
  },
@@ -215,10 +257,23 @@
215
257
  "instanceof": "Buffer"
216
258
  }
217
259
  ],
218
- "description": "Path to an SSL CA certificate."
260
+ "description": "Path to an SSL CA certificate or content of an SSL CA certificate."
219
261
  },
220
- "key": {
262
+ "cert": {
221
263
  "anyOf": [
264
+ {
265
+ "type": "array",
266
+ "items": {
267
+ "anyOf": [
268
+ {
269
+ "type": "string"
270
+ },
271
+ {
272
+ "instanceof": "Buffer"
273
+ }
274
+ ]
275
+ }
276
+ },
222
277
  {
223
278
  "type": "string"
224
279
  },
@@ -226,10 +281,51 @@
226
281
  "instanceof": "Buffer"
227
282
  }
228
283
  ],
229
- "description": "Path to an SSL key."
284
+ "description": "Path to an SSL certificate or content of an SSL certificate."
230
285
  },
231
- "pfx": {
286
+ "crl": {
287
+ "anyOf": [
288
+ {
289
+ "type": "array",
290
+ "items": {
291
+ "anyOf": [
292
+ {
293
+ "type": "string"
294
+ },
295
+ {
296
+ "instanceof": "Buffer"
297
+ }
298
+ ]
299
+ }
300
+ },
301
+ {
302
+ "type": "string"
303
+ },
304
+ {
305
+ "instanceof": "Buffer"
306
+ }
307
+ ],
308
+ "description": "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists)."
309
+ },
310
+ "key": {
232
311
  "anyOf": [
312
+ {
313
+ "type": "array",
314
+ "items": {
315
+ "anyOf": [
316
+ {
317
+ "type": "string"
318
+ },
319
+ {
320
+ "instanceof": "Buffer"
321
+ },
322
+ {
323
+ "type": "object",
324
+ "additionalProperties": true
325
+ }
326
+ ]
327
+ }
328
+ },
233
329
  {
234
330
  "type": "string"
235
331
  },
@@ -237,10 +333,27 @@
237
333
  "instanceof": "Buffer"
238
334
  }
239
335
  ],
240
- "description": "Path to an SSL pfx file."
336
+ "description": "Path to an SSL key or content of an SSL key."
241
337
  },
242
- "cert": {
338
+ "pfx": {
243
339
  "anyOf": [
340
+ {
341
+ "type": "array",
342
+ "items": {
343
+ "anyOf": [
344
+ {
345
+ "type": "string"
346
+ },
347
+ {
348
+ "instanceof": "Buffer"
349
+ },
350
+ {
351
+ "type": "object",
352
+ "additionalProperties": true
353
+ }
354
+ ]
355
+ }
356
+ },
244
357
  {
245
358
  "type": "string"
246
359
  },
@@ -248,7 +361,7 @@
248
361
  "instanceof": "Buffer"
249
362
  }
250
363
  ],
251
- "description": "Path to an SSL certificate."
364
+ "description": "Path to an SSL pfx file or content of an SSL pfx file."
252
365
  }
253
366
  }
254
367
  }
@@ -326,6 +439,11 @@
326
439
  "description": "Enables reload/refresh the page(s) when file changes are detected (enabled by default).",
327
440
  "link": "https://webpack.js.org/configuration/dev-server/#devserverlivereload"
328
441
  },
442
+ "MagicHTML": {
443
+ "type": "boolean",
444
+ "description": "Tells dev-server whether to enable magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').",
445
+ "link": "https://webpack.js.org/configuration/dev-server/#devservermagichtml"
446
+ },
329
447
  "OnAfterSetupMiddleware": {
330
448
  "instanceof": "Function",
331
449
  "description": "Provides the ability to execute a custom function and apply custom middleware(s) after all other middlewares.",
@@ -514,10 +632,12 @@
514
632
  "directory": {
515
633
  "type": "string",
516
634
  "minLength": 1,
517
- "description": "Directory for static contents."
635
+ "description": "Directory for static contents.",
636
+ "link": "https://webpack.js.org/configuration/dev-server/#directory"
518
637
  },
519
638
  "staticOptions": {
520
639
  "type": "object",
640
+ "link": "https://webpack.js.org/configuration/dev-server/#staticoptions",
521
641
  "additionalProperties": true
522
642
  },
523
643
  "publicPath": {
@@ -533,7 +653,8 @@
533
653
  "type": "string"
534
654
  }
535
655
  ],
536
- "description": "The static files will be available in the browser under this public path."
656
+ "description": "The static files will be available in the browser under this public path.",
657
+ "link": "https://webpack.js.org/configuration/dev-server/#publicpath"
537
658
  },
538
659
  "serveIndex": {
539
660
  "anyOf": [
@@ -545,7 +666,8 @@
545
666
  "additionalProperties": true
546
667
  }
547
668
  ],
548
- "description": "Tells dev server to use serveIndex middleware when enabled."
669
+ "description": "Tells dev server to use serveIndex middleware when enabled.",
670
+ "link": "https://webpack.js.org/configuration/dev-server/#serveindex"
549
671
  },
550
672
  "watch": {
551
673
  "anyOf": [
@@ -558,7 +680,8 @@
558
680
  "link": "https://github.com/paulmillr/chokidar#api"
559
681
  }
560
682
  ],
561
- "description": "Watches for files in static content directory."
683
+ "description": "Watches for files in static content directory.",
684
+ "link": "https://webpack.js.org/configuration/dev-server/#watch"
562
685
  }
563
686
  }
564
687
  },
@@ -719,6 +842,9 @@
719
842
  "liveReload": {
720
843
  "$ref": "#/definitions/LiveReload"
721
844
  },
845
+ "magicHtml": {
846
+ "$ref": "#/definitions/MagicHTML"
847
+ },
722
848
  "onAfterSetupMiddleware": {
723
849
  "$ref": "#/definitions/OnAfterSetupMiddleware"
724
850
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-dev-server",
3
- "version": "4.0.0",
3
+ "version": "4.2.1",
4
4
  "description": "Serves a webpack app. Updates the browser on changes.",
5
5
  "bin": "bin/webpack-dev-server.js",
6
6
  "main": "lib/Server.js",
@@ -32,7 +32,7 @@
32
32
  "release": "standard-version"
33
33
  },
34
34
  "dependencies": {
35
- "ansi-html": "^0.0.7",
35
+ "ansi-html-community": "^0.0.8",
36
36
  "bonjour": "^3.5.0",
37
37
  "chokidar": "^3.5.1",
38
38
  "colorette": "^1.2.2",
@@ -55,7 +55,7 @@
55
55
  "spdy": "^4.0.2",
56
56
  "strip-ansi": "^7.0.0",
57
57
  "url": "^0.11.0",
58
- "webpack-dev-middleware": "^5.0.0",
58
+ "webpack-dev-middleware": "^5.1.0",
59
59
  "ws": "^8.1.0"
60
60
  },
61
61
  "devDependencies": {
@@ -1,352 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * An Entry, it can be of type string or string[] or Object<string | string[],string>
5
- * @typedef {(string[] | string | Object<string | string[],string>)} Entry
6
- */
7
-
8
- class DevServerPlugin {
9
- /**
10
- * @param {Object} options - Dev-Server options
11
- */
12
- constructor(options) {
13
- this.options = options;
14
- }
15
-
16
- getWebsocketTransport() {
17
- let ClientImplementation;
18
- let clientImplementationFound = true;
19
-
20
- const isKnownWebSocketServerImplementation =
21
- this.options.webSocketServer &&
22
- typeof this.options.webSocketServer.type === "string" &&
23
- (this.options.webSocketServer.type === "ws" ||
24
- this.options.webSocketServer.type === "sockjs");
25
-
26
- let clientTransport;
27
-
28
- if (this.options.client) {
29
- if (typeof this.options.client.webSocketTransport !== "undefined") {
30
- clientTransport = this.options.client.webSocketTransport;
31
- } else if (isKnownWebSocketServerImplementation) {
32
- clientTransport = this.options.webSocketServer.type;
33
- } else {
34
- clientTransport = "ws";
35
- }
36
- } else {
37
- clientTransport = "ws";
38
- }
39
-
40
- switch (typeof clientTransport) {
41
- case "string":
42
- // could be 'sockjs', 'ws', or a path that should be required
43
- if (clientTransport === "sockjs") {
44
- ClientImplementation = require.resolve(
45
- "../../client/clients/SockJSClient"
46
- );
47
- } else if (clientTransport === "ws") {
48
- ClientImplementation = require.resolve(
49
- "../../client/clients/WebSocketClient"
50
- );
51
- } else {
52
- try {
53
- // eslint-disable-next-line import/no-dynamic-require
54
- ClientImplementation = require.resolve(clientTransport);
55
- } catch (e) {
56
- clientImplementationFound = false;
57
- }
58
- }
59
- break;
60
- default:
61
- clientImplementationFound = false;
62
- }
63
-
64
- if (!clientImplementationFound) {
65
- throw new Error(
66
- `${
67
- !isKnownWebSocketServerImplementation
68
- ? "When you use custom web socket implementation you must explicitly specify client.webSocketTransport. "
69
- : ""
70
- }client.webSocketTransport must be a string denoting a default implementation (e.g. 'sockjs', 'ws') or a full path to a JS file via require.resolve(...) which exports a class `
71
- );
72
- }
73
-
74
- return ClientImplementation;
75
- }
76
-
77
- /**
78
- * @returns {string}
79
- */
80
- getWebSocketURL() {
81
- const { options } = this;
82
- const searchParams = new URLSearchParams();
83
-
84
- /** @type {"ws:" | "wss:" | "http:" | "https:" | "auto:"} */
85
- let protocol;
86
-
87
- // We are proxying dev server and need to specify custom `hostname`
88
- if (typeof options.client.webSocketURL.protocol !== "undefined") {
89
- protocol = options.client.webSocketURL.protocol;
90
- } else {
91
- protocol = options.https ? "wss:" : "ws:";
92
- }
93
-
94
- searchParams.set("protocol", protocol);
95
-
96
- if (typeof options.client.webSocketURL.username !== "undefined") {
97
- searchParams.set("username", options.client.webSocketURL.username);
98
- }
99
-
100
- if (typeof options.client.webSocketURL.password !== "undefined") {
101
- searchParams.set("password", options.client.webSocketURL.password);
102
- }
103
-
104
- /** @type {string} */
105
- let hostname;
106
-
107
- // SockJS is not supported server mode, so `hostname` and `port` can't specified, let's ignore them
108
- // TODO show warning about this
109
- const isSockJSType = options.webSocketServer.type === "sockjs";
110
-
111
- // We are proxying dev server and need to specify custom `hostname`
112
- if (typeof options.client.webSocketURL.hostname !== "undefined") {
113
- hostname = options.client.webSocketURL.hostname;
114
- }
115
- // Web socket server works on custom `hostname`, only for `ws` because `sock-js` is not support custom `hostname`
116
- else if (
117
- typeof options.webSocketServer.options.host !== "undefined" &&
118
- !isSockJSType
119
- ) {
120
- hostname = options.webSocketServer.options.host;
121
- }
122
- // The `host` option is specified
123
- else if (typeof this.options.host !== "undefined") {
124
- hostname = this.options.host;
125
- }
126
- // The `port` option is not specified
127
- else {
128
- hostname = "0.0.0.0";
129
- }
130
-
131
- searchParams.set("hostname", hostname);
132
-
133
- /** @type {number | string} */
134
- let port;
135
-
136
- // We are proxying dev server and need to specify custom `port`
137
- if (typeof options.client.webSocketURL.port !== "undefined") {
138
- port = options.client.webSocketURL.port;
139
- }
140
- // Web socket server works on custom `port`, only for `ws` because `sock-js` is not support custom `port`
141
- else if (
142
- typeof options.webSocketServer.options.port !== "undefined" &&
143
- !isSockJSType
144
- ) {
145
- port = options.webSocketServer.options.port;
146
- }
147
- // The `port` option is specified
148
- else if (typeof options.port === "number") {
149
- port = options.port;
150
- }
151
- // The `port` option is specified using `string`
152
- else if (typeof options.port === "string" && options.port !== "auto") {
153
- port = Number(options.port);
154
- }
155
- // The `port` option is not specified or set to `auto`
156
- else {
157
- port = "0";
158
- }
159
-
160
- searchParams.set("port", String(port));
161
-
162
- /** @type {string} */
163
- let pathname = "";
164
-
165
- // We are proxying dev server and need to specify custom `pathname`
166
- if (typeof options.client.webSocketURL.pathname !== "undefined") {
167
- pathname = options.client.webSocketURL.pathname;
168
- }
169
- // Web socket server works on custom `path`
170
- else if (
171
- typeof options.webSocketServer.options.prefix !== "undefined" ||
172
- typeof options.webSocketServer.options.path !== "undefined"
173
- ) {
174
- pathname =
175
- options.webSocketServer.options.prefix ||
176
- options.webSocketServer.options.path;
177
- }
178
-
179
- searchParams.set("pathname", pathname);
180
-
181
- if (typeof options.client.logging !== "undefined") {
182
- searchParams.set("logging", options.client.logging);
183
- }
184
-
185
- return searchParams.toString();
186
- }
187
-
188
- /**
189
- * @returns {string}
190
- */
191
- getClientEntry() {
192
- /** @type {string} */
193
- const webSocketURL = this.options.webSocketServer
194
- ? this.getWebSocketURL()
195
- : "";
196
-
197
- return `${require.resolve("../../client/index.js")}?${webSocketURL}`;
198
- }
199
-
200
- getHotEntry() {
201
- const { options } = this;
202
-
203
- /** @type {(string[] | string)} */
204
- let hotEntry;
205
-
206
- if (options.hot === "only") {
207
- hotEntry = require.resolve("webpack/hot/only-dev-server");
208
- } else if (options.hot) {
209
- hotEntry = require.resolve("webpack/hot/dev-server");
210
- }
211
-
212
- return hotEntry;
213
- }
214
-
215
- /**
216
- * @param {Object} compilerOptions
217
- * @returns {boolean}
218
- */
219
- // eslint-disable-next-line class-methods-use-this
220
- isWebTarget(compilerOptions) {
221
- return compilerOptions.externalsPresets
222
- ? compilerOptions.externalsPresets.web
223
- : [
224
- "web",
225
- "webworker",
226
- "electron-preload",
227
- "electron-renderer",
228
- "node-webkit",
229
- // eslint-disable-next-line no-undefined
230
- undefined,
231
- null,
232
- ].includes(compilerOptions.target);
233
- }
234
-
235
- /**
236
- * Apply the plugin
237
- * @param {Object} compiler the compiler instance
238
- * @returns {void}
239
- */
240
- apply(compiler) {
241
- /**
242
- *
243
- * Description of the option for checkInject method
244
- * @typedef {Function} checkInjectOptionsParam
245
- * @param {Object} _config - compilerConfig
246
- * @return {Boolean}
247
- */
248
-
249
- const additionalEntries = [];
250
-
251
- // TODO maybe empty empty client
252
- if (this.options.client && this.isWebTarget(compiler.options)) {
253
- const clientEntry = this.getClientEntry();
254
-
255
- additionalEntries.push(clientEntry);
256
- }
257
-
258
- if (this.options.hot) {
259
- const hotEntry = this.getHotEntry();
260
-
261
- additionalEntries.push(hotEntry);
262
- }
263
-
264
- const webpack = compiler.webpack || require("webpack");
265
-
266
- // use a hook to add entries if available
267
- if (typeof webpack.EntryPlugin !== "undefined") {
268
- for (const additionalEntry of additionalEntries) {
269
- new webpack.EntryPlugin(compiler.context, additionalEntry, {
270
- // eslint-disable-next-line no-undefined
271
- name: undefined,
272
- }).apply(compiler);
273
- }
274
- } else {
275
- /**
276
- * prependEntry Method for webpack 4
277
- * @param {Entry} originalEntry
278
- * @param {Entry} newAdditionalEntries
279
- * @returns {Entry}
280
- */
281
- const prependEntry = (originalEntry, newAdditionalEntries) => {
282
- if (typeof originalEntry === "function") {
283
- return () =>
284
- Promise.resolve(originalEntry()).then((entry) =>
285
- prependEntry(entry, newAdditionalEntries)
286
- );
287
- }
288
-
289
- if (
290
- typeof originalEntry === "object" &&
291
- !Array.isArray(originalEntry)
292
- ) {
293
- /** @type {Object<string,string>} */
294
- const clone = {};
295
-
296
- Object.keys(originalEntry).forEach((key) => {
297
- // entry[key] should be a string here
298
- const entryDescription = originalEntry[key];
299
-
300
- clone[key] = prependEntry(entryDescription, newAdditionalEntries);
301
- });
302
-
303
- return clone;
304
- }
305
-
306
- // in this case, entry is a string or an array.
307
- // make sure that we do not add duplicates.
308
- /** @type {Entry} */
309
- const entriesClone = additionalEntries.slice(0);
310
-
311
- [].concat(originalEntry).forEach((newEntry) => {
312
- if (!entriesClone.includes(newEntry)) {
313
- entriesClone.push(newEntry);
314
- }
315
- });
316
-
317
- return entriesClone;
318
- };
319
-
320
- compiler.options.entry = prependEntry(
321
- compiler.options.entry || "./src",
322
- additionalEntries
323
- );
324
- compiler.hooks.entryOption.call(
325
- compiler.options.context,
326
- compiler.options.entry
327
- );
328
- }
329
-
330
- const providePlugin = new webpack.ProvidePlugin({
331
- __webpack_dev_server_client__: this.getWebsocketTransport(),
332
- });
333
-
334
- providePlugin.apply(compiler);
335
-
336
- compiler.options.plugins = compiler.options.plugins || [];
337
-
338
- if (
339
- this.options.hot &&
340
- !compiler.options.plugins.find(
341
- (p) => p.constructor === webpack.HotModuleReplacementPlugin
342
- )
343
- ) {
344
- // apply the HMR plugin, if it didn't exist before.
345
- const plugin = new webpack.HotModuleReplacementPlugin();
346
-
347
- plugin.apply(compiler);
348
- }
349
- }
350
- }
351
-
352
- module.exports = DevServerPlugin;