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.
- package/cjs/client/client.cjs +15 -15
- package/cjs/client/events.cjs +1 -1
- package/cjs/client/hot.cjs +2 -2
- package/cjs/client/index.cjs +1 -1
- package/cjs/client/main.cjs +1 -1
- package/cjs/client/ui/{overlay.cjs → Overlay.cjs} +2 -2
- package/cjs/client/ui/{progress.cjs → Progress.cjs} +2 -2
- package/cjs/client/ui/utils.cjs +1 -1
- package/cjs/server/compose.cjs +1 -1
- package/cjs/server/dev/Service.cjs +1 -1
- package/cjs/server/dev/index.cjs +1 -1
- package/cjs/server/dev/middleware.cjs +1 -1
- package/cjs/server/dev/utils/fs.cjs +1 -1
- package/cjs/server/dev/utils/hash.cjs +1 -1
- package/cjs/server/dev/utils/http.cjs +1 -1
- package/cjs/server/dev/utils/path.cjs +1 -1
- package/cjs/server/dev/utils/paths.cjs +7 -10
- package/cjs/server/dev/utils/ready.cjs +1 -1
- package/cjs/server/dev/utils/setupHooks.cjs +3 -3
- package/cjs/server/dev/utils/setupOutputFileSystem.cjs +1 -1
- package/cjs/server/dev/utils/setupWatching.cjs +2 -2
- package/cjs/server/dev/utils/setupWriteToDisk.cjs +1 -1
- package/cjs/server/hot/Socket.cjs +3 -3
- package/cjs/server/hot/index.cjs +1 -1
- package/cjs/server/hot/utils.cjs +2 -2
- package/cjs/server/index.cjs +1 -1
- package/cjs/server/schema.cjs +1 -1
- package/cjs/server/utils.cjs +4 -4
- package/esm/client/client.js +3 -3
- package/esm/client/events.js +1 -1
- package/esm/client/hot.js +2 -2
- package/esm/client/index.js +1 -1
- package/esm/client/main.js +1 -1
- package/esm/client/ui/{overlay.js → Overlay.js} +2 -2
- package/esm/client/ui/{progress.js → Progress.js} +2 -2
- package/esm/client/ui/utils.js +1 -1
- package/esm/server/compose.js +1 -1
- package/esm/server/dev/Service.js +1 -1
- package/esm/server/dev/index.js +1 -1
- package/esm/server/dev/middleware.js +1 -1
- package/esm/server/dev/utils/fs.js +1 -1
- package/esm/server/dev/utils/hash.js +1 -1
- package/esm/server/dev/utils/http.js +1 -1
- package/esm/server/dev/utils/path.js +1 -1
- package/esm/server/dev/utils/paths.js +7 -10
- package/esm/server/dev/utils/ready.js +1 -1
- package/esm/server/dev/utils/setupHooks.js +4 -4
- package/esm/server/dev/utils/setupOutputFileSystem.js +1 -1
- package/esm/server/dev/utils/setupWatching.js +3 -3
- package/esm/server/dev/utils/setupWriteToDisk.js +1 -1
- package/esm/server/hot/Socket.js +2 -2
- package/esm/server/hot/index.js +1 -1
- package/esm/server/hot/utils.js +3 -3
- package/esm/server/index.js +1 -1
- package/esm/server/schema.js +1 -1
- package/esm/server/utils.js +4 -4
- package/global.d.ts +11 -0
- package/package.json +15 -15
- package/types/client/{message.d.ts → Message.d.ts} +9 -8
- package/types/client/events.d.ts +17 -17
- package/types/client/hot.d.ts +1 -1
- package/types/client/ui/{overlay.d.ts → Overlay.d.ts} +3 -3
- package/types/client/ui/{progress.d.ts → Progress.d.ts} +1 -1
- package/types/server/dev/interface.d.ts +3 -3
- package/types/server/dev/utils/fs.d.ts +4 -3
- package/types/server/hot/Socket.d.ts +2 -2
- package/types/server/hot/interface.d.ts +2 -2
- package/types/server/hot/utils.d.ts +3 -3
- package/types/server/interface.d.ts +8 -6
- 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.
|
|
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.
|
|
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.
|
|
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.
|
|
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 (
|
|
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
|
|
52
|
-
|
|
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.
|
|
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.
|
|
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,
|
|
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 (
|
|
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 (
|
|
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.
|
|
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.
|
|
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 {
|
|
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 =
|
|
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.
|
|
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
|
package/esm/server/hot/Socket.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.11.
|
|
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
|
|
package/esm/server/hot/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.11.
|
|
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
|
package/esm/server/hot/utils.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.11.
|
|
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 {
|
|
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 (
|
|
70
|
+
if (isMultiCompiler(compiler)) {
|
|
71
71
|
return {
|
|
72
72
|
children: compiler.compilers.map(({ options }) => {
|
|
73
73
|
return normalizeStatsOptions(options.stats);
|
package/esm/server/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.11.
|
|
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
|
package/esm/server/schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.11.
|
|
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
|
package/esm/server/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package webpack-dev-service
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 0.11.
|
|
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 (
|
|
28
|
+
if (isMultiCompiler(compiler)) {
|
|
29
29
|
return compiler.compilers;
|
|
30
30
|
}
|
|
31
31
|
return [compiler];
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function isMultiCompiler(compiler) {
|
|
34
34
|
return 'compilers' in compiler;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export { PLUGIN_NAME, getCompilers, isBoolean, isFunction,
|
|
37
|
+
export { PLUGIN_NAME, getCompilers, isBoolean, isFunction, isMultiCompiler, isObject, isString };
|
package/global.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-dev-service",
|
|
3
|
-
"version": "0.11.
|
|
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.
|
|
77
|
+
"@nuintun/ansi": "^0.0.8",
|
|
77
78
|
"@types/koa": "^2.15.0",
|
|
78
|
-
"@types/ws": "^8.5.
|
|
79
|
+
"@types/ws": "^8.5.12",
|
|
79
80
|
"destroy": "^1.2.0",
|
|
80
81
|
"etag": "^1.8.1",
|
|
81
|
-
"memfs": "^4.
|
|
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.
|
|
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.
|
|
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": "^
|
|
97
|
+
"@types/node": "^22.5.2",
|
|
97
98
|
"@types/range-parser": "^1.2.7",
|
|
98
|
-
"@types/react": "^18.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.
|
|
105
|
-
"
|
|
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.
|
|
111
|
+
"rollup": "^4.21.2",
|
|
112
112
|
"swc-loader": "^0.2.6",
|
|
113
113
|
"tsc-alias": "^1.8.10",
|
|
114
|
-
"typescript": "^5.5.
|
|
115
|
-
"webpack": "^5.
|
|
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
|
|
5
|
-
export interface
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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;
|
package/types/client/events.d.ts
CHANGED
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
* @module events
|
|
3
3
|
*/
|
|
4
4
|
import { Options } from './client';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
15
|
-
hash(message: Messages
|
|
16
|
-
issues(message: Messages
|
|
17
|
-
invalid(message: Messages
|
|
18
|
-
progress(message: Messages
|
|
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
|
|
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
|
|
34
|
-
export declare function emit<E extends keyof Events>(event: E, message: Messages
|
|
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;
|
package/types/client/hot.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare function isUpdateAvailable(): boolean;
|
|
|
9
9
|
/**
|
|
10
10
|
* @function setHash
|
|
11
11
|
* @description Set webpack hash.
|
|
12
|
-
* @param 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
|
|
6
|
-
export
|
|
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
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module interface
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
5
|
-
export type IStats = Stats | MultiStats;
|
|
6
|
-
export type
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
9
|
-
export type
|
|
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>>;
|
package/types/server/utils.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module utils
|
|
3
3
|
*/
|
|
4
|
+
import webpack from 'webpack';
|
|
4
5
|
import { ICompiler } from './interface';
|
|
5
|
-
|
|
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
|
|
11
|
+
export declare function getCompilers(compiler: ICompiler): webpack.Compiler[];
|
|
12
|
+
export declare function isMultiCompiler(compiler: ICompiler): compiler is webpack.MultiCompiler;
|