webpack-dev-service 0.11.7 → 0.11.8

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 (70) hide show
  1. package/cjs/client/client.cjs +15 -15
  2. package/cjs/client/events.cjs +1 -1
  3. package/cjs/client/hot.cjs +2 -2
  4. package/cjs/client/index.cjs +1 -1
  5. package/cjs/client/main.cjs +1 -1
  6. package/cjs/client/ui/{overlay.cjs → Overlay.cjs} +2 -2
  7. package/cjs/client/ui/{progress.cjs → Progress.cjs} +2 -2
  8. package/cjs/client/ui/utils.cjs +1 -1
  9. package/cjs/server/compose.cjs +1 -1
  10. package/cjs/server/dev/Service.cjs +1 -1
  11. package/cjs/server/dev/index.cjs +1 -1
  12. package/cjs/server/dev/middleware.cjs +1 -1
  13. package/cjs/server/dev/utils/fs.cjs +1 -1
  14. package/cjs/server/dev/utils/hash.cjs +1 -1
  15. package/cjs/server/dev/utils/http.cjs +1 -1
  16. package/cjs/server/dev/utils/path.cjs +1 -1
  17. package/cjs/server/dev/utils/paths.cjs +7 -10
  18. package/cjs/server/dev/utils/ready.cjs +1 -1
  19. package/cjs/server/dev/utils/setupHooks.cjs +3 -3
  20. package/cjs/server/dev/utils/setupOutputFileSystem.cjs +1 -1
  21. package/cjs/server/dev/utils/setupWatching.cjs +2 -2
  22. package/cjs/server/dev/utils/setupWriteToDisk.cjs +1 -1
  23. package/cjs/server/hot/Socket.cjs +3 -3
  24. package/cjs/server/hot/index.cjs +1 -1
  25. package/cjs/server/hot/utils.cjs +2 -2
  26. package/cjs/server/index.cjs +1 -1
  27. package/cjs/server/schema.cjs +1 -1
  28. package/cjs/server/utils.cjs +4 -4
  29. package/esm/client/client.js +3 -3
  30. package/esm/client/events.js +1 -1
  31. package/esm/client/hot.js +2 -2
  32. package/esm/client/index.js +1 -1
  33. package/esm/client/main.js +1 -1
  34. package/esm/client/ui/{overlay.js → Overlay.js} +2 -2
  35. package/esm/client/ui/{progress.js → Progress.js} +2 -2
  36. package/esm/client/ui/utils.js +1 -1
  37. package/esm/server/compose.js +1 -1
  38. package/esm/server/dev/Service.js +1 -1
  39. package/esm/server/dev/index.js +1 -1
  40. package/esm/server/dev/middleware.js +1 -1
  41. package/esm/server/dev/utils/fs.js +1 -1
  42. package/esm/server/dev/utils/hash.js +1 -1
  43. package/esm/server/dev/utils/http.js +1 -1
  44. package/esm/server/dev/utils/path.js +1 -1
  45. package/esm/server/dev/utils/paths.js +7 -10
  46. package/esm/server/dev/utils/ready.js +1 -1
  47. package/esm/server/dev/utils/setupHooks.js +4 -4
  48. package/esm/server/dev/utils/setupOutputFileSystem.js +1 -1
  49. package/esm/server/dev/utils/setupWatching.js +3 -3
  50. package/esm/server/dev/utils/setupWriteToDisk.js +1 -1
  51. package/esm/server/hot/Socket.js +2 -2
  52. package/esm/server/hot/index.js +1 -1
  53. package/esm/server/hot/utils.js +3 -3
  54. package/esm/server/index.js +1 -1
  55. package/esm/server/schema.js +1 -1
  56. package/esm/server/utils.js +4 -4
  57. package/global.d.ts +11 -0
  58. package/package.json +15 -15
  59. package/types/client/{message.d.ts → Message.d.ts} +9 -8
  60. package/types/client/events.d.ts +17 -17
  61. package/types/client/hot.d.ts +1 -1
  62. package/types/client/ui/{overlay.d.ts → Overlay.d.ts} +3 -3
  63. package/types/client/ui/{progress.d.ts → Progress.d.ts} +1 -1
  64. package/types/server/dev/interface.d.ts +3 -3
  65. package/types/server/dev/utils/fs.d.ts +4 -3
  66. package/types/server/hot/Socket.d.ts +2 -2
  67. package/types/server/hot/interface.d.ts +2 -2
  68. package/types/server/hot/utils.d.ts +3 -3
  69. package/types/server/interface.d.ts +8 -6
  70. package/types/server/utils.d.ts +4 -4
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.11.7
4
+ * @version 0.11.8
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.11.7
4
+ * @version 0.11.8
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.11.7
4
+ * @version 0.11.8
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.11.7
4
+ * @version 0.11.8
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,18 +21,12 @@ function normalize(path) {
21
21
  return `/${path}`;
22
22
  }
