rspack-dev-middleware 0.4.1 → 0.4.2
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/HotUpdate.cjs +1 -1
- package/cjs/client/client.cjs +2 -2
- package/cjs/client/events.cjs +5 -5
- package/cjs/client/events.d.cts +3 -7
- package/cjs/client/index.cjs +1 -1
- package/cjs/client/main.cjs +3 -3
- package/cjs/client/ui/Overlay.cjs +4 -4
- package/cjs/client/ui/Progress.cjs +3 -3
- package/cjs/client/ui/images/rspack-logo.svg.cjs +1 -1
- package/cjs/client/ui/utils.cjs +16 -22
- package/cjs/client/ui/utils.d.cts +3 -10
- package/cjs/server/compose.cjs +2 -2
- package/cjs/server/dev/ReadStream.cjs +5 -5
- package/cjs/server/dev/Service.cjs +10 -21
- package/cjs/server/dev/index.cjs +7 -3
- package/cjs/server/dev/middleware.cjs +4 -5
- package/cjs/server/dev/utils/fs.cjs +1 -1
- package/cjs/server/dev/utils/http.cjs +56 -28
- package/cjs/server/dev/utils/http.d.cts +26 -1
- package/cjs/server/dev/utils/path.cjs +1 -1
- package/cjs/server/dev/utils/paths.cjs +1 -1
- package/cjs/server/dev/utils/setupHooks.cjs +3 -9
- package/cjs/server/dev/utils/setupOutputFileSystem.cjs +1 -1
- package/cjs/server/dev/utils/setupWatching.cjs +11 -16
- package/cjs/server/dev/utils/setupWriteToDisk.cjs +1 -1
- package/cjs/server/hot/Message.d.cts +16 -32
- package/cjs/server/hot/Socket.cjs +19 -20
- package/cjs/server/hot/index.cjs +1 -1
- package/cjs/server/hot/utils.cjs +2 -8
- package/cjs/server/index.cjs +1 -1
- package/cjs/server/schema.cjs +27 -6
- package/cjs/server/utils.cjs +12 -1
- package/cjs/server/utils.d.cts +1 -0
- package/esm/client/HotUpdate.js +1 -1
- package/esm/client/client.js +2 -2
- package/esm/client/events.d.ts +3 -7
- package/esm/client/events.js +5 -5
- package/esm/client/index.js +1 -1
- package/esm/client/main.js +3 -3
- package/esm/client/ui/Overlay.js +5 -5
- package/esm/client/ui/Progress.js +4 -4
- package/esm/client/ui/images/rspack-logo.svg.js +1 -1
- package/esm/client/ui/utils.d.ts +3 -10
- package/esm/client/ui/utils.js +15 -21
- package/esm/server/compose.js +2 -2
- package/esm/server/dev/ReadStream.js +5 -5
- package/esm/server/dev/Service.js +10 -15
- package/esm/server/dev/index.js +7 -3
- package/esm/server/dev/middleware.js +4 -5
- package/esm/server/dev/utils/fs.js +1 -1
- package/esm/server/dev/utils/http.d.ts +26 -1
- package/esm/server/dev/utils/http.js +62 -29
- package/esm/server/dev/utils/path.js +1 -1
- package/esm/server/dev/utils/paths.js +1 -1
- package/esm/server/dev/utils/setupHooks.js +4 -10
- package/esm/server/dev/utils/setupOutputFileSystem.js +1 -1
- package/esm/server/dev/utils/setupWatching.js +11 -16
- package/esm/server/dev/utils/setupWriteToDisk.js +1 -1
- package/esm/server/hot/Message.d.ts +16 -32
- package/esm/server/hot/Socket.js +16 -17
- package/esm/server/hot/index.js +1 -1
- package/esm/server/hot/utils.js +3 -9
- package/esm/server/index.js +1 -1
- package/esm/server/schema.js +27 -6
- package/esm/server/utils.d.ts +1 -0
- package/esm/server/utils.js +12 -2
- package/package.json +33 -35
- package/cjs/server/dev/utils/hash.cjs +0 -47
- package/cjs/server/dev/utils/hash.d.cts +0 -9
- package/cjs/server/dev/utils/ready.cjs +0 -24
- package/cjs/server/dev/utils/ready.d.cts +0 -5
- package/esm/server/dev/utils/hash.d.ts +0 -9
- package/esm/server/dev/utils/hash.js +0 -45
- package/esm/server/dev/utils/ready.d.ts +0 -5
- package/esm/server/dev/utils/ready.js +0 -22
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
* @module message
|
|
3
3
|
*/
|
|
4
4
|
import * as rspack from '@rspack/core';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export interface Messages {
|
|
6
|
+
ok: {
|
|
7
|
+
timestamp: number;
|
|
8
|
+
};
|
|
9
|
+
hash: {
|
|
10
|
+
hash: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
};
|
|
13
|
+
invalid: {
|
|
9
14
|
timestamp: number;
|
|
10
15
|
path: string | null;
|
|
11
16
|
};
|
|
12
|
-
|
|
13
|
-
export interface Progress {
|
|
14
|
-
action: 'progress';
|
|
15
|
-
payload: {
|
|
17
|
+
progress: {
|
|
16
18
|
stage: string;
|
|
17
19
|
percent: number;
|
|
18
20
|
details: {
|
|
@@ -20,33 +22,15 @@ export interface Progress {
|
|
|
20
22
|
moduleIdentifier?: string;
|
|
21
23
|
};
|
|
22
24
|
};
|
|
23
|
-
|
|
24
|
-
export interface Hash {
|
|
25
|
-
action: 'hash';
|
|
26
|
-
payload: {
|
|
27
|
-
hash: string;
|
|
28
|
-
timestamp: number;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export interface Issues {
|
|
32
|
-
action: 'issues';
|
|
33
|
-
payload: {
|
|
25
|
+
issues: {
|
|
34
26
|
timestamp: number;
|
|
35
27
|
errors: rspack.StatsError[];
|
|
36
28
|
warnings: rspack.StatsError[];
|
|
37
29
|
};
|
|
38
30
|
}
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
export type Message = {
|
|
32
|
+
[A in keyof Messages]: {
|
|
33
|
+
action: A;
|
|
34
|
+
payload: Messages[A];
|
|
43
35
|
};
|
|
44
|
-
}
|
|
45
|
-
export interface Messages {
|
|
46
|
-
ok: GetProp<Ok, 'payload'>;
|
|
47
|
-
hash: GetProp<Hash, 'payload'>;
|
|
48
|
-
issues: GetProp<Issues, 'payload'>;
|
|
49
|
-
invalid: GetProp<Invalid, 'payload'>;
|
|
50
|
-
progress: GetProp<Progress, 'payload'>;
|
|
51
|
-
}
|
|
52
|
-
export type Message = Invalid | Progress | Hash | Issues | Ok;
|
|
36
|
+
}[keyof Messages];
|
package/esm/server/hot/Socket.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* @module rspack-dev-middleware
|
|
3
3
|
* @package rspack-dev-middleware
|
|
4
4
|
* @license MIT
|
|
5
|
-
* @version 0.4.
|
|
5
|
+
* @version 0.4.2
|
|
6
6
|
* @author nuintun <nuintun@qq.com>
|
|
7
7
|
* @description A koa 2 middleware for rspack development and hot reloading.
|
|
8
8
|
* @see https://github.com/nuintun/rspack-dev-middleware#readme
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { v7 } from 'uuid';
|
|
12
11
|
import { Buffer } from 'node:buffer';
|
|
13
12
|
import * as rspack from '@rspack/core';
|
|
14
13
|
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import { randomUUID } from 'node:crypto';
|
|
15
15
|
import { resolve, dirname } from 'node:path';
|
|
16
16
|
import WebSocket, { WebSocketServer } from 'ws';
|
|
17
17
|
import { PLUGIN_NAME, getCompilers } from '../utils.js';
|
|
@@ -37,7 +37,7 @@ class Socket {
|
|
|
37
37
|
const compilers = getCompilers(compiler);
|
|
38
38
|
const contexts = new Map();
|
|
39
39
|
for (const compiler of compilers) {
|
|
40
|
-
const uuid =
|
|
40
|
+
const uuid = randomUUID();
|
|
41
41
|
const context = {
|
|
42
42
|
uuid,
|
|
43
43
|
stats: null,
|
|
@@ -81,7 +81,7 @@ class Socket {
|
|
|
81
81
|
process.nextTick(() => {
|
|
82
82
|
const { stats } = context;
|
|
83
83
|
// Broadcast stats.
|
|
84
|
-
if (stats) {
|
|
84
|
+
if (stats != null && context.clients.size > 0) {
|
|
85
85
|
this.#broadcastStats(context.clients, stats);
|
|
86
86
|
}
|
|
87
87
|
});
|
|
@@ -132,7 +132,7 @@ class Socket {
|
|
|
132
132
|
const uuid = url.searchParams.get('uuid');
|
|
133
133
|
if (uuid) {
|
|
134
134
|
const context = contexts.get(uuid);
|
|
135
|
-
if (context) {
|
|
135
|
+
if (context != null) {
|
|
136
136
|
const { stats } = context;
|
|
137
137
|
context.clients.add(client);
|
|
138
138
|
logger.log('client connected');
|
|
@@ -140,9 +140,8 @@ class Socket {
|
|
|
140
140
|
context.clients.delete(client);
|
|
141
141
|
logger.log('client disconnected');
|
|
142
142
|
});
|
|
143
|
-
if (stats) {
|
|
144
|
-
|
|
145
|
-
this.#broadcastStats(clients, stats);
|
|
143
|
+
if (stats != null) {
|
|
144
|
+
this.#broadcastStats([client], stats);
|
|
146
145
|
}
|
|
147
146
|
} else {
|
|
148
147
|
client.close(4001, 'compiler not found');
|
|
@@ -156,21 +155,21 @@ class Socket {
|
|
|
156
155
|
});
|
|
157
156
|
}
|
|
158
157
|
#broadcast(clients, action, payload) {
|
|
158
|
+
// Serialize once, send to all.
|
|
159
|
+
const message = JSON.stringify({ action, payload });
|
|
159
160
|
for (const client of clients) {
|
|
160
161
|
if (client.readyState === WebSocket.OPEN) {
|
|
161
|
-
client.send(
|
|
162
|
+
client.send(message);
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
#broadcastStats(clients, stats) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
this.#broadcast(clients, 'ok', { timestamp });
|
|
173
|
-
}
|
|
167
|
+
const { hash, errors, warnings, builtAt: timestamp } = stats;
|
|
168
|
+
this.#broadcast(clients, 'hash', { hash, timestamp });
|
|
169
|
+
if (hasIssues(errors) || hasIssues(warnings)) {
|
|
170
|
+
this.#broadcast(clients, 'issues', { errors, warnings, timestamp });
|
|
171
|
+
} else {
|
|
172
|
+
this.#broadcast(clients, 'ok', { timestamp });
|
|
174
173
|
}
|
|
175
174
|
}
|
|
176
175
|
upgrade(context) {
|
package/esm/server/hot/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module rspack-dev-middleware
|
|
3
3
|
* @package rspack-dev-middleware
|
|
4
4
|
* @license MIT
|
|
5
|
-
* @version 0.4.
|
|
5
|
+
* @version 0.4.2
|
|
6
6
|
* @author nuintun <nuintun@qq.com>
|
|
7
7
|
* @description A koa 2 middleware for rspack development and hot reloading.
|
|
8
8
|
* @see https://github.com/nuintun/rspack-dev-middleware#readme
|
package/esm/server/hot/utils.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* @module rspack-dev-middleware
|
|
3
3
|
* @package rspack-dev-middleware
|
|
4
4
|
* @license MIT
|
|
5
|
-
* @version 0.4.
|
|
5
|
+
* @version 0.4.2
|
|
6
6
|
* @author nuintun <nuintun@qq.com>
|
|
7
7
|
* @description A koa 2 middleware for rspack development and hot reloading.
|
|
8
8
|
* @see https://github.com/nuintun/rspack-dev-middleware#readme
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { toStatsPreset } from '../utils.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @module utils
|
|
@@ -34,14 +34,8 @@ function hasIssues(issues) {
|
|
|
34
34
|
return Array.isArray(issues) && issues.length > 0;
|
|
35
35
|
}
|
|
36
36
|
function getStatsOptions(compiler) {
|
|
37
|
-
let statsOptions = compiler.options.stats;
|
|
38
|
-
if (isString(statsOptions)) {
|
|
39
|
-
statsOptions = { preset: statsOptions };
|
|
40
|
-
} else if (isBoolean(statsOptions)) {
|
|
41
|
-
statsOptions = statsOptions ? { preset: 'normal' } : { preset: 'none' };
|
|
42
|
-
}
|
|
43
37
|
return {
|
|
44
|
-
...
|
|
38
|
+
...toStatsPreset(compiler.options.stats),
|
|
45
39
|
all: false,
|
|
46
40
|
hash: true,
|
|
47
41
|
colors: true,
|
package/esm/server/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module rspack-dev-middleware
|
|
3
3
|
* @package rspack-dev-middleware
|
|
4
4
|
* @license MIT
|
|
5
|
-
* @version 0.4.
|
|
5
|
+
* @version 0.4.2
|
|
6
6
|
* @author nuintun <nuintun@qq.com>
|
|
7
7
|
* @description A koa 2 middleware for rspack development and hot reloading.
|
|
8
8
|
* @see https://github.com/nuintun/rspack-dev-middleware#readme
|
package/esm/server/schema.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module rspack-dev-middleware
|
|
3
3
|
* @package rspack-dev-middleware
|
|
4
4
|
* @license MIT
|
|
5
|
-
* @version 0.4.
|
|
5
|
+
* @version 0.4.2
|
|
6
6
|
* @author nuintun <nuintun@qq.com>
|
|
7
7
|
* @description A koa 2 middleware for rspack development and hot reloading.
|
|
8
8
|
* @see https://github.com/nuintun/rspack-dev-middleware#readme
|
|
@@ -15,7 +15,7 @@ const schema = {
|
|
|
15
15
|
type: 'object',
|
|
16
16
|
properties: {
|
|
17
17
|
hot: {
|
|
18
|
-
description: '
|
|
18
|
+
description: 'Configure the HMR server, or set to false to disable.',
|
|
19
19
|
anyOf: [
|
|
20
20
|
{
|
|
21
21
|
type: 'boolean',
|
|
@@ -38,7 +38,7 @@ const schema = {
|
|
|
38
38
|
},
|
|
39
39
|
reload: {
|
|
40
40
|
type: 'boolean',
|
|
41
|
-
description: 'Control whether the full page should be reloaded when HMR
|
|
41
|
+
description: 'Control whether the full page should be reloaded when HMR fails.'
|
|
42
42
|
},
|
|
43
43
|
overlay: {
|
|
44
44
|
type: 'boolean',
|
|
@@ -99,9 +99,30 @@ const schema = {
|
|
|
99
99
|
type: 'object',
|
|
100
100
|
description: 'The output file system used by the dev server.'
|
|
101
101
|
},
|
|
102
|
+
highWaterMark: {
|
|
103
|
+
description: 'The size of the read stream buffer.',
|
|
104
|
+
anyOf: [
|
|
105
|
+
{
|
|
106
|
+
type: 'number'
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
instanceof: 'Function'
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
},
|
|
102
113
|
stats: {
|
|
103
|
-
|
|
104
|
-
|
|
114
|
+
description: 'Options for the statistics output.',
|
|
115
|
+
anyOf: [
|
|
116
|
+
{
|
|
117
|
+
type: 'boolean'
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: 'string'
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'object'
|
|
124
|
+
}
|
|
125
|
+
]
|
|
105
126
|
},
|
|
106
127
|
writeToDisk: {
|
|
107
128
|
anyOf: [
|
|
@@ -117,7 +138,7 @@ const schema = {
|
|
|
117
138
|
},
|
|
118
139
|
onCompilationDone: {
|
|
119
140
|
instanceof: 'Function',
|
|
120
|
-
description: 'Callback function when the compilation is done, providing
|
|
141
|
+
description: 'Callback function when the compilation is done, providing stats and stats options.'
|
|
121
142
|
}
|
|
122
143
|
},
|
|
123
144
|
additionalProperties: false
|
package/esm/server/utils.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export declare function isBoolean(value: unknown): value is boolean;
|
|
|
9
9
|
export declare function isFunction(value: unknown): value is Function;
|
|
10
10
|
export declare function assertPublicPath(compiler: UnionCompiler): never | void;
|
|
11
11
|
export declare function getCompilers(compiler: UnionCompiler): rspack.Compiler[];
|
|
12
|
+
export declare function toStatsPreset(stats?: rspack.StatsValue): rspack.StatsOptions;
|
|
12
13
|
export declare function isMultiCompiler(compiler: UnionCompiler): compiler is rspack.MultiCompiler;
|
package/esm/server/utils.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module rspack-dev-middleware
|
|
3
3
|
* @package rspack-dev-middleware
|
|
4
4
|
* @license MIT
|
|
5
|
-
* @version 0.4.
|
|
5
|
+
* @version 0.4.2
|
|
6
6
|
* @author nuintun <nuintun@qq.com>
|
|
7
7
|
* @description A koa 2 middleware for rspack development and hot reloading.
|
|
8
8
|
* @see https://github.com/nuintun/rspack-dev-middleware#readme
|
|
@@ -36,8 +36,18 @@ function getCompilers(compiler) {
|
|
|
36
36
|
}
|
|
37
37
|
return [compiler];
|
|
38
38
|
}
|
|
39
|
+
function toStatsPreset(stats) {
|
|
40
|
+
if (stats == null) {
|
|
41
|
+
return { preset: 'normal' };
|
|
42
|
+
} else if (isString(stats)) {
|
|
43
|
+
return { preset: stats };
|
|
44
|
+
} else if (isBoolean(stats)) {
|
|
45
|
+
return stats ? { preset: 'normal' } : { preset: 'none' };
|
|
46
|
+
}
|
|
47
|
+
return stats;
|
|
48
|
+
}
|
|
39
49
|
function isMultiCompiler(compiler) {
|
|
40
50
|
return 'compilers' in compiler;
|
|
41
51
|
}
|
|
42
52
|
|
|
43
|
-
export { PLUGIN_NAME, assertPublicPath, getCompilers, isBoolean, isFunction, isMultiCompiler, isString };
|
|
53
|
+
export { PLUGIN_NAME, assertPublicPath, getCompilers, isBoolean, isFunction, isMultiCompiler, isString, toStatsPreset };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rspack-dev-middleware",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "A koa 2 middleware for rspack development and hot reloading.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -47,55 +47,53 @@
|
|
|
47
47
|
"url": "https://github.com/nuintun/rspack-dev-middleware/issues"
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://github.com/nuintun/rspack-dev-middleware#readme",
|
|
50
|
+
"scripts": {
|
|
51
|
+
"lint": "tsc --noEmit",
|
|
52
|
+
"pretest": "pnpm build",
|
|
53
|
+
"clean": "node tools/clean.ts",
|
|
54
|
+
"prepublishOnly": "pnpm build",
|
|
55
|
+
"test": "cd tests && node rspack.config.ts",
|
|
56
|
+
"build:cjs": "rollup -c tools/rollup.cjs.ts",
|
|
57
|
+
"build:esm": "rollup -c tools/rollup.esm.ts",
|
|
58
|
+
"build:fix-types": "node tools/fix-types.ts",
|
|
59
|
+
"build": "pnpm clean && pnpm build:main && pnpm format",
|
|
60
|
+
"format": "prettier --write . --ignore-path .prettierignore",
|
|
61
|
+
"build:main": "pnpm build:cjs && pnpm build:esm && pnpm build:fix-types"
|
|
62
|
+
},
|
|
50
63
|
"dependencies": {
|
|
51
64
|
"@nuintun/ansi": "^0.3.13",
|
|
52
65
|
"@types/koa": "^3.0.3",
|
|
53
|
-
"@types/ws": "^8.18.
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"supports-color": "^10.2.2",
|
|
66
|
+
"@types/ws": "^8.18.2",
|
|
67
|
+
"memfs": "^4.80.0",
|
|
68
|
+
"range-parser": "^1.3.0",
|
|
69
|
+
"schema-utils": "^4.8.1",
|
|
70
|
+
"supports-color": "^11.0.0",
|
|
59
71
|
"tslib": "^2.8.1",
|
|
60
|
-
"
|
|
61
|
-
"ws": "^8.20.1"
|
|
72
|
+
"ws": "^8.22.0"
|
|
62
73
|
},
|
|
63
74
|
"devDependencies": {
|
|
64
75
|
"@rollup/plugin-replace": "^6.0.3",
|
|
65
76
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
66
77
|
"@rollup/plugin-url": "^8.0.2",
|
|
67
|
-
"@rspack/core": "^2.
|
|
68
|
-
"@rspack/plugin-react-refresh": "^2.0.
|
|
69
|
-
"@types/
|
|
70
|
-
"@types/node": "^25.9.1",
|
|
78
|
+
"@rspack/core": "^2.2.9",
|
|
79
|
+
"@rspack/plugin-react-refresh": "^2.0.2",
|
|
80
|
+
"@types/node": "^26.6.5",
|
|
71
81
|
"@types/range-parser": "^1.2.7",
|
|
72
|
-
"@types/react": "^19.
|
|
73
|
-
"@types/react-dom": "^19.
|
|
74
|
-
"dts-paths": "^2.2.
|
|
82
|
+
"@types/react": "^19.3.0",
|
|
83
|
+
"@types/react-dom": "^19.3.0",
|
|
84
|
+
"dts-paths": "^2.2.2",
|
|
75
85
|
"koa": "^3.2.1",
|
|
76
|
-
"koa-compress": "^5.2.
|
|
77
|
-
"prettier": "^3.
|
|
78
|
-
"react": "^19.
|
|
79
|
-
"react-dom": "^19.
|
|
80
|
-
"react-refresh": "^0.
|
|
86
|
+
"koa-compress": "^5.2.2",
|
|
87
|
+
"prettier": "^3.9.10",
|
|
88
|
+
"react": "^19.3.1",
|
|
89
|
+
"react-dom": "^19.3.1",
|
|
90
|
+
"react-refresh": "^0.19.0",
|
|
81
91
|
"rimraf": "^6.1.3",
|
|
82
|
-
"rollup": "^4.
|
|
92
|
+
"rollup": "^4.64.12",
|
|
83
93
|
"typescript": "^6.0.3"
|
|
84
94
|
},
|
|
85
95
|
"peerDependencies": {
|
|
86
96
|
"@rspack/core": ">=1.0.7",
|
|
87
97
|
"koa": ">=2.0.0"
|
|
88
|
-
},
|
|
89
|
-
"scripts": {
|
|
90
|
-
"lint": "tsc --noEmit",
|
|
91
|
-
"pretest": "pnpm build",
|
|
92
|
-
"clean": "node tools/clean.ts",
|
|
93
|
-
"test": "cd tests && node rspack.config.ts",
|
|
94
|
-
"build:cjs": "rollup -c tools/rollup.cjs.ts",
|
|
95
|
-
"build:esm": "rollup -c tools/rollup.esm.ts",
|
|
96
|
-
"build:fix-types": "node tools/fix-types.ts",
|
|
97
|
-
"build": "pnpm clean && pnpm build:main && pnpm format",
|
|
98
|
-
"format": "prettier --write . --ignore-path .prettierignore",
|
|
99
|
-
"build:main": "pnpm build:cjs && pnpm build:esm && pnpm build:fix-types"
|
|
100
98
|
}
|
|
101
|
-
}
|
|
99
|
+
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module rspack-dev-middleware
|
|
3
|
-
* @package rspack-dev-middleware
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @version 0.4.1
|
|
6
|
-
* @author nuintun <nuintun@qq.com>
|
|
7
|
-
* @description A koa 2 middleware for rspack development and hot reloading.
|
|
8
|
-
* @see https://github.com/nuintun/rspack-dev-middleware#readme
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const node_crypto = require('node:crypto');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @module hash
|
|
17
|
-
*/
|
|
18
|
-
// prettier-ignore
|
|
19
|
-
const CHARS = [
|
|
20
|
-
// 0-9
|
|
21
|
-
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
22
|
-
// A-M
|
|
23
|
-
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
24
|
-
// N-Z
|
|
25
|
-
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
26
|
-
// a-m
|
|
27
|
-
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
|
28
|
-
// n-z
|
|
29
|
-
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
|
|
30
|
-
];
|
|
31
|
-
/**
|
|
32
|
-
* @function generate
|
|
33
|
-
* @description Generate a hash.
|
|
34
|
-
* @param length The length of hash.
|
|
35
|
-
*/
|
|
36
|
-
function generate(length) {
|
|
37
|
-
let hash = '';
|
|
38
|
-
const randomValues = node_crypto.getRandomValues(new Uint8Array(length));
|
|
39
|
-
// Create hash.
|
|
40
|
-
for (const value of randomValues) {
|
|
41
|
-
hash += CHARS[value % 62];
|
|
42
|
-
}
|
|
43
|
-
// Return hash.
|
|
44
|
-
return hash;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
exports.generate = generate;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module rspack-dev-middleware
|
|
3
|
-
* @package rspack-dev-middleware
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @version 0.4.1
|
|
6
|
-
* @author nuintun <nuintun@qq.com>
|
|
7
|
-
* @description A koa 2 middleware for rspack development and hot reloading.
|
|
8
|
-
* @see https://github.com/nuintun/rspack-dev-middleware#readme
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @module ready
|
|
15
|
-
*/
|
|
16
|
-
function ready({ stats, callbacks }, callback) {
|
|
17
|
-
if (stats) {
|
|
18
|
-
callback(stats);
|
|
19
|
-
} else {
|
|
20
|
-
callbacks.push(callback);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
exports.ready = ready;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module rspack-dev-middleware
|
|
3
|
-
* @package rspack-dev-middleware
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @version 0.4.1
|
|
6
|
-
* @author nuintun <nuintun@qq.com>
|
|
7
|
-
* @description A koa 2 middleware for rspack development and hot reloading.
|
|
8
|
-
* @see https://github.com/nuintun/rspack-dev-middleware#readme
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { getRandomValues } from 'node:crypto';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @module hash
|
|
15
|
-
*/
|
|
16
|
-
// prettier-ignore
|
|
17
|
-
const CHARS = [
|
|
18
|
-
// 0-9
|
|
19
|
-
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
20
|
-
// A-M
|
|
21
|
-
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
|
22
|
-
// N-Z
|
|
23
|
-
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
24
|
-
// a-m
|
|
25
|
-
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
|
26
|
-
// n-z
|
|
27
|
-
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
|
|
28
|
-
];
|
|
29
|
-
/**
|
|
30
|
-
* @function generate
|
|
31
|
-
* @description Generate a hash.
|
|
32
|
-
* @param length The length of hash.
|
|
33
|
-
*/
|
|
34
|
-
function generate(length) {
|
|
35
|
-
let hash = '';
|
|
36
|
-
const randomValues = getRandomValues(new Uint8Array(length));
|
|
37
|
-
// Create hash.
|
|
38
|
-
for (const value of randomValues) {
|
|
39
|
-
hash += CHARS[value % 62];
|
|
40
|
-
}
|
|
41
|
-
// Return hash.
|
|
42
|
-
return hash;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { generate };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module rspack-dev-middleware
|
|
3
|
-
* @package rspack-dev-middleware
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @version 0.4.1
|
|
6
|
-
* @author nuintun <nuintun@qq.com>
|
|
7
|
-
* @description A koa 2 middleware for rspack development and hot reloading.
|
|
8
|
-
* @see https://github.com/nuintun/rspack-dev-middleware#readme
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @module ready
|
|
13
|
-
*/
|
|
14
|
-
function ready({ stats, callbacks }, callback) {
|
|
15
|
-
if (stats) {
|
|
16
|
-
callback(stats);
|
|
17
|
-
} else {
|
|
18
|
-
callbacks.push(callback);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { ready };
|