@winner-fed/bundler-rsbuild2 0.19.3-alpha.0 → 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/config/outConfig.js +2 -0
- package/dist/dev.d.ts +2 -1
- package/dist/server/server.d.ts +2 -1
- package/dist/server/server.js +17 -3
- 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({ all: true, assets: true });
|
|
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/config/outConfig.js
CHANGED
|
@@ -81,6 +81,8 @@ function getOutConfig(opts) {
|
|
|
81
81
|
copy,
|
|
82
82
|
cssModules: cssLoaderModules,
|
|
83
83
|
dataUriLimit: inlineLimit,
|
|
84
|
+
// dev 默认内联样式(无 FOUC、规避历史 win.css 404 问题——如今 stats 已为真实值,
|
|
85
|
+
// 关闭后 dev 会产出 win.css 并被正确注入);如需覆盖可透传 rsbuild2.config.output.injectStyles
|
|
84
86
|
injectStyles: isDev,
|
|
85
87
|
distPath: {
|
|
86
88
|
root: outputPath,
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { IWinMiddleware } from '@winner-fed/bundler-utils';
|
|
1
2
|
import type { RequestHandler } from '@winner-fed/bundler-utils/compiled/express';
|
|
2
3
|
import { IBabelPlugin, IConfig, MultiStats, Stats } from './types';
|
|
3
4
|
type IOpts = {
|
|
4
5
|
beforeBabelPlugins?: IBabelPlugin[];
|
|
5
6
|
beforeBabelPresets?: IBabelPlugin[];
|
|
6
|
-
afterMiddlewares?:
|
|
7
|
+
afterMiddlewares?: IWinMiddleware[];
|
|
7
8
|
beforeMiddlewares?: RequestHandler[];
|
|
8
9
|
onDevCompileDone?: (opts: {
|
|
9
10
|
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
|
@@ -38,7 +38,12 @@ var import_express = __toESM(require("@winner-fed/bundler-utils/compiled/express
|
|
|
38
38
|
var import_utils = require("@winner-fed/utils");
|
|
39
39
|
var import_types = require("../types");
|
|
40
40
|
async function createServer(opts) {
|
|
41
|
+
var _a;
|
|
41
42
|
const { userConfig, rsbuildConfig } = opts;
|
|
43
|
+
console.log(
|
|
44
|
+
"[debug] merged injectStyles =",
|
|
45
|
+
(_a = rsbuildConfig == null ? void 0 : rsbuildConfig.output) == null ? void 0 : _a.injectStyles
|
|
46
|
+
);
|
|
42
47
|
const rsbuild = await (0, import_core.createRsbuild)({
|
|
43
48
|
cwd: opts.cwd,
|
|
44
49
|
rsbuildConfig
|
|
@@ -53,8 +58,17 @@ async function createServer(opts) {
|
|
|
53
58
|
if (userConfig.proxy) {
|
|
54
59
|
(0, import_bundler_utils.createProxy)(userConfig.proxy, app);
|
|
55
60
|
}
|
|
61
|
+
const compilerLike = {
|
|
62
|
+
hooks: {
|
|
63
|
+
done: {
|
|
64
|
+
tap: (_name, cb) => {
|
|
65
|
+
rsbuild.onAfterDevCompile(({ stats }) => cb(stats));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
56
70
|
(opts.afterMiddlewares || []).forEach((m) => {
|
|
57
|
-
app.use(
|
|
71
|
+
app.use((0, import_bundler_utils.resolveMiddleware)(m, { compiler: compilerLike }));
|
|
58
72
|
});
|
|
59
73
|
const httpServer = app.listen(rsbuildServer.port, async () => {
|
|
60
74
|
await rsbuildServer.afterListen();
|
|
@@ -75,9 +89,9 @@ async function createServer(opts) {
|
|
|
75
89
|
});
|
|
76
90
|
}
|
|
77
91
|
rsbuild.onAfterDevCompile((params) => {
|
|
78
|
-
var
|
|
92
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
79
93
|
if (opts.onDevCompileDone) {
|
|
80
|
-
const s = ((
|
|
94
|
+
const s = ((_a2 = params.stats) == null ? void 0 : _a2.stats) ? (_c = (_b = params.stats) == null ? void 0 : _b.stats) == null ? void 0 : _c[0] : params.stats;
|
|
81
95
|
(_h = opts.onDevCompileDone) == null ? void 0 : _h.call(opts, {
|
|
82
96
|
isFirstCompile: params.isFirstCompile,
|
|
83
97
|
stats: params.stats,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@winner-fed/bundler-rsbuild2",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.4-alpha.0",
|
|
4
4
|
"description": "@winner-fed/bundler-rsbuild2, based on Rsbuild 2.x (Rspack 2.x). External bundler for winjs, not a dependency of preset-win.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@rsbuild/plugin-sass": "2.0.1",
|
|
21
21
|
"@rsbuild/plugin-stylus": "2.0.1",
|
|
22
22
|
"@rsbuild/plugin-type-check": "1.6.0",
|
|
23
|
-
"@winner-fed/utils": "0.19.
|
|
24
|
-
"@winner-fed/
|
|
23
|
+
"@winner-fed/bundler-utils": "0.19.4-alpha.0",
|
|
24
|
+
"@winner-fed/utils": "0.19.4-alpha.0"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
27
|
"node": ">=20.19"
|