@lemon-fe/vite-plugin-micro-frontend 1.0.4 → 1.0.6
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/index.d.ts +27 -63
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime.js +107 -35
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,14 +20,29 @@ interface FederationConfig {
|
|
|
20
20
|
name: string;
|
|
21
21
|
/** 远程入口文件名 */
|
|
22
22
|
filename?: string;
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* 暴露的模块(手动配置)
|
|
25
|
+
* 会与自动扫描的 exposes 合并,手动配置优先级更高
|
|
26
|
+
*/
|
|
24
27
|
exposes?: Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* exposes 目录路径,默认为 src/exposes
|
|
30
|
+
* 插件会自动扫描该目录下的子目录作为暴露的模块
|
|
31
|
+
* 例如:src/exposes/Button -> { './Button': './src/exposes/Button/index.tsx' }
|
|
32
|
+
*/
|
|
33
|
+
exposesDir?: string;
|
|
25
34
|
/** 远程模块配置 */
|
|
26
|
-
remotes?:
|
|
35
|
+
remotes?: RemoteConfig[];
|
|
27
36
|
/** 共享依赖 */
|
|
28
37
|
shared?: string[];
|
|
29
38
|
/** 生成的文件路径,默认为 src/utils/mf.tsx */
|
|
30
39
|
outputPath?: string;
|
|
40
|
+
/**
|
|
41
|
+
* 开发服务器地址,用于拼接远程模块入口
|
|
42
|
+
* 例如:'http://localhost:5173'
|
|
43
|
+
* 如果不设置,将使用 remotes 中的 entry 作为完整 URL
|
|
44
|
+
*/
|
|
45
|
+
devHost?: string;
|
|
31
46
|
}
|
|
32
47
|
/**
|
|
33
48
|
* 路由配置
|
|
@@ -85,7 +100,7 @@ interface RoutesTemplateOptions {
|
|
|
85
100
|
*/
|
|
86
101
|
interface MfGeneratorOptions {
|
|
87
102
|
/** 远程模块配置 */
|
|
88
|
-
remotes:
|
|
103
|
+
remotes: RemoteConfig[];
|
|
89
104
|
/** 生成的文件路径,默认为 src/utils/mf.tsx */
|
|
90
105
|
outputPath?: string;
|
|
91
106
|
}
|
|
@@ -130,6 +145,12 @@ declare function pagesRoutesPlugin(options?: RoutesPluginOptions): VitePlugin;
|
|
|
130
145
|
*/
|
|
131
146
|
declare function mfGeneratorPlugin(options: MfGeneratorOptions): VitePlugin;
|
|
132
147
|
|
|
148
|
+
/**
|
|
149
|
+
* 模块联邦插件
|
|
150
|
+
* 整合了 federation 配置、exposes 自动扫描、remotes URL 构建等功能
|
|
151
|
+
*/
|
|
152
|
+
declare function federationPlugin(federationOptions: FederationConfig): PluginOption[];
|
|
153
|
+
|
|
133
154
|
interface DynamicOptions<P = Record<string, unknown>> {
|
|
134
155
|
/** 动态加载函数,返回一个包含 default 导出的 Promise */
|
|
135
156
|
loader: () => Promise<{
|
|
@@ -200,67 +221,10 @@ declare function getRoutes(opts: IOpts): IRoute[];
|
|
|
200
221
|
|
|
201
222
|
/**
|
|
202
223
|
* 微前端插件集合
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* 1. HTML 转换 - 移除开发环境下的 React Refresh 脚本
|
|
206
|
-
* 2. 路由自动生成 - 根据 pages 目录自动生成路由配置
|
|
207
|
-
* 3. mf.tsx 生成器 - 自动生成模块联邦工具文件
|
|
208
|
-
* 4. 模块联邦配置 - 使用 @originjs/vite-plugin-federation
|
|
209
|
-
* 5. qiankun 微前端配置
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* ```ts
|
|
213
|
-
* // vite.config.ts
|
|
214
|
-
* import { microFrontendPlugins, createMfAlias } from '@anthropic/vite-plugin-micro-frontend';
|
|
215
|
-
*
|
|
216
|
-
* export default defineConfig({
|
|
217
|
-
* plugins: [
|
|
218
|
-
* ...microFrontendPlugins({
|
|
219
|
-
* appName: 'wms',
|
|
220
|
-
* useDevMode: process.env.NODE_ENV === 'development',
|
|
221
|
-
* federation: {
|
|
222
|
-
* name: 'wms',
|
|
223
|
-
* filename: 'remote.js',
|
|
224
|
-
* exposes: {
|
|
225
|
-
* './ProcessingInboundDetail': './src/exposes/processing-inbound-detail/index.tsx',
|
|
226
|
-
* },
|
|
227
|
-
* remotes: {
|
|
228
|
-
* ama: {
|
|
229
|
-
* aliasName: 'ama',
|
|
230
|
-
* remoteName: 'ama',
|
|
231
|
-
* entry: '/app-ama/remote.js',
|
|
232
|
-
* },
|
|
233
|
-
* whs: {
|
|
234
|
-
* aliasName: 'whs',
|
|
235
|
-
* remoteName: 'whs',
|
|
236
|
-
* entry: '/app-whs/remote.js',
|
|
237
|
-
* },
|
|
238
|
-
* },
|
|
239
|
-
* },
|
|
240
|
-
* routes: {
|
|
241
|
-
* pagesDir: 'src/pages',
|
|
242
|
-
* outputPath: 'src/routes.ts',
|
|
243
|
-
* },
|
|
244
|
-
* qiankun: {
|
|
245
|
-
* enabled: true,
|
|
246
|
-
* name: 'wms',
|
|
247
|
-
* },
|
|
248
|
-
* }),
|
|
249
|
-
* ],
|
|
250
|
-
* resolve: {
|
|
251
|
-
* alias: {
|
|
252
|
-
* ...createMfAlias(),
|
|
253
|
-
* },
|
|
254
|
-
* },
|
|
255
|
-
* });
|
|
256
|
-
* ```
|
|
224
|
+
* @param options 微前端插件选项
|
|
225
|
+
* @returns 插件数组
|
|
257
226
|
*/
|
|
258
227
|
declare function microFrontendPlugins(options: MicroFrontendPluginOptions): PluginOption[];
|
|
259
|
-
/**
|
|
260
|
-
* 创建 resolve.alias 配置
|
|
261
|
-
* 用于配置 mf.tsx 的别名
|
|
262
|
-
*/
|
|
263
|
-
declare function createMfAlias(mfPath?: string): Record<string, string>;
|
|
264
228
|
|
|
265
|
-
export {
|
|
229
|
+
export { dynamic, federationPlugin, getRoutes, htmlRemoveFreshPlugin, mfGeneratorPlugin, microFrontendPlugins, pagesRoutesPlugin };
|
|
266
230
|
export type { ComponentMetadata, DynamicOptions, FederationConfig, IRoute, MfGeneratorOptions, MicroFrontendPluginOptions, RemoteConfig, RouteConfig, RoutesPluginOptions, RoutesTemplateOptions, VitePlugin };
|