miaoda-react-devkit 0.1.1-beta.10 → 0.1.1-beta.11

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.
@@ -23,4 +23,39 @@ declare function withSentryBuild(): Plugin;
23
23
  */
24
24
  declare function hmrTogglePlugin(): Plugin;
25
25
 
26
- export { hmrTogglePlugin, withSentryBuild, withSentryStub };
26
+ /**
27
+ * extractRouterPlugin:Vite 插件入口。
28
+ *
29
+ * 功能概述:
30
+ * 在 Vite dev server(serve 模式)下,通过 AST 静态分析实时收集项目路由信息,
31
+ * 并通过 /__routes HTTP 接口暴露给开发调试面板(devtools)使用。
32
+ *
33
+ * 路由收集方式(均在 transform 钩子中实时处理每个文件):
34
+ * 1. JSX 路由:解析含 <Route> 的任意组件文件(包括 .map() 动态渲染)
35
+ * 2. Hook 路由:解析含 useRoutes() 调用的文件
36
+ *
37
+ * 跨文件嵌套路由处理:
38
+ * 当遇到 <Route path="/admin/*" element={<AdminPanel />} /> 时,记录通配符挂载关系。
39
+ * 在 rebuildRoutes 阶段,对挂载目标文件中的相对路径路由追加正确前缀。
40
+ * 支持一级间接引用(通过 Vite moduleGraph 追踪 element 文件的直接 import)。
41
+ *
42
+ * 插件配置:
43
+ * - apply: 'serve' → 仅在开发模式生效
44
+ * - enforce: 'pre' → 在其他插件之前执行 transform
45
+ */
46
+
47
+ /**
48
+ * 创建路由收集 Vite 插件实例。
49
+ *
50
+ * @returns Vite Plugin 对象
51
+ *
52
+ * @example
53
+ * // vite.config.ts
54
+ * import { extractRouterPlugin } from '@miaoda/devkit';
55
+ * export default defineConfig({
56
+ * plugins: [extractRouterPlugin()],
57
+ * });
58
+ */
59
+ declare const extractRouterPlugin: () => Plugin;
60
+
61
+ export { extractRouterPlugin, hmrTogglePlugin, withSentryBuild, withSentryStub };
@@ -23,4 +23,39 @@ declare function withSentryBuild(): Plugin;
23
23
  */
24
24
  declare function hmrTogglePlugin(): Plugin;
25
25
 
26
- export { hmrTogglePlugin, withSentryBuild, withSentryStub };
26
+ /**
27
+ * extractRouterPlugin:Vite 插件入口。
28
+ *
29
+ * 功能概述:
30
+ * 在 Vite dev server(serve 模式)下,通过 AST 静态分析实时收集项目路由信息,
31
+ * 并通过 /__routes HTTP 接口暴露给开发调试面板(devtools)使用。
32
+ *
33
+ * 路由收集方式(均在 transform 钩子中实时处理每个文件):
34
+ * 1. JSX 路由:解析含 <Route> 的任意组件文件(包括 .map() 动态渲染)
35
+ * 2. Hook 路由:解析含 useRoutes() 调用的文件
36
+ *
37
+ * 跨文件嵌套路由处理:
38
+ * 当遇到 <Route path="/admin/*" element={<AdminPanel />} /> 时,记录通配符挂载关系。
39
+ * 在 rebuildRoutes 阶段,对挂载目标文件中的相对路径路由追加正确前缀。
40
+ * 支持一级间接引用(通过 Vite moduleGraph 追踪 element 文件的直接 import)。
41
+ *
42
+ * 插件配置:
43
+ * - apply: 'serve' → 仅在开发模式生效
44
+ * - enforce: 'pre' → 在其他插件之前执行 transform
45
+ */
46
+
47
+ /**
48
+ * 创建路由收集 Vite 插件实例。
49
+ *
50
+ * @returns Vite Plugin 对象
51
+ *
52
+ * @example
53
+ * // vite.config.ts
54
+ * import { extractRouterPlugin } from '@miaoda/devkit';
55
+ * export default defineConfig({
56
+ * plugins: [extractRouterPlugin()],
57
+ * });
58
+ */
59
+ declare const extractRouterPlugin: () => Plugin;
60
+
61
+ export { extractRouterPlugin, hmrTogglePlugin, withSentryBuild, withSentryStub };