@winner-fed/bundler-rsbuild 0.19.3 → 0.19.4-alpha.0
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/dist/build.js +34 -19
- package/dist/dev.d.ts +2 -1
- package/dist/server/server.d.ts +2 -1
- package/dist/server/server.js +10 -1
- package/package.json +3 -3
package/dist/build.js
CHANGED
|
@@ -42,7 +42,7 @@ var configModule = (0, import_utils.importLazy)(
|
|
|
42
42
|
);
|
|
43
43
|
var statsJson = {};
|
|
44
44
|
async function build(opts) {
|
|
45
|
-
var _a, _b
|
|
45
|
+
var _a, _b;
|
|
46
46
|
(0, import_assert.default)(opts, "opts should be supplied");
|
|
47
47
|
(0, import_checkConfig.checkConfig)(opts);
|
|
48
48
|
const { cwd, onBuildComplete, config } = opts;
|
|
@@ -57,14 +57,41 @@ async function build(opts) {
|
|
|
57
57
|
cwd,
|
|
58
58
|
rsbuildConfig
|
|
59
59
|
});
|
|
60
|
+
const isWatch = opts.watch ?? false;
|
|
61
|
+
let isFirstCompile = true;
|
|
62
|
+
const makeStats = () => {
|
|
63
|
+
var _a2;
|
|
64
|
+
return {
|
|
65
|
+
compilation: {
|
|
66
|
+
...statsJson,
|
|
67
|
+
// convert assets to [key: value] for compilation data
|
|
68
|
+
assets: (_a2 = statsJson == null ? void 0 : statsJson.assets) == null ? void 0 : _a2.reduce(
|
|
69
|
+
(acc, asset) => ({
|
|
70
|
+
...acc,
|
|
71
|
+
[asset.name]: { size: asset.size }
|
|
72
|
+
}),
|
|
73
|
+
{}
|
|
74
|
+
)
|
|
75
|
+
},
|
|
76
|
+
hasErrors: () => false
|
|
77
|
+
};
|
|
78
|
+
};
|
|
60
79
|
try {
|
|
61
80
|
rsbuild.onAfterBuild((params) => {
|
|
62
|
-
var _a2, _b2,
|
|
63
|
-
const s = ((_a2 = params.stats) == null ? void 0 : _a2.stats) ? (
|
|
81
|
+
var _a2, _b2, _c;
|
|
82
|
+
const s = ((_a2 = params.stats) == null ? void 0 : _a2.stats) ? (_c = (_b2 = params.stats) == null ? void 0 : _b2.stats) == null ? void 0 : _c[0] : params.stats;
|
|
64
83
|
statsJson = s == null ? void 0 : s.toJson();
|
|
84
|
+
if (isWatch && !isFirstCompile && onBuildComplete) {
|
|
85
|
+
onBuildComplete({
|
|
86
|
+
err: null,
|
|
87
|
+
stats: makeStats(),
|
|
88
|
+
isFirstCompile: false
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
isFirstCompile = false;
|
|
65
92
|
});
|
|
66
93
|
await rsbuild.build({
|
|
67
|
-
watch:
|
|
94
|
+
watch: isWatch
|
|
68
95
|
});
|
|
69
96
|
} catch (e) {
|
|
70
97
|
console.error(e == null ? void 0 : e.message);
|
|
@@ -79,24 +106,12 @@ async function build(opts) {
|
|
|
79
106
|
writeToDisk: true
|
|
80
107
|
});
|
|
81
108
|
}
|
|
82
|
-
const stats =
|
|
83
|
-
compilation: {
|
|
84
|
-
...statsJson,
|
|
85
|
-
// convert assets to [key: value] for compilation data
|
|
86
|
-
assets: (_c = statsJson == null ? void 0 : statsJson.assets) == null ? void 0 : _c.reduce(
|
|
87
|
-
(acc, asset) => ({
|
|
88
|
-
...acc,
|
|
89
|
-
[asset.name]: { size: asset.size }
|
|
90
|
-
}),
|
|
91
|
-
{}
|
|
92
|
-
)
|
|
93
|
-
},
|
|
94
|
-
hasErrors: () => false
|
|
95
|
-
};
|
|
109
|
+
const stats = makeStats();
|
|
96
110
|
if (onBuildComplete) {
|
|
97
111
|
await onBuildComplete({
|
|
98
112
|
err: null,
|
|
99
|
-
stats
|
|
113
|
+
stats,
|
|
114
|
+
isFirstCompile: true
|
|
100
115
|
});
|
|
101
116
|
}
|
|
102
117
|
return stats;
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { MaybePromise } from '@rsbuild/core/dist-types/types';
|
|
2
|
+
import type { IWinMiddleware } from '@winner-fed/bundler-utils';
|
|
2
3
|
import { Express, RequestHandler } from '@winner-fed/bundler-utils/compiled/express';
|
|
3
4
|
import { IBabelPlugin, IConfig, MultiStats, Stats } from './types';
|
|
4
5
|
type IOpts = {
|
|
5
6
|
beforeBabelPlugins?: IBabelPlugin[];
|
|
6
7
|
beforeBabelPresets?: IBabelPlugin[];
|
|
7
|
-
afterMiddlewares?:
|
|
8
|
+
afterMiddlewares?: IWinMiddleware[];
|
|
8
9
|
beforeMiddlewares?: RequestHandler[];
|
|
9
10
|
onDevCompileDone?: (opts: {
|
|
10
11
|
isFirstCompile: boolean;
|
package/dist/server/server.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RsbuildConfig } from '@rsbuild/core';
|
|
2
|
+
import type { IWinMiddleware } from '@winner-fed/bundler-utils';
|
|
2
3
|
import { IConfig } from '../types';
|
|
3
4
|
interface IOpts {
|
|
4
5
|
cwd: string;
|
|
@@ -8,7 +9,7 @@ interface IOpts {
|
|
|
8
9
|
userConfig: IConfig;
|
|
9
10
|
rsbuildConfig: RsbuildConfig;
|
|
10
11
|
beforeMiddlewares?: any[];
|
|
11
|
-
afterMiddlewares?:
|
|
12
|
+
afterMiddlewares?: IWinMiddleware[];
|
|
12
13
|
onDevCompileDone?: Function;
|
|
13
14
|
onBeforeMiddleware?: Function;
|
|
14
15
|
}
|
package/dist/server/server.js
CHANGED
|
@@ -53,8 +53,17 @@ async function createServer(opts) {
|
|
|
53
53
|
if (userConfig.proxy) {
|
|
54
54
|
(0, import_bundler_utils.createProxy)(userConfig.proxy, app);
|
|
55
55
|
}
|
|
56
|
+
const compilerLike = {
|
|
57
|
+
hooks: {
|
|
58
|
+
done: {
|
|
59
|
+
tap: (_name, cb) => {
|
|
60
|
+
rsbuild.onAfterDevCompile(({ stats }) => cb(stats));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
56
65
|
(opts.afterMiddlewares || []).forEach((m) => {
|
|
57
|
-
app.use(
|
|
66
|
+
app.use((0, import_bundler_utils.resolveMiddleware)(m, { compiler: compilerLike }));
|
|
58
67
|
});
|
|
59
68
|
const httpServer = app.listen(rsbuildServer.port, async () => {
|
|
60
69
|
await rsbuildServer.afterListen();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@winner-fed/bundler-rsbuild",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.4-alpha.0",
|
|
4
4
|
"description": "@winner-fed/bundler-rsbuild",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"@rsbuild/plugin-sass": "1.5.1",
|
|
20
20
|
"@rsbuild/plugin-stylus": "1.3.1",
|
|
21
21
|
"@rsbuild/plugin-type-check": "1.3.4",
|
|
22
|
-
"@winner-fed/bundler-utils": "0.19.
|
|
23
|
-
"@winner-fed/utils": "0.19.
|
|
22
|
+
"@winner-fed/bundler-utils": "0.19.4-alpha.0",
|
|
23
|
+
"@winner-fed/utils": "0.19.4-alpha.0"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|