webpack-dev-service 0.15.7 → 0.15.9

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.
Files changed (67) hide show
  1. package/cjs/client/client.cjs +1 -1
  2. package/cjs/client/events.cjs +1 -1
  3. package/cjs/client/hot.cjs +1 -1
  4. package/cjs/client/index.cjs +1 -1
  5. package/cjs/client/main.cjs +1 -1
  6. package/cjs/client/ui/Overlay.cjs +1 -1
  7. package/cjs/client/ui/Progress.cjs +1 -1
  8. package/cjs/client/ui/images/webpack-logo.svg.cjs +1 -1
  9. package/cjs/client/ui/utils.cjs +1 -1
  10. package/cjs/server/compose.cjs +1 -1
  11. package/cjs/server/dev/ReadStream.cjs +38 -40
  12. package/cjs/server/dev/Service.cjs +19 -26
  13. package/cjs/server/dev/Service.d.cts +9 -7
  14. package/cjs/server/dev/index.cjs +3 -2
  15. package/cjs/server/dev/middleware.cjs +1 -1
  16. package/cjs/server/dev/utils/fs.cjs +1 -1
  17. package/cjs/server/dev/utils/hash.cjs +1 -1
  18. package/cjs/server/dev/utils/http.cjs +1 -1
  19. package/cjs/server/dev/utils/http.d.cts +1 -1
  20. package/cjs/server/dev/utils/path.cjs +1 -1
  21. package/cjs/server/dev/utils/paths.cjs +3 -3
  22. package/cjs/server/dev/utils/ready.cjs +1 -1
  23. package/cjs/server/dev/utils/setupHooks.cjs +1 -1
  24. package/cjs/server/dev/utils/setupOutputFileSystem.cjs +1 -1
  25. package/cjs/server/dev/utils/setupWatching.cjs +1 -1
  26. package/cjs/server/dev/utils/setupWriteToDisk.cjs +1 -1
  27. package/cjs/server/hot/Socket.cjs +1 -1
  28. package/cjs/server/hot/index.cjs +1 -1
  29. package/cjs/server/hot/utils.cjs +1 -1
  30. package/cjs/server/index.cjs +1 -1
  31. package/cjs/server/schema.cjs +1 -1
  32. package/cjs/server/utils.cjs +10 -1
  33. package/cjs/server/utils.d.cts +1 -0
  34. package/esm/client/client.js +1 -1
  35. package/esm/client/events.js +1 -1
  36. package/esm/client/hot.js +1 -1
  37. package/esm/client/index.js +1 -1
  38. package/esm/client/main.js +1 -1
  39. package/esm/client/ui/Overlay.js +1 -1
  40. package/esm/client/ui/Progress.js +1 -1
  41. package/esm/client/ui/images/webpack-logo.svg.js +1 -1
  42. package/esm/client/ui/utils.js +1 -1
  43. package/esm/server/compose.js +1 -1
  44. package/esm/server/dev/ReadStream.js +38 -40
  45. package/esm/server/dev/Service.d.ts +9 -7
  46. package/esm/server/dev/Service.js +19 -26
  47. package/esm/server/dev/index.js +3 -2
  48. package/esm/server/dev/middleware.js +1 -1
  49. package/esm/server/dev/utils/fs.js +1 -1
  50. package/esm/server/dev/utils/hash.js +1 -1
  51. package/esm/server/dev/utils/http.d.ts +1 -1
  52. package/esm/server/dev/utils/http.js +1 -1
  53. package/esm/server/dev/utils/path.js +1 -1
  54. package/esm/server/dev/utils/paths.js +3 -3
  55. package/esm/server/dev/utils/ready.js +1 -1
  56. package/esm/server/dev/utils/setupHooks.js +1 -1
  57. package/esm/server/dev/utils/setupOutputFileSystem.js +1 -1
  58. package/esm/server/dev/utils/setupWatching.js +1 -1
  59. package/esm/server/dev/utils/setupWriteToDisk.js +1 -1
  60. package/esm/server/hot/Socket.js +1 -1
  61. package/esm/server/hot/index.js +1 -1
  62. package/esm/server/hot/utils.js +1 -1
  63. package/esm/server/index.js +1 -1
  64. package/esm/server/schema.js +1 -1
  65. package/esm/server/utils.d.ts +1 -0
  66. package/esm/server/utils.js +10 -2
  67. package/package.json +7 -7
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -73,20 +73,19 @@ class ReadStream extends node_stream.Readable {
73
73
  }