23
23
  function getStats(stats) {
24
- if (isMultiStatsMode(stats)) {
24
+ if ('stats' in stats) {
25
25
  return stats.stats;
26
26
  }
27
27
  // Return the stats.
28
28
  return [stats];
29
29
  }
30
- function getOutputPath(compilation) {
31
- // The `output.path` is always present and always absolute.
32
- const { path } = compilation.outputOptions;
33
- // Get the path.
34
- return compilation.getPath(path ?? '');
35
- }
36
30
  function getPublicPath(compilation) {
37
31
  const { publicPath } = compilation.outputOptions;
38
32
  // @see https://webpack.js.org/guides/public-path/#automatic-publicpath
@@ -48,8 +42,11 @@ function getPublicPath(compilation) {
48
42
  return normalize(path);
49
43
  }
50
44
  }
51
- function isMultiStatsMode(stats) {
52
- return 'stats' in stats;
45
+ function getOutputPath(compilation) {
46
+ // The `output.path` is always present and always absolute.
47
+ const { path } = compilation.outputOptions;
48
+ // Get the path.
49
+ return compilation.getPath(path ?? '');
53
50
  }
54
51
  function getPaths(stats) {
55
52
  const paths = [];
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.11.7
4
+ * @version 0.11.8
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,14 +1,14 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.11.7
4
+ * @version 0.11.8
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
8
8
  */
9
9
 
10
10
  import supportsColor from 'supports-color';
11
- import { PLUGIN_NAME, isMultiCompilerMode, isString, isBoolean } from '../../utils.js';
11
+ import { PLUGIN_NAME, isMultiCompiler, isString, isBoolean } from '../../utils.js';
12
12
 
13
13
  /**
14
14
  * @module setupHooks
@@ -31,7 +31,7 @@ function getStatsOptions(context) {
31
31
  const { compiler } = context;
32
32
  const { stats } = context.options;
33
33
  if (stats) {
34
- if (isMultiCompilerMode(compiler)) {
34
+ if (isMultiCompiler(compiler)) {
35
35
  return {
36
36
  children: compiler.compilers.map(() => {
37
37
  return normalizeStatsOptions(stats);
@@ -40,7 +40,7 @@ function getStatsOptions(context) {
40
40
  }
41
41
  return normalizeStatsOptions(stats);
42
42
  }
43
- if (isMultiCompilerMode(compiler)) {
43
+ if (isMultiCompiler(compiler)) {
44
44
  return {
45
45
  children: compiler.compilers.map(({ options }) => {
46
46
  return normalizeStatsOptions(options.stats);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.11.7
4
+ * @version 0.11.8
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,19 +1,19 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.11.7
4
+ * @version 0.11.8
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
8
8
  */
9
9
 
10
- import { isMultiCompilerMode } from '../../utils.js';
10
+ import { isMultiCompiler } from '../../utils.js';
11
11
 
12
12
  /**
13
13
  * @module setupWatching
14
14
  */
15
15
  function getWatching({ compiler, logger }) {
16
- const isMulti = isMultiCompilerMode(compiler);
16
+ const isMulti = isMultiCompiler(compiler);
17
17
  if (!isMulti && compiler.watching) {
18
18
  return compiler.watching;
19
19
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.11.7
4
+ * @version 0.11.8
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,16 +1,16 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.11.7
4
+ * @version 0.11.8
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
8
8
  */
9
9
 
10
+ import webpack from 'webpack';
10
11
  import { fileURLToPath } from 'url';
11
12
  import { resolve, dirname } from 'path';
12
13
  import WebSocket, { WebSocketServer } from 'ws';
13
- import webpack from 'webpack';
14
14
  import { PLUGIN_NAME, getCompilers } from '../utils.js';
15
15
  import { getOptions, getStatsOptions, getTimestamp, isUpgradable, hasIssues } from './utils.js';
16
16
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.11.7
4
+ * @version 0.11.8
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,13 +1,13 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.11.7
4
+ * @version 0.11.8
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
8
8
  */
9
9
 
10
- import { isMultiCompilerMode, isObject } from '../utils.js';
10
+ import { isMultiCompiler, isObject } from '../utils.js';
11
11
 
12
12
  /**
13
13
  * @module utils
@@ -67,7 +67,7 @@ function normalizeStatsOptions(statsOptions) {
67
67
  };
68
68
  }
69
69
  function getStatsOptions(compiler) {
70
- if (isMultiCompilerMode(compiler)) {
70
+ if (isMultiCompiler(compiler)) {
71
71
  return {
72
72
  children: compiler.compilers.map(({ options }) => {
73
73
  return normalizeStatsOptions(options.stats);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package webpack-dev-service
3
3
  * @license MIT
4
- * @version 0.11.7
4
+ * @version 0.11.8
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.11.7
4
+ * @version 0.11.8
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.11.7
4
+ * @version 0.11.8
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
@@ -25,13 +25,13 @@ function isFunction(value) {
25
25
  return typeof value === 'function';
26
26
  }
27
27
  function getCompilers(compiler) {
28
- if (isMultiCompilerMode(compiler)) {
28
+ if (isMultiCompiler(compiler)) {
29
29
  return compiler.compilers;
30
30
  }
31
31
  return [compiler];
32
32
  }
33
- function isMultiCompilerMode(compiler) {
33
+ function isMultiCompiler(compiler) {
34
34
  return 'compilers' in compiler;
35
35
  }
36
36
 
37
- export { PLUGIN_NAME, getCompilers, isBoolean, isFunction, isMultiCompilerMode, isObject, isString };
37
+ export { PLUGIN_NAME, getCompilers, isBoolean, isFunction, isMultiCompiler, isObject, isString };
package/global.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @module global.d.ts
3
+ */
4
+
5
+ /// <reference types="webpack/module" />
6
+
7
+ declare const __HOT_CLIENT__: string;
8
+
9
+ declare const __PLUGIN_NAME__: string;
10
+
11
+ declare type HotUpdateStatus = `${webpack.HotUpdateStatus}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-dev-service",
3
- "version": "0.11.7",
3
+ "version": "0.11.8",
4
4
  "description": "A koa 2 middleware for webpack development and hot reloading.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -35,7 +35,8 @@
35
35
  "files": [
36
36
  "cjs",
37
37
  "esm",
38
- "types"
38
+ "types",
39
+ "global.d.ts"
39
40
  ],
40
41
  "engines": {
41
42
  "node": ">=18.0.0"
@@ -73,46 +74,45 @@
73
74
  "build:types": "tsc --declaration --emitDeclarationOnly --declarationDir types && node tools/fix-types.js"
74
75
  },
75
76
  "dependencies": {
76
- "@nuintun/ansi": "^0.0.6",
77
+ "@nuintun/ansi": "^0.0.8",
77
78
  "@types/koa": "^2.15.0",
78
- "@types/ws": "^8.5.11",
79
+ "@types/ws": "^8.5.12",
79
80
  "destroy": "^1.2.0",
80
81
  "etag": "^1.8.1",
81
- "memfs": "^4.9.3",
82
+ "memfs": "^4.11.1",
82
83
  "range-parser": "^1.2.1",
83
84
  "schema-utils": "^4.2.0",
84
85
  "supports-color": "^9.4.0",
85
- "tslib": "^2.6.3",
86
+ "tslib": "^2.7.0",
86
87
  "ws": "^8.18.0"
87
88
  },
88
89
  "devDependencies": {
89
90
  "@rollup/plugin-replace": "^5.0.7",
90
91
  "@rollup/plugin-typescript": "^11.1.6",
91
- "@swc/core": "^1.7.0",
92
+ "@swc/core": "^1.7.22",
92
93
  "@swc/helpers": "^0.5.12",
93
94
  "@types/destroy": "^1.0.3",
94
95
  "@types/etag": "^1.8.3",
95
96
  "@types/koa-compose": "^3.2.8",
96
- "@types/node": "^20.14.11",
97
+ "@types/node": "^22.5.2",
97
98
  "@types/range-parser": "^1.2.7",
98
- "@types/react": "^18.3.3",
99
+ "@types/react": "^18.3.5",
99
100
  "@types/react-dom": "^18.3.0",
100
101
  "css-loader": "^7.1.2",
101
102
  "html-webpack-plugin": "^5.6.0",
102
103
  "koa": "^2.15.3",
103
104
  "koa-compress": "^5.1.1",
104
- "magic-string": "^0.30.10",
105
- "memfs": "^4.9.3",
106
- "mini-css-extract-plugin": "^2.9.0",
105
+ "magic-string": "^0.30.11",
106
+ "mini-css-extract-plugin": "^2.9.1",
107
107
  "prettier": "^3.3.3",
108
108
  "react": "^18.3.1",
109
109
  "react-dom": "^18.3.1",
110
110
  "rimraf": "^6.0.1",
111
- "rollup": "^4.18.1",
111
+ "rollup": "^4.21.2",
112
112
  "swc-loader": "^0.2.6",
113
113
  "tsc-alias": "^1.8.10",
114
- "typescript": "^5.5.3",
115
- "webpack": "^5.93.0"
114
+ "typescript": "^5.5.4",
115
+ "webpack": "^5.94.0"
116
116
  },
117
117
  "peerDependencies": {
118
118
  "koa": ">=2.0.0",
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * @module message
3
3
  */
4
- import { StatsError } from 'webpack';
5
- export interface Invalid {
4
+ import webpack from 'webpack';
5
+ export interface InvalidMessage {
6
6
  action: 'invalid';
7
7
  payload: {
8
8
  path: string;
9
9
  timestamp: number;
10
10
  };
11
11
  }
12
- export interface Progress {
12
+ export interface ProgressMessage {
13
13
  action: 'progress';
14
14
  payload: {
15
15
  value: number;
@@ -17,24 +17,25 @@ export interface Progress {
17
17
  message: string;
18
18
  };
19
19
  }
20
- export interface Hash {
20
+ export interface HashMessage {
21
21
  action: 'hash';
22
22
  payload: {
23
23
  hash: string;
24
24
  timestamp: number;
25
25
  };
26
26
  }
27
- export interface Issues {
27
+ export interface IssuesMessage {
28
28
  action: 'issues';
29
29
  payload: {
30
30
  timestamp: number;
31
- errors: StatsError[];
32
- warnings: StatsError[];
31
+ errors: webpack.StatsError[];
32
+ warnings: webpack.StatsError[];
33
33
  };
34
34
  }
35
- export interface OK {
35
+ export interface OkMessage {
36
36
  action: 'ok';
37
37
  payload: {
38
38
  timestamp: number;
39
39
  };
40
40
  }
41
+ export type Message = InvalidMessage | ProgressMessage | HashMessage | IssuesMessage | OkMessage;
@@ -2,20 +2,21 @@
2
2
  * @module events
3
3
  */
4
4
  import { Options } from './client';
5
- import * as Message from './message';
6
- interface Messages {
7
- ok: Message.OK['payload'];
8
- hash: Message.Hash['payload'];
9
- issues: Message.Issues['payload'];
10
- invalid: Message.Invalid['payload'];
11
- progress: Message.Progress['payload'];
5
+ import { GetProp } from '../server/interface';
6
+ import { HashMessage, InvalidMessage, IssuesMessage, OkMessage, ProgressMessage } from './Message';
7
+ export interface Messages {
8
+ ok: GetProp<OkMessage, 'payload'>;
9
+ hash: GetProp<HashMessage, 'payload'>;
10
+ issues: GetProp<IssuesMessage, 'payload'>;
11
+ invalid: GetProp<InvalidMessage, 'payload'>;
12
+ progress: GetProp<ProgressMessage, 'payload'>;
12
13
  }
13
- interface Events {
14
- ok(message: Messages['ok'], options: Options): void;
15
- hash(message: Messages['hash'], options: Options): void;
16
- issues(message: Messages['issues'], options: Options): void;
17
- invalid(message: Messages['invalid'], options: Options): void;
18
- progress(message: Messages['progress'], options: Options): void;
14
+ export interface Events {
15
+ ok(message: GetProp<Messages, 'ok'>, options: Options): void;
16
+ hash(message: GetProp<Messages, 'hash'>, options: Options): void;
17
+ issues(message: GetProp<Messages, 'issues'>, options: Options): void;
18
+ invalid(message: GetProp<Messages, 'invalid'>, options: Options): void;
19
+ progress(message: GetProp<Messages, 'progress'>, options: Options): void;
19
20
  }
20
21
  /**
21
22
  * @function on
@@ -23,13 +24,12 @@ interface Events {
23
24
  * @param event Event name.
24
25
  * @param callback Event listener callback.
25
26
  */
26
- export declare function on<E extends keyof Events>(event: E, callback: Events[E]): void;
27
+ export declare function on<E extends keyof Events>(event: E, callback: GetProp<Events, E>): void;
27
28
  /**
28
29
  * @function off
29
30
  * @description Remove an event listener callback.
30
31
  * @param event Event name.
31
32
  * @param callback Event listener callback.
32
33
  */
33
- export declare function off<E extends keyof Events>(event: E, callback?: Events[E]): void;
34
- export declare function emit<E extends keyof Events>(event: E, message: Messages[E], options: Options): void;
35
- export {};
34
+ export declare function off<E extends keyof Events>(event: E, callback?: GetProp<Events, E>): void;
35
+ export declare function emit<E extends keyof Events>(event: E, message: GetProp<Messages, E>, options: Options): void;
@@ -9,7 +9,7 @@ export declare function isUpdateAvailable(): boolean;
9
9
  /**
10
10
  * @function setHash
11
11
  * @description Set webpack hash.
12
- * @param value - The new hash value.
12
+ * @param value The new hash value.
13
13
  */
14
14
  export declare function setHash(value: string): void;
15
15
  /**
@@ -2,8 +2,8 @@
2
2
  * @module overlay
3
3
  * @see https://github.com/shellscape/webpack-plugin-serve
4
4
  */
5
- import { StatsError } from 'webpack';
6
- export default class Overlay {
5
+ import webpack from 'webpack';
6
+ export declare class Overlay {
7
7
  private hidden;
8
8
  private readonly name;
9
9
  private readonly close;
@@ -13,7 +13,7 @@ export default class Overlay {
13
13
  private readonly warningsList;
14
14
  private readonly warningsTitle;
15
15
  constructor(name: string);
16
- setIssues(type: 'errors' | 'warnings', issues: StatsError[]): void;
16
+ setIssues(type: 'errors' | 'warnings', issues: webpack.StatsError[]): void;
17
17
  show(): void;
18
18
  hide(): void;
19
19
  }
@@ -3,7 +3,7 @@
3
3
  * @see https://github.com/shellscape/webpack-plugin-serve
4
4
  * @see https://www.zhangxinxu.com/wordpress/2015/07/svg-circle-loading
5
5
  */
6
- export default class Progress {
6
+ export declare class Progress {
7
7
  private timer?;
8
8
  private hidden;
9
9
  private readonly svg;
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @module interface
3
3
  */
4
- import { StatsOptions } from 'webpack';
4
+ import webpack from 'webpack';
5
5
  import { FileSystem } from './utils/fs';
6
6
  import { Options as ServiceOptions, Service } from './Service';
7
- import { ICompiler, ILogger, IStats, IStatsOptions, IWatching } from '../../server/interface';
7
+ import { ICompiler, ILogger, IStats, IStatsOptions, IWatching, Optional } from '../../server/interface';
8
8
  export interface Callback {
9
9
  (stats: IStats): void;
10
10
  }
@@ -22,7 +22,7 @@ export interface Options extends Omit<ServiceOptions, 'fs'> {
22
22
  fs?: FileSystem;
23
23
  stats?: IStatsOptions;
24
24
  writeToDisk?: boolean | ((targetPath: string) => boolean);
25
- onCompilationDone?(stats: IStats, statsOptions: Readonly<StatsOptions>): void;
25
+ onCompilationDone?(stats: IStats, statsOptions: Readonly<webpack.StatsOptions>): void;
26
26
  }
27
27
  export type FileService = [publicPath: string, service: Service];
28
28
  export interface Context {
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * @module fs
3
3
  */
4
- import { Compiler } from 'webpack';
4
+ import webpack from 'webpack';
5
5
  import { ReadStream, Stats } from 'fs';
6
+ import { GetProp } from '../../../server/interface';
6
7
  type PathLike = string | Buffer | URL;
7
8
  type FileStats = Stats | null | undefined;
8
- type IFileSystem = NonNullable<Compiler['outputFileSystem']>;
9
+ type OutputFileSystem = GetProp<webpack.Compiler, 'outputFileSystem'>;
9
10
  /**
10
11
  * @function stat
11
12
  * @description Get file stats.
@@ -13,7 +14,7 @@ type IFileSystem = NonNullable<Compiler['outputFileSystem']>;
13
14
  * @param path The file path.
14
15
  */
15
16
  export declare function stat(fs: FileSystem, path: string): Promise<FileStats>;
16
- export interface FileSystem extends IFileSystem {
17
+ export interface FileSystem extends OutputFileSystem {
17
18
  createReadStream(
18
19
  path: PathLike,
19
20
  options?: {
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @module Socket
3
3
  */
4
+ import webpack from 'webpack';
4
5
  import { Context } from 'koa';
5
6
  import WebSocket from 'ws';
6
- import { StatsCompilation } from 'webpack';
7
7
  import { Options } from './interface';
8
8
  import { ICompiler } from '../../server/interface';
9
9
  export declare class Socket {
@@ -19,5 +19,5 @@ export declare class Socket {
19
19
  clients(): Set<WebSocket>;
20
20
  upgrade(context: Context): boolean;
21
21
  broadcast<T>(clients: Set<WebSocket> | WebSocket[], action: string, payload: T): void;
22
- broadcastStats(clients: Set<WebSocket> | WebSocket[], stats: StatsCompilation): void;
22
+ broadcastStats(clients: Set<WebSocket> | WebSocket[], stats: webpack.StatsCompilation): void;
23
23
  }
@@ -2,7 +2,7 @@
2
2
  * @module interface
3
3
  */
4
4
  import WebSocket from 'ws';
5
- import { Compiler, WebpackPluginInstance } from 'webpack';
5
+ import webpack from 'webpack';
6
6
  export interface Options {
7
7
  hmr?: boolean;
8
8
  path?: string;
@@ -12,7 +12,7 @@ export interface Options {
12
12
  progress?: boolean;
13
13
  }
14
14
  export interface PluginFactory {
15
- (compiler: Compiler): WebpackPluginInstance;
15
+ (compiler: webpack.Compiler): webpack.WebpackPluginInstance;
16
16
  }
17
17
  export interface Expose {
18
18
  readonly clients: () => Set<WebSocket>;
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * @module utils
3
3
  */
4
+ import webpack from 'webpack';
4
5
  import { Context } from 'koa';
5
6
  import { Options } from './interface';
6
- import { StatsCompilation, StatsOptions } from 'webpack';
7
7
  import { ICompiler } from '../../server/interface';
8
8
  export declare function isUpgradable(context: Context): boolean;
9
9
  export declare function getOptions(options?: Options): Required<Options>;
10
10
  export declare function hasIssues<T>(issues: ArrayLike<T> | undefined): boolean;
11
- export declare function getStatsOptions(compiler: ICompiler): StatsOptions;
12
- export declare function getTimestamp({ builtAt, children }: StatsCompilation): number;
11
+ export declare function getStatsOptions(compiler: ICompiler): webpack.StatsOptions;
12
+ export declare function getTimestamp({ builtAt, children }: webpack.StatsCompilation): number;
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * @module interface
3
3
  */
4
- import { Compiler, Configuration, MultiCompiler, MultiStats, Stats, Watching } from 'webpack';
5
- export type IStats = Stats | MultiStats;
6
- export type ICompiler = Compiler | MultiCompiler;
7
- export type IStatsOptions = NonNullable<Configuration['stats']>;
8
- export type ILogger = ReturnType<Compiler['getInfrastructureLogger']>;
9
- export type IWatching = Watching | ReturnType<MultiCompiler['watch']>;
4
+ import webpack from 'webpack';
5
+ export type IStats = webpack.Stats | webpack.MultiStats;
6
+ export type GetProp<T, P extends keyof T> = NonNullable<T[P]>;
7
+ export type ICompiler = webpack.Compiler | webpack.MultiCompiler;
8
+ export type IStatsOptions = GetProp<webpack.Configuration, 'stats'>;
9
+ export type ILogger = ReturnType<GetProp<webpack.Compiler, 'getInfrastructureLogger'>>;
10
+ export type IWatching = webpack.Watching | ReturnType<GetProp<webpack.MultiCompiler, 'watch'>>;
11
+ export type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * @module utils
3
3
  */
4
+ import webpack from 'webpack';
4
5
  import { ICompiler } from './interface';
5
- import { Compiler, MultiCompiler } from 'webpack';
6
- export declare const PLUGIN_NAME = 'webpack-dev-service';
6
+ export declare const PLUGIN_NAME: string;
7
7
  export declare function isObject(value: unknown): value is object;
8
8
  export declare function isString(value: unknown): value is string;
9
9
  export declare function isBoolean(value: unknown): value is boolean;
10
10
  export declare function isFunction(value: unknown): value is Function;
11
- export declare function getCompilers(compiler: ICompiler): Compiler[];
12
- export declare function isMultiCompilerMode(compiler: ICompiler): compiler is MultiCompiler;
11
+ export declare function getCompilers(compiler: ICompiler): webpack.Compiler[];
12
+ export declare function isMultiCompiler(compiler: ICompiler): compiler is webpack.MultiCompiler;