@lark-apaas/fullstack-rspack-preset 1.0.32-alpha.20 → 1.0.32-alpha.22
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/lib/preset.js
CHANGED
|
@@ -279,7 +279,7 @@ function createRecommendRspackConfig(options) {
|
|
|
279
279
|
!isDev && new polyfill_plugin_1.default(),
|
|
280
280
|
// 静态资源插件 - 支持 @shared/static/* 导入
|
|
281
281
|
staticAssetsPlugin,
|
|
282
|
-
//
|
|
282
|
+
// 解析路由(dev + prod 均生成 routes.json 和 page-routes.json)
|
|
283
283
|
needRoutes &&
|
|
284
284
|
new route_parser_plugin_1.default({
|
|
285
285
|
appPath: './client/src/app.tsx',
|
|
@@ -7,6 +7,8 @@ declare class RouteParserPlugin {
|
|
|
7
7
|
private options;
|
|
8
8
|
private lastAppPathHash;
|
|
9
9
|
private cachedRoutes;
|
|
10
|
+
/** 不带 basePath 前缀的路由(供日志服务消费) */
|
|
11
|
+
private cachedPageRoutes;
|
|
10
12
|
constructor(options?: RouteParserPluginOptions);
|
|
11
13
|
private normalizeBasePath;
|
|
12
14
|
private log;
|
|
@@ -48,6 +48,8 @@ class RouteParserPlugin {
|
|
|
48
48
|
constructor(options = {}) {
|
|
49
49
|
this.lastAppPathHash = null;
|
|
50
50
|
this.cachedRoutes = null;
|
|
51
|
+
/** 不带 basePath 前缀的路由(供日志服务消费) */
|
|
52
|
+
this.cachedPageRoutes = null;
|
|
51
53
|
// 从环境变量读取 basePath,并规范化(确保以 / 开头,不以 / 结尾)
|
|
52
54
|
const envBasePath = process.env.CLIENT_BASE_PATH || '';
|
|
53
55
|
const normalizedBasePath = this.normalizeBasePath(options.basePath ?? envBasePath);
|
|
@@ -102,6 +104,12 @@ class RouteParserPlugin {
|
|
|
102
104
|
source: () => routesJson,
|
|
103
105
|
size: () => routesJson.length
|
|
104
106
|
};
|
|
107
|
+
// 不带 basePath 前缀的路由,供日志服务消费
|
|
108
|
+
const pageRoutesJson = JSON.stringify(this.cachedPageRoutes, null, 2);
|
|
109
|
+
compilation.assets['page-routes.json'] = {
|
|
110
|
+
source: () => pageRoutesJson,
|
|
111
|
+
size: () => pageRoutesJson.length
|
|
112
|
+
};
|
|
105
113
|
callback();
|
|
106
114
|
}
|
|
107
115
|
catch (error) {
|
|
@@ -110,10 +118,16 @@ class RouteParserPlugin {
|
|
|
110
118
|
const defaultPath = basePath ? `${basePath}/` : '/';
|
|
111
119
|
const defaultRoutes = [{ path: defaultPath }];
|
|
112
120
|
const routesJson = JSON.stringify(defaultRoutes, null, 2);
|
|
121
|
+
const defaultPageRoutes = [{ path: '/' }];
|
|
122
|
+
const pageRoutesJson = JSON.stringify(defaultPageRoutes, null, 2);
|
|
113
123
|
compilation.assets['routes.json'] = {
|
|
114
124
|
source: () => routesJson,
|
|
115
125
|
size: () => routesJson.length
|
|
116
126
|
};
|
|
127
|
+
compilation.assets['page-routes.json'] = {
|
|
128
|
+
source: () => pageRoutesJson,
|
|
129
|
+
size: () => pageRoutesJson.length
|
|
130
|
+
};
|
|
117
131
|
callback();
|
|
118
132
|
}
|
|
119
133
|
});
|
|
@@ -200,6 +214,11 @@ class RouteParserPlugin {
|
|
|
200
214
|
}
|
|
201
215
|
});
|
|
202
216
|
const { basePath } = this.options;
|
|
217
|
+
// 不带前缀的纯页面路由(供日志服务消费)
|
|
218
|
+
const pageRoutes = Array.from(routeSet).map(routePath => ({
|
|
219
|
+
path: routePath,
|
|
220
|
+
}));
|
|
221
|
+
this.cachedPageRoutes = pageRoutes.length > 0 ? pageRoutes : [{ path: '/' }];
|
|
203
222
|
const routes = Array.from(routeSet).map(routePath => ({
|
|
204
223
|
path: basePath ? `${basePath}${routePath}` : routePath,
|
|
205
224
|
}));
|
|
@@ -211,6 +230,7 @@ class RouteParserPlugin {
|
|
|
211
230
|
this.log('warn', '⚠️ 路由解析失败,使用默认路由:', error.message);
|
|
212
231
|
const { basePath } = this.options;
|
|
213
232
|
const defaultPath = basePath ? `${basePath}/` : '/';
|
|
233
|
+
this.cachedPageRoutes = [{ path: '/' }];
|
|
214
234
|
return [{ path: defaultPath }];
|
|
215
235
|
}
|
|
216
236
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-rspack-preset",
|
|
3
|
-
"version": "1.0.32-alpha.
|
|
3
|
+
"version": "1.0.32-alpha.22",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"patches",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@babel/parser": "^7.28.0",
|
|
32
32
|
"@babel/traverse": "^7.28.0",
|
|
33
33
|
"@babel/types": "^7.28.2",
|
|
34
|
-
"@lark-apaas/devtool-kits": "1.2.17-alpha.
|
|
34
|
+
"@lark-apaas/devtool-kits": "1.2.17-alpha.35",
|
|
35
35
|
"@lark-apaas/miaoda-inspector-babel-plugin": "^1.0.2",
|
|
36
36
|
"@lark-apaas/styled-jsx": "^1.0.1",
|
|
37
37
|
"@rspack/plugin-react-refresh": "^1.5.1",
|