74
74
  /**
75
75
  * @private
76
- * @method #readFilePadding
76
+ * @method #readPadding
77
77
  * @param fd The file descriptor.
78
78
  * @param range The current range.
79
79
  * @param size The number of bytes to read.
80
80
  */
81
- #readFilePadding(fd, range, size) {
81
+ #readPadding(fd, range, size) {
82
82
  let bytesRead = 0;
83
83
  const padding = this.#getPadding(range);
84
- const hasRangePadding = padding != null;
85
84
  // If padding exists.
86
- if (hasRangePadding) {
85
+ if (padding != null) {
87
86
  const { length } = padding;
88
87
  const begin = this.#bytesRead;
89
- if (length > 0 && begin < length) {
88
+ if (begin < length) {
90
89
  bytesRead = Math.min(size, length - begin);
91
90
  const end = begin + bytesRead;
92
91
  this.push(padding.subarray(begin, end));
@@ -94,14 +93,13 @@ class ReadStream extends node_stream.Readable {
94
93
  }
95
94
  }
96
95
  // If no padding or read completed.
97
- if (bytesRead <= 0) {
96
+ if (bytesRead < size) {
98
97
  this.#bytesRead = 0;
99
- const readState = this.#readState;
100
98
  // Change read state.
101
- switch (readState) {
99
+ switch (this.#readState) {
102
100
  case 0 /* ReadState.PREFIX */:
103
101
  this.#readState = 1 /* ReadState.RANGE */;
104
- this.#readFileRange(fd, range, size);
102
+ this.#readFileRange(fd, range, size - bytesRead);
105
103
  break;
106
104
  case 2 /* ReadState.SUFFIX */:
107
105
  this.#currentRangeIndex++;
@@ -110,7 +108,7 @@ class ReadStream extends node_stream.Readable {
110
108
  if (nextRange == null) {
111
109
  this.push(null);
112
110
  } else {
113
- this.#readFilePadding(fd, nextRange, size);
111
+ this.#readPadding(fd, nextRange, size - bytesRead);
114
112
  }
115
113
  break;
116
114
  }
@@ -124,39 +122,40 @@ class ReadStream extends node_stream.Readable {
124
122
  * @param size The number of bytes to read.
125
123
  */
126
124
  #readFileRange(fd, range, size) {
127
- this.#reading = true;
125
+ const { length } = range;
128
126
  const bytesRead = this.#bytesRead;
129
- const position = range.offset + bytesRead;
130
- const buffer = node_buffer.Buffer.allocUnsafeSlow(Math.min(size, range.length - bytesRead));
131
- // Read file range.
132
- this.#fs.read(fd, buffer, 0, buffer.length, position, (readError, bytesRead, buffer) => {
133
- this.#reading = false;
134
- // Tell ._destroy() that it's safe to close the fd now.
135
- if (this.destroyed) {
136
- this.emit(DISPOSE_EVENT, readError);
137
- } else {
138
- if (readError != null) {
127
+ // File range not finished.
128
+ if (bytesRead < length) {
129
+ this.#reading = true;
130
+ const bytesToRead = Math.min(size, length - bytesRead);
131
+ const buffer = node_buffer.Buffer.allocUnsafeSlow(bytesToRead);
132
+ const position = range.offset + bytesRead;
133
+ // Read file range.
134
+ this.#fs.read(fd, buffer, 0, bytesToRead, position, (readError, bytesRead, buffer) => {
135
+ this.#reading = false;
136
+ // Tell ._destroy() that it's safe to close the fd now.
137
+ if (this.destroyed) {
138
+ this.emit(DISPOSE_EVENT, readError);
139
+ } else if (readError != null) {
139
140
  this.destroy(readError);
141
+ } else if (bytesRead !== bytesToRead) {
142
+ this.destroy(new RangeError('invalid read operation'));
140
143
  } else {
141
- if (bytesRead > 0) {
142
- if (bytesRead !== buffer.length) {
143
- // Slow path. Shrink to fit.
144
- // Copy instead of slice so that we don't retain
145
- // large backing buffer for small reads.
146
- const chunk = node_buffer.Buffer.allocUnsafeSlow(bytesRead);
147
- buffer.copy(chunk, 0, 0, bytesRead);
148
- buffer = chunk;
149
- }
150
- this.push(buffer);
151
- this.#bytesRead += bytesRead;
152
- } else {
144
+ this.push(buffer);
145
+ this.#bytesRead += bytesRead;
146
+ // file range read completed.
147
+ if (bytesRead < size) {
153
148
  this.#bytesRead = 0;
154
149
  this.#readState = 2 /* ReadState.SUFFIX */;
155
- this.#readFilePadding(fd, range, size);
150
+ this.#readPadding(fd, range, size - bytesRead);
156
151
  }
157
152
  }
158
- }
159
- });
153
+ });
154
+ } else {
155
+ this.#bytesRead = 0;
156
+ this.#readState = 2 /* ReadState.SUFFIX */;
157
+ this.#readPadding(fd, range, size);
158
+ }
160
159
  }
161
160
  /**
162
161
  * @override
@@ -171,12 +170,11 @@ class ReadStream extends node_stream.Readable {
171
170
  if (fd == null || range == null) {
172
171
  this.push(null);
173
172
  } else {
174
- const readState = this.#readState;
175
173
  // Read bytes from range.
176
- switch (readState) {
174
+ switch (this.#readState) {
177
175
  case 0 /* ReadState.PREFIX */:
178
176
  case 2 /* ReadState.SUFFIX */:
179
- this.#readFilePadding(fd, range, size);
177
+ this.#readPadding(fd, range, size);
180
178
  break;
181
179
  case 1 /* ReadState.RANGE */:
182
180
  this.#readFileRange(fd, range, size);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -39,18 +39,14 @@ class Service {
39
39
  * @param options The file service options.
40
40
  */
41
41
  constructor(root, options) {
42
- this.#options = options;
43
42
  this.#root = path.unixify(node_path.resolve(root));
44
- }
45
- /**
46
- * @private
47
- * @method #isIgnore
48
- * @description Check if path is ignore.
49
- * @param path The path to check.
50
- */
51
- #isIgnore(path) {
52
- const { ignore } = this.#options;
53
- return (utils.isFunction(ignore) ? ignore(path) : false) === true;
43
+ const { ignore, headers, highWaterMark = 65536 } = options;
44
+ this.#options = {
45
+ ...options,
46
+ ignore: utils.isFunction(ignore) ? ignore : () => false,
47
+ headers: utils.isFunction(headers) ? headers : () => headers,
48
+ highWaterMark: utils.isFunction(highWaterMark) ? highWaterMark : () => highWaterMark
49
+ };
54
50
  }
55
51
  /**
56
52
  * @private
@@ -62,21 +58,15 @@ class Service {
62
58
  */
63
59
  async #setupHeaders({ response }, path, stats) {
64
60
  const options = this.#options;
65
- const { headers } = options;
66
61
  // Set status.
67
62
  response.status = 200;
68
63
  // Set Content-Type.
69
64
  response.type = node_path.extname(path);
70
- // Set headers.
65
+ // Get headers.
66
+ const headers = await options.headers(path, stats);
67
+ // If headers not empty, set headers.
71
68
  if (headers) {
72
- if (utils.isFunction(headers)) {
73
- const fields = await headers(path, stats);
74
- if (fields) {
75
- response.set(fields);
76
- }
77
- } else {
78
- response.set(headers);
79
- }
69
+ response.set(headers);
80
70
  }
81
71
  // Accept-Ranges.
82
72
  if (options.acceptRanges === false) {
@@ -128,12 +118,12 @@ class Service {
128
118
  if (path.isOutRoot(path$1, root)) {
129
119
  return false;
130
120
  }
121
+ // Get options.
122
+ const options = this.#options;
131
123
  // Is ignore path or file (403).
132
- if (this.#isIgnore(path$1)) {
124
+ if (await options.ignore(path$1)) {
133
125
  return false;
134
126
  }
135
- // Get options.
136
- const options = this.#options;
137
127
  // File stats.
138
128
  const stats = await fs.stat(options.fs, path$1);
139
129
  // Check file stats.
@@ -190,7 +180,10 @@ class Service {
190
180
  return context.throw(400);
191
181
  }
192
182
  // Set response body.
193
- response.body = new ReadStream.ReadStream(path$1, ranges, options);
183
+ response.body = new ReadStream.ReadStream(path$1, ranges, {
184
+ fs: options.fs,
185
+ highWaterMark: await options.highWaterMark(path$1, stats)
186
+ });
194
187
  // File found.
195
188
  return true;
196
189
  }
@@ -4,24 +4,26 @@
4
4
  import { Context } from 'koa';
5
5
  import { Stats } from 'node:fs';
6
6
  import { FileSystem } from './utils/fs.cjs';
7
- interface IgnoreFunction {
8
- (path: string): boolean;
9
- }
10
7
  interface Headers {
11
8
  [key: string]: string | string[];
12
9
  }
13
- type FileStats = Stats | null | undefined;
10
+ interface IgnoreFunction {
11
+ (path: string): Promise<boolean> | boolean;
12
+ }
13
+ interface HighWaterMarkFunction {
14
+ (path: string, stats: Stats): Promise<number> | number;
15
+ }
14
16
  interface HeadersFunction {
15
- (path: string, stats: FileStats): Promise<Headers | void> | Headers | void;
17
+ (path: string, stats: Stats): Promise<Headers | void> | Headers | void;
16
18
  }
17
19
  export interface Options {
18
- fs: FileSystem;
19
20
  etag?: boolean;
21
+ fs: FileSystem;
20
22
  acceptRanges?: boolean;
21
23
  lastModified?: boolean;
22
- highWaterMark?: number;
23
24
  ignore?: IgnoreFunction;
24
25
  headers?: Headers | HeadersFunction;
26
+ highWaterMark?: number | HighWaterMarkFunction;
25
27
  }
26
28
  /**
27
29
  * @class Service
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -12,16 +12,17 @@
12
12
  const ready = require('./utils/ready.cjs');
13
13
  const fs = require('./utils/fs.cjs');
14
14
  const middleware = require('./middleware.cjs');
15
- const utils = require('../utils.cjs');
16
15
  const setupHooks = require('./utils/setupHooks.cjs');
17
16
  const setupWatching = require('./utils/setupWatching.cjs');
18
17
  const setupWriteToDisk = require('./utils/setupWriteToDisk.cjs');
18
+ const utils = require('../utils.cjs');
19
19
  const setupOutputFileSystem = require('./utils/setupOutputFileSystem.cjs');
20
20
 
21
21
  /**
22
22
  * @module index
23
23
  */
24
24
  function setup(compiler, options) {
25
+ utils.assertPublicPath(compiler);
25
26
  const context = {
26
27
  compiler,
27
28
  stats: null,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -34,4 +34,4 @@ export declare function isPreconditionFailed({ request, response }: Context): bo
34
34
  * @param context The koa context.
35
35
  * @param stats The file stats.
36
36
  */
37
- export declare function parseRanges(context: Context, stats: Stats): Range[] | -1 | -2;
37
+ export declare function parseRanges(context: Context, stats: Stats): -1 | -2 | Range[];
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -22,13 +22,13 @@ function getStats(stats) {
22
22
  return [stats];
23
23
  }
24
24
  function getPublicPath(compilation) {
25
- const { publicPath } = compilation.outputOptions;
25
+ const { publicPath = '' } = compilation.outputOptions;
26
26
  // @see https://webpack.js.org/guides/public-path/#automatic-publicpath
27
27
  if (publicPath === 'auto') {
28
28
  return '/';
29
29
  }
30
30
  // Get public path.
31
- const path = compilation.getPath(publicPath ?? '');
31
+ const path = compilation.getPath(publicPath);
32
32
  // Get public path without protocol.
33
33
  return new node_url.URL(path, 'https://127.0.0.1').pathname;
34
34
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -23,6 +23,14 @@ function isBoolean(value) {
23
23
  function isFunction(value) {
24
24
  return typeof value === 'function';
25
25
  }
26
+ function assertPublicPath(compiler) {
27
+ const compilers = getCompilers(compiler);
28
+ for (const { options } of compilers) {
29
+ if (isFunction(options.output.publicPath)) {
30
+ throw new TypeError('function type public path is not supported');
31
+ }
32
+ }
33
+ }
26
34
  function getCompilers(compiler) {
27
35
  if (isMultiCompiler(compiler)) {
28
36
  return compiler.compilers;
@@ -34,6 +42,7 @@ function isMultiCompiler(compiler) {
34
42
  }
35
43
 
36
44
  exports.PLUGIN_NAME = PLUGIN_NAME;
45
+ exports.assertPublicPath = assertPublicPath;
37
46
  exports.getCompilers = getCompilers;
38
47
  exports.isBoolean = isBoolean;
39
48
  exports.isFunction = isFunction;
@@ -7,5 +7,6 @@ export declare const PLUGIN_NAME: string;
7
7
  export declare function isString(value: unknown): value is string;
8
8
  export declare function isBoolean(value: unknown): value is boolean;
9
9
  export declare function isFunction(value: unknown): value is Function;
10
+ export declare function assertPublicPath(compiler: UnionCompiler): never | void;
10
11
  export declare function getCompilers(compiler: UnionCompiler): webpack.Compiler[];
11
12
  export declare function isMultiCompiler(compiler: UnionCompiler): compiler is webpack.MultiCompiler;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme
package/esm/client/hot.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.15.7
4
+ * @version 0.15.9
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A koa 2 middleware for webpack development and hot reloading.
7
7
  * @see https://github.com/nuintun/webpack-dev-service#readme