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
@@ -71,20 +71,19 @@ class ReadStream extends Readable {
71
71
  }
72
72
  /**
73
73
  * @private
74
- * @method #readFilePadding
74
+ * @method #readPadding
75
75
  * @param fd The file descriptor.
76
76
  * @param range The current range.
77
77
  * @param size The number of bytes to read.
78
78
  */
79
- #readFilePadding(fd, range, size) {
79
+ #readPadding(fd, range, size) {
80
80
  let bytesRead = 0;
81
81
  const padding = this.#getPadding(range);
82
- const hasRangePadding = padding != null;
83
82
  // If padding exists.
84
- if (hasRangePadding) {
83
+ if (padding != null) {
85
84
  const { length } = padding;
86
85
  const begin = this.#bytesRead;
87
- if (length > 0 && begin < length) {
86
+ if (begin < length) {
88
87
  bytesRead = Math.min(size, length - begin);
89
88
  const end = begin + bytesRead;
90
89
  this.push(padding.subarray(begin, end));
@@ -92,14 +91,13 @@ class ReadStream extends Readable {
92
91
  }
93
92
  }
94
93
  // If no padding or read completed.
95
- if (bytesRead <= 0) {
94
+ if (bytesRead < size) {
96
95
  this.#bytesRead = 0;
97
- const readState = this.#readState;
98
96
  // Change read state.
99
- switch (readState) {
97
+ switch (this.#readState) {
100
98
  case 0 /* ReadState.PREFIX */:
101
99
  this.#readState = 1 /* ReadState.RANGE */;
102
- this.#readFileRange(fd, range, size);
100
+ this.#readFileRange(fd, range, size - bytesRead);
103
101
  break;
104
102
  case 2 /* ReadState.SUFFIX */:
105
103
  this.#currentRangeIndex++;
@@ -108,7 +106,7 @@ class ReadStream extends Readable {
108
106
  if (nextRange == null) {
109
107
  this.push(null);
110
108
  } else {
111
- this.#readFilePadding(fd, nextRange, size);
109
+ this.#readPadding(fd, nextRange, size - bytesRead);
112
110
  }
113
111
  break;
114
112
  }
@@ -122,39 +120,40 @@ class ReadStream extends Readable {
122
120
  * @param size The number of bytes to read.
123
121
  */
124
122
  #readFileRange(fd, range, size) {
125
- this.#reading = true;
123
+ const { length } = range;
126
124
  const bytesRead = this.#bytesRead;
127
- const position = range.offset + bytesRead;
128
- const buffer = Buffer.allocUnsafeSlow(Math.min(size, range.length - bytesRead));
129
- // Read file range.
130
- this.#fs.read(fd, buffer, 0, buffer.length, position, (readError, bytesRead, buffer) => {
131
- this.#reading = false;
132
- // Tell ._destroy() that it's safe to close the fd now.
133
- if (this.destroyed) {
134
- this.emit(DISPOSE_EVENT, readError);
135
- } else {
136
- if (readError != null) {
125
+ // File range not finished.
126
+ if (bytesRead < length) {
127
+ this.#reading = true;
128
+ const bytesToRead = Math.min(size, length - bytesRead);
129
+ const buffer = Buffer.allocUnsafeSlow(bytesToRead);
130
+ const position = range.offset + bytesRead;
131
+ // Read file range.
132
+ this.#fs.read(fd, buffer, 0, bytesToRead, 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 if (readError != null) {
137
138
  this.destroy(readError);
139
+ } else if (bytesRead !== bytesToRead) {
140
+ this.destroy(new RangeError('invalid read operation'));
138
141
  } else {
139
- if (bytesRead > 0) {
140
- if (bytesRead !== buffer.length) {
141
- // Slow path. Shrink to fit.
142
- // Copy instead of slice so that we don't retain
143
- // large backing buffer for small reads.
144
- const chunk = Buffer.allocUnsafeSlow(bytesRead);
145
- buffer.copy(chunk, 0, 0, bytesRead);
146
- buffer = chunk;
147
- }
148
- this.push(buffer);
149
- this.#bytesRead += bytesRead;
150
- } else {
142
+ this.push(buffer);
143
+ this.#bytesRead += bytesRead;
144
+ // file range read completed.
145
+ if (bytesRead < size) {
151
146
  this.#bytesRead = 0;
152
147
  this.#readState = 2 /* ReadState.SUFFIX */;
153
- this.#readFilePadding(fd, range, size);
148
+ this.#readPadding(fd, range, size - bytesRead);
154
149
  }
155
150
  }
156
- }
157
- });
151
+ });
152
+ } else {
153
+ this.#bytesRead = 0;
154
+ this.#readState = 2 /* ReadState.SUFFIX */;
155
+ this.#readPadding(fd, range, size);
156
+ }
158
157
  }
159
158
  /**
160
159
  * @override
@@ -169,12 +168,11 @@ class ReadStream extends Readable {
169
168
  if (fd == null || range == null) {
170
169
  this.push(null);
171
170
  } else {
172
- const readState = this.#readState;
173
171
  // Read bytes from range.
174
- switch (readState) {
172
+ switch (this.#readState) {
175
173
  case 0 /* ReadState.PREFIX */:
176
174
  case 2 /* ReadState.SUFFIX */:
177
- this.#readFilePadding(fd, range, size);
175
+ this.#readPadding(fd, range, size);
178
176
  break;
179
177
  case 1 /* ReadState.RANGE */:
180
178
  this.#readFileRange(fd, range, size);
@@ -4,24 +4,26 @@
4
4
  import { Context } from 'koa';
5
5
  import { Stats } from 'node:fs';
6
6
  import { FileSystem } from './utils/fs.js';
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
@@ -31,18 +31,14 @@ class Service {
31
31
  * @param options The file service options.
32
32
  */
33
33
  constructor(root, options) {
34
- this.#options = options;
35
34
  this.#root = unixify(resolve(root));
36
- }
37
- /**
38
- * @private
39
- * @method #isIgnore
40
- * @description Check if path is ignore.
41
- * @param path The path to check.
42
- */
43
- #isIgnore(path) {
44
- const { ignore } = this.#options;
45
- return (isFunction(ignore) ? ignore(path) : false) === true;
35
+ const { ignore, headers, highWaterMark = 65536 } = options;
36
+ this.#options = {
37
+ ...options,
38
+ ignore: isFunction(ignore) ? ignore : () => false,
39
+ headers: isFunction(headers) ? headers : () => headers,
40
+ highWaterMark: isFunction(highWaterMark) ? highWaterMark : () => highWaterMark
41
+ };
46
42
  }
47
43
  /**
48
44
  * @private
@@ -54,21 +50,15 @@ class Service {
54
50
  */
55
51
  async #setupHeaders({ response }, path, stats) {
56
52
  const options = this.#options;
57
- const { headers } = options;
58
53
  // Set status.
59
54
  response.status = 200;
60
55
  // Set Content-Type.
61
56
  response.type = extname(path);
62
- // Set headers.
57
+ // Get headers.
58
+ const headers = await options.headers(path, stats);
59
+ // If headers not empty, set headers.
63
60
  if (headers) {
64
- if (isFunction(headers)) {
65
- const fields = await headers(path, stats);
66
- if (fields) {
67
- response.set(fields);
68
- }
69
- } else {
70
- response.set(headers);
71
- }
61
+ response.set(headers);
72
62
  }
73
63
  // Accept-Ranges.
74
64
  if (options.acceptRanges === false) {
@@ -120,12 +110,12 @@ class Service {
120
110
  if (isOutRoot(path, root)) {
121
111
  return false;
122
112
  }
113
+ // Get options.
114
+ const options = this.#options;
123
115
  // Is ignore path or file (403).
124
- if (this.#isIgnore(path)) {
116
+ if (await options.ignore(path)) {
125
117
  return false;
126
118
  }
127
- // Get options.
128
- const options = this.#options;
129
119
  // File stats.
130
120
  const stats = await stat(options.fs, path);
131
121
  // Check file stats.
@@ -182,7 +172,10 @@ class Service {
182
172
  return context.throw(400);
183
173
  }
184
174
  // Set response body.
185
- response.body = new ReadStream(path, ranges, options);
175
+ response.body = new ReadStream(path, ranges, {
176
+ fs: options.fs,
177
+ highWaterMark: await options.highWaterMark(path, stats)
178
+ });
186
179
  // File found.
187
180
  return true;
188
181
  }
@@ -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
@@ -10,16 +10,17 @@
10
10
  import { ready } from './utils/ready.js';
11
11
  import { createMemfs } from './utils/fs.js';
12
12
  import { middleware } from './middleware.js';
13
- import { PLUGIN_NAME } from '../utils.js';
14
13
  import { setupHooks } from './utils/setupHooks.js';
15
14
  import { setupWatching } from './utils/setupWatching.js';
16
15
  import { setupWriteToDisk } from './utils/setupWriteToDisk.js';
16
+ import { assertPublicPath, PLUGIN_NAME } from '../utils.js';
17
17
  import { setupOutputFileSystem } from './utils/setupOutputFileSystem.js';
18
18
 
19
19
  /**
20
20
  * @module index
21
21
  */
22
22
  function setup(compiler, options) {
23
+ assertPublicPath(compiler);
23
24
  const context = {
24
25
  compiler,
25
26
  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
@@ -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
@@ -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
@@ -20,13 +20,13 @@ function getStats(stats) {
20
20
  return [stats];
21
21
  }
22
22
  function getPublicPath(compilation) {
23
- const { publicPath } = compilation.outputOptions;
23
+ const { publicPath = '' } = compilation.outputOptions;
24
24
  // @see https://webpack.js.org/guides/public-path/#automatic-publicpath
25
25
  if (publicPath === 'auto') {
26
26
  return '/';
27
27
  }
28
28
  // Get public path.
29
- const path = compilation.getPath(publicPath ?? '');
29
+ const path = compilation.getPath(publicPath);
30
30
  // Get public path without protocol.
31
31
  return new URL(path, 'https://127.0.0.1').pathname;
32
32
  }
@@ -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
@@ -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
@@ -21,6 +21,14 @@ function isBoolean(value) {
21
21
  function isFunction(value) {
22
22
  return typeof value === 'function';
23
23
  }
24
+ function assertPublicPath(compiler) {
25
+ const compilers = getCompilers(compiler);
26
+ for (const { options } of compilers) {
27
+ if (isFunction(options.output.publicPath)) {
28
+ throw new TypeError('function type public path is not supported');
29
+ }
30
+ }
31
+ }
24
32
  function getCompilers(compiler) {
25
33
  if (isMultiCompiler(compiler)) {
26
34
  return compiler.compilers;
@@ -31,4 +39,4 @@ function isMultiCompiler(compiler) {
31
39
  return 'compilers' in compiler;
32
40
  }
33
41
 
34
- export { PLUGIN_NAME, getCompilers, isBoolean, isFunction, isMultiCompiler, isString };
42
+ export { PLUGIN_NAME, assertPublicPath, getCompilers, isBoolean, isFunction, isMultiCompiler, isString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-dev-service",
3
- "version": "0.15.7",
3
+ "version": "0.15.9",
4
4
  "description": "A koa 2 middleware for webpack development and hot reloading.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -54,7 +54,7 @@
54
54
  "@types/koa": "^2.15.0",
55
55
  "@types/ws": "^8.18.1",
56
56
  "etag": "^1.8.1",
57
- "memfs": "^4.17.2",
57
+ "memfs": "^4.23.0",
58
58
  "range-parser": "^1.2.1",
59
59
  "schema-utils": "^4.3.2",
60
60
  "supports-color": "^10.0.0",
@@ -66,17 +66,17 @@
66
66
  "@rollup/plugin-replace": "^6.0.2",
67
67
  "@rollup/plugin-typescript": "^12.1.4",
68
68
  "@rollup/plugin-url": "^8.0.2",
69
- "@swc/core": "^1.12.11",
69
+ "@swc/core": "^1.13.2",
70
70
  "@swc/helpers": "^0.5.17",
71
71
  "@types/etag": "^1.8.4",
72
- "@types/node": "^24.0.12",
72
+ "@types/node": "^24.1.0",
73
73
  "@types/range-parser": "^1.2.7",
74
74
  "@types/react": "^19.1.8",
75
75
  "@types/react-dom": "^19.1.6",
76
76
  "css-loader": "^7.1.2",
77
77
  "dts-paths": "^1.1.10",
78
78
  "html-webpack-plugin": "^5.6.3",
79
- "koa": "^3.0.0",
79
+ "koa": "^3.0.1",
80
80
  "koa-compress": "^5.1.1",
81
81
  "magic-string": "^0.30.17",
82
82
  "mini-css-extract-plugin": "^2.9.2",
@@ -84,10 +84,10 @@
84
84
  "react": "^19.1.0",
85
85
  "react-dom": "^19.1.0",
86
86
  "rimraf": "^6.0.1",
87
- "rollup": "^4.44.2",
87
+ "rollup": "^4.46.1",
88
88
  "swc-loader": "^0.2.6",
89
89
  "typescript": "^5.8.3",
90
- "webpack": "^5.100.0"
90
+ "webpack": "^5.100.2"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "koa": ">=2.0.0",