@ice/mf-runtime 1.0.2 → 1.0.3-beta.2

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/README.md CHANGED
@@ -1,12 +1,18 @@
1
1
  # @ice/mf-runtime
2
2
 
3
- 基于 Module Federation 的运行时工具,用于在 ice.js 应用中加载和管理远程模块。支持跨版本 React 组件加载
3
+ 基于 Module Federation 的运行时工具,用于在 ice.js 应用中加载和管理远程模块。支持跨版本 React 组件加载,并提供增强的插件机制。
4
4
 
5
5
  ## 特性
6
6
 
7
7
  - 基于 [Module Federation 2.0](https://module-federation.io/index.html)
8
8
  - 支持跨版本 React 组件加载
9
9
  - 内置冲突检测和降级渲染
10
+ - 🔌 **增强插件机制**: 完全兼容标准 MF 运行时插件
11
+ - 🎯 **组件增强**: 支持 HOC、Props 注入等组件扩展机制
12
+ - 🛡️ **错误边界**: 内置错误处理和恢复机制
13
+ - 📊 **性能监控**: 支持组件加载和渲染性能追踪
14
+ - 🔄 **热插拔**: 运行时动态注册和移除插件
15
+ - 📝 **TypeScript**: 完整的类型定义支持
10
16
 
11
17
  ## 安装
12
18
 
@@ -14,6 +20,220 @@
14
20
  $ npm i @ice/mf-runtime --save
15
21
  ```
16
22
 
23
+ ## 插件机制
24
+
25
+ 从 v1.0.1 开始,`@ice/mf-runtime` 支持强大的插件机制,允许在运行时动态扩展微前端功能。
26
+
27
+ ### 插件类型
28
+
29
+ #### 1. 标准 MF 插件 (FederationRuntimePlugin)
30
+ 标准 MF 插件使用原生的 `@module-federation/runtime` API 进行管理:
31
+
32
+ ```typescript
33
+ import { registerPlugins } from '@module-federation/runtime';
34
+ import type { FederationRuntimePlugin } from '@ice/mf-runtime';
35
+
36
+ const mfPlugin: FederationRuntimePlugin = {
37
+ name: 'my-mf-plugin',
38
+ beforeRequest: (args) => {
39
+ console.log('模块请求前:', args);
40
+ return args;
41
+ },
42
+ onLoad: (args) => {
43
+ console.log('模块加载后:', args);
44
+ return args;
45
+ },
46
+ afterResolve: (args) => {
47
+ console.log('模块解析后:', args);
48
+ return args;
49
+ }
50
+ };
51
+
52
+ // 使用原生 API 注册标准 MF 插件
53
+ registerPlugins([mfPlugin]);
54
+ ```
55
+
56
+ #### 2. 增强插件 (EnhancedRuntimePlugin)
57
+ 增强插件使用新的 API 进行管理,提供组件级别的扩展能力:
58
+
59
+ ```typescript
60
+ import { registerEnhancedPlugins } from '@ice/mf-runtime';
61
+ import type { EnhancedRuntimePlugin } from '@ice/mf-runtime';
62
+
63
+ const enhancedPlugin: EnhancedRuntimePlugin = {
64
+ name: 'my-enhanced-plugin',
65
+
66
+ // 组件包装器 - 支持 HOC 模式
67
+ wrapComponent: (WrappedComponent, context) => {
68
+ return function Enhanced(props) {
69
+ console.log(`渲染组件: ${context.remoteName}/${context.moduleName}`);
70
+ return <WrappedComponent {...props} />;
71
+ };
72
+ },
73
+
74
+ // 属性注入器
75
+ injectProps: (props, context) => {
76
+ return {
77
+ ...props,
78
+ injectedProp: `来自 ${context.remoteName} 的数据`
79
+ };
80
+ }
81
+ };
82
+
83
+ // 使用新的 API 注册增强插件
84
+ registerEnhancedPlugins([enhancedPlugin]);
85
+ ```
86
+
87
+ ### 注册和使用插件
88
+
89
+ #### 基本用法
90
+
91
+ ```typescript
92
+ import { init, registerEnhancedPlugins, RemoteModule } from '@ice/mf-runtime';
93
+ import { registerPlugins } from '@module-federation/runtime';
94
+
95
+ // 注册标准 MF 插件
96
+ registerPlugins([mfPlugin]);
97
+
98
+ // 注册增强插件
99
+ registerEnhancedPlugins([enhancedPlugin]);
100
+
101
+ // 初始化运行时
102
+ init({
103
+ remotes: [
104
+ {
105
+ name: 'remote-app',
106
+ entry: 'http://localhost:3001/remoteEntry.js'
107
+ }
108
+ ]
109
+ });
110
+
111
+ // 使用远程模块(插件会自动应用)
112
+ function App() {
113
+ return (
114
+ <RemoteModule
115
+ scope="remote-app"
116
+ module="Button"
117
+ componentProps={{ text: '点击我' }}
118
+ />
119
+ );
120
+ }
121
+ ```
122
+
123
+ #### 使用示例插件包
124
+
125
+ 我们提供了一个示例插件包 `@ice/mf-plugin-example`,包含常用的插件:
126
+
127
+ ```bash
128
+ npm install @ice/mf-plugin-example
129
+ ```
130
+
131
+ ```typescript
132
+ import { registerPlugins } from '@module-federation/runtime';
133
+ import { registerEnhancedPlugins } from '@ice/mf-runtime';
134
+ import {
135
+ errorBoundaryPlugin,
136
+ commonPropsPlugin,
137
+ developmentMFLoggingPlugin,
138
+ developmentEnhancedLoggingPlugin
139
+ } from '@ice/mf-plugin-example';
140
+
141
+ // 注册标准 MF 插件
142
+ registerPlugins([
143
+ developmentMFLoggingPlugin // MF 日志插件
144
+ ]);
145
+
146
+ // 注册增强插件
147
+ registerEnhancedPlugins([
148
+ developmentEnhancedLoggingPlugin, // 增强日志插件
149
+ errorBoundaryPlugin, // 错误边界插件
150
+ commonPropsPlugin // 通用属性注入插件
151
+ ]);
152
+ ```
153
+
154
+ ### 插件开发指南
155
+
156
+ #### 错误边界插件示例
157
+
158
+ ```typescript
159
+ import { ErrorBoundary } from 'react-error-boundary';
160
+
161
+ const errorBoundaryPlugin: EnhancedRuntimePlugin = {
162
+ name: 'error-boundary',
163
+ wrapComponent: (WrappedComponent, context) => {
164
+ return function ErrorBoundaryWrapper(props) {
165
+ return (
166
+ <ErrorBoundary
167
+ fallback={<div>组件 {context.remoteName} 加载失败</div>}
168
+ onError={(error) => {
169
+ console.error(`组件错误:`, error);
170
+ }}
171
+ >
172
+ <WrappedComponent {...props} />
173
+ </ErrorBoundary>
174
+ );
175
+ };
176
+ }
177
+ };
178
+ ```
179
+
180
+ #### 属性注入插件示例
181
+
182
+ ```typescript
183
+ const themePlugin: EnhancedRuntimePlugin = {
184
+ name: 'theme-injector',
185
+ injectProps: (props, context) => {
186
+ return {
187
+ ...props,
188
+ theme: {
189
+ mode: 'light',
190
+ primaryColor: '#1890ff'
191
+ }
192
+ };
193
+ }
194
+ };
195
+ ```
196
+
197
+ ### 插件 API
198
+
199
+ #### EnhancedPluginManager
200
+
201
+ ```typescript
202
+ import { getEnhancedPluginManager } from '@ice/mf-runtime';
203
+
204
+ const manager = getEnhancedPluginManager();
205
+
206
+ // 注册增强插件
207
+ manager.register(enhancedPlugin);
208
+
209
+ // 获取插件信息
210
+ const info = manager.getPluginInfo();
211
+ // 返回: [{ name: 'plugin-name', hasWrapper: true, hasInjector: false }]
212
+
213
+ // 移除插件
214
+ manager.removePlugin('plugin-name');
215
+
216
+ // 清空所有插件
217
+ manager.clear();
218
+ ```
219
+
220
+ #### React Hook
221
+
222
+ ```typescript
223
+ import { useEnhancedPluginManager } from '@ice/mf-runtime';
224
+
225
+ function MyComponent() {
226
+ const enhancedPluginManager = useEnhancedPluginManager();
227
+
228
+ // 动态操作插件
229
+ const handleAddPlugin = () => {
230
+ enhancedPluginManager.register(newEnhancedPlugin);
231
+ };
232
+
233
+ return <div>...</div>;
234
+ }
235
+ ```
236
+
17
237
  ## 使用
18
238
 
19
239
  ### 1. 初始化配置
@@ -0,0 +1,294 @@
1
+ # 微前端插件系统使用指南
2
+
3
+ ## 概述
4
+
5
+ `@ice/mf-runtime` 提供了一套增强插件系统,允许开发者对远程组件进行功能扩展,如错误边界、日志记录、性能监控等。
6
+
7
+ ## 快速开始
8
+
9
+ ### 1. 安装依赖
10
+
11
+ ```bash
12
+ npm install @ice/mf-runtime
13
+ ```
14
+
15
+ ### 2. 基本使用
16
+
17
+ ```tsx
18
+ import { RemoteModule, registerEnhancedPlugins } from '@ice/mf-runtime';
19
+ import { createEnhancedLoggingPlugin } from '@ice/mf-plugin-example';
20
+
21
+ // 注册插件
22
+ registerEnhancedPlugins([createEnhancedLoggingPlugin()]);
23
+
24
+ // 使用远程组件
25
+ function App() {
26
+ return (
27
+ <RemoteModule
28
+ scope="remote-app"
29
+ module="Button"
30
+ />
31
+ );
32
+ }
33
+ ```
34
+
35
+ ## 插件开发
36
+
37
+ ### 插件接口
38
+
39
+ ```typescript
40
+ export interface EnhancedRuntimePlugin {
41
+ name: string;
42
+ wrapComponent?: ComponentWrapper;
43
+ injectProps?: PropInjector;
44
+ }
45
+
46
+ export interface ComponentWrapper {
47
+ (
48
+ WrappedComponent: React.ComponentType<any>,
49
+ context: WrapperContext
50
+ ): React.ComponentType<any>;
51
+ }
52
+
53
+ export interface PropInjector {
54
+ (
55
+ props: Record<string, any>,
56
+ context: InjectionContext
57
+ ): Record<string, any>;
58
+ }
59
+ ```
60
+
61
+ ### 上下文信息
62
+
63
+ ```typescript
64
+ export interface WrapperContext {
65
+ remoteName: string;
66
+ moduleName: string;
67
+ props: Record<string, any>;
68
+ React: typeof import('react'); // 正确的 React 实例
69
+ ReactDOM?: typeof import('react-dom'); // 正确的 ReactDOM 实例
70
+ }
71
+
72
+ export interface InjectionContext {
73
+ remoteName: string;
74
+ moduleName: string;
75
+ }
76
+ ```
77
+
78
+ ### 创建插件
79
+
80
+ ```typescript
81
+ import type { EnhancedRuntimePlugin, WrapperContext } from '@ice/mf-runtime';
82
+
83
+ export function createMyPlugin(options = {}): EnhancedRuntimePlugin {
84
+ return {
85
+ name: 'my-plugin',
86
+
87
+ wrapComponent: (WrappedComponent, context: WrapperContext) => {
88
+ // 🔑 使用上下文提供的 React 实例
89
+ const { React: ContextReact } = context;
90
+
91
+ const MyWrapper = ContextReact.forwardRef<any, any>((props, ref) => {
92
+ ContextReact.useEffect(() => {
93
+ console.log(`Component ${context.remoteName}/${context.moduleName} mounted`);
94
+ }, []);
95
+
96
+ return ContextReact.createElement(WrappedComponent, { ...props, ref });
97
+ });
98
+
99
+ MyWrapper.displayName = `MyWrapper(${WrappedComponent.displayName || 'Component'})`;
100
+ return MyWrapper;
101
+ },
102
+
103
+ injectProps: (props, context) => {
104
+ return {
105
+ ...props,
106
+ pluginData: 'injected by my plugin'
107
+ };
108
+ }
109
+ };
110
+ }
111
+ ```
112
+
113
+ ## 内置插件示例
114
+
115
+ ### 日志记录插件
116
+
117
+ ```typescript
118
+ import {
119
+ createEnhancedLoggingPlugin,
120
+ developmentEnhancedLoggingPlugin,
121
+ productionEnhancedLoggingPlugin
122
+ } from '@ice/mf-plugin-example';
123
+
124
+ // 自定义配置
125
+ registerEnhancedPlugins([createEnhancedLoggingPlugin({
126
+ level: 'info',
127
+ logComponentRender: true,
128
+ enablePerformanceMonitoring: true
129
+ })]);
130
+
131
+ // 或使用预定义插件
132
+ registerEnhancedPlugins([
133
+ process.env.NODE_ENV === 'development'
134
+ ? developmentEnhancedLoggingPlugin
135
+ : productionEnhancedLoggingPlugin
136
+ ]);
137
+ ```
138
+
139
+ ### 属性注入插件
140
+
141
+ ```typescript
142
+ import { createPropsInjectionPlugin } from '@ice/mf-plugin-example';
143
+
144
+ registerEnhancedPlugins([createPropsInjectionPlugin({
145
+ globalProps: {
146
+ theme: 'dark',
147
+ version: '1.0.0'
148
+ }
149
+ })]);
150
+ ```
151
+
152
+ ## 插件管理
153
+
154
+ ### 注册插件
155
+
156
+ ```typescript
157
+ import { registerEnhancedPlugins } from '@ice/mf-runtime';
158
+
159
+ // 注册多个插件(推荐方式)
160
+ registerEnhancedPlugins([plugin1, plugin2, plugin3]);
161
+
162
+ // 或通过插件管理器注册
163
+ import { getEnhancedPluginManager } from '@ice/mf-runtime';
164
+ const manager = getEnhancedPluginManager();
165
+ manager.register(myPlugin);
166
+ manager.registerPlugins([plugin1, plugin2]);
167
+ ```
168
+
169
+ ### 获取插件管理器
170
+
171
+ ```typescript
172
+ import { getEnhancedPluginManager } from '@ice/mf-runtime';
173
+
174
+ const manager = getEnhancedPluginManager();
175
+
176
+ // 获取所有插件
177
+ const plugins = manager.getPlugins();
178
+
179
+ // 获取插件信息
180
+ const info = manager.getPluginInfo();
181
+
182
+ // 移除插件
183
+ manager.removePlugin('plugin-name');
184
+
185
+ // 清空所有插件
186
+ manager.clear();
187
+ ```
188
+
189
+ ### 在组件中使用
190
+
191
+ ```typescript
192
+ import { useEnhancedPluginManager } from '@ice/mf-runtime';
193
+
194
+ function MyComponent() {
195
+ const pluginManager = useEnhancedPluginManager();
196
+
197
+ // 动态注册插件
198
+ React.useEffect(() => {
199
+ pluginManager.register(createMyPlugin());
200
+ }, []);
201
+
202
+ return <div>My Component</div>;
203
+ }
204
+ ```
205
+
206
+ ## 远程组件配置
207
+
208
+ ### 基本配置
209
+
210
+ ```tsx
211
+ <RemoteModule
212
+ scope="remote-app"
213
+ module="Button"
214
+ componentProps={{ text: 'Click me' }}
215
+ />
216
+ ```
217
+
218
+
219
+ ## 最佳实践
220
+
221
+ ### 1. React 实例一致性
222
+
223
+ 始终使用上下文提供的 React 实例,避免使用 JSX 语法:
224
+
225
+ ```typescript
226
+ // ✅ 正确 - 使用上下文的 React 实例
227
+ wrapComponent: (WrappedComponent, context) => {
228
+ const { React: ContextReact } = context;
229
+ return ContextReact.forwardRef((props, ref) => {
230
+ // 使用 createElement 确保实例一致性
231
+ return ContextReact.createElement(WrappedComponent, { ...props, ref });
232
+ });
233
+ }
234
+
235
+ // ❌ 错误 - 使用导入的 React 实例
236
+ import React from 'react';
237
+ wrapComponent: (WrappedComponent, context) => {
238
+ return React.forwardRef((props, ref) => { // 可能是错误的 React 实例
239
+ return <WrappedComponent {...props} ref={ref} />; // JSX 使用编译时的 React
240
+ });
241
+ }
242
+ ```
243
+
244
+ **为什么不能直接用 JSX?**
245
+
246
+ 在微前端场景中:
247
+ - 主应用和远程模块可能使用不同版本的 React
248
+ - JSX 编译时绑定到特定的 React 实例
249
+ - 使用 `ContextReact.createElement` 确保运行时使用正确的实例
250
+
251
+ ### 2. Ref 转发
252
+
253
+ 确保正确转发 ref:
254
+
255
+ ```typescript
256
+ const MyWrapper = ContextReact.forwardRef<any, any>((props, ref) => {
257
+ return ContextReact.createElement(WrappedComponent, { ...props, ref });
258
+ });
259
+ ```
260
+
261
+ ## 故障排除
262
+
263
+ ### 常见问题
264
+
265
+ 1. **插件不生效**
266
+ - 确保插件已正确注册
267
+ - 检查插件名称是否唯一
268
+ - 验证插件函数是否正确实现
269
+
270
+ 2. **React Hook 错误**
271
+ - 确保使用上下文提供的 React 实例
272
+ - 检查是否在条件语句中使用 Hook
273
+
274
+ 3. **Ref 转发失败**
275
+ - 确保使用 `React.forwardRef`
276
+ - 检查 ref 是否正确传递给底层组件
277
+
278
+ 4. **类型错误**
279
+ - 确保导入正确的类型定义
280
+ - 使用 `React.ComponentType<any>` 处理动态组件类型
281
+
282
+ ### 调试技巧
283
+
284
+ ```typescript
285
+ // 启用调试日志
286
+ registerEnhancedPlugin(createEnhancedLoggingPlugin({
287
+ level: 'debug',
288
+ logComponentRender: true
289
+ }));
290
+
291
+ // 检查插件状态
292
+ const manager = getEnhancedPluginManager();
293
+ console.log('Registered plugins:', manager.getPluginInfo());
294
+ ```
@@ -2,10 +2,13 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
2
  import { loadRemote } from '@module-federation/runtime';
3
3
  import * as React from 'react';
4
4
  import { useMemo, useState, useLayoutEffect, forwardRef } from 'react';
5
+ import * as ReactDOM from 'react-dom';
5
6
  import { ErrorBoundary } from 'react-error-boundary';
6
7
  import { FallBack } from './FallBack';
7
8
  import { setFederatedModulePublicPath } from './set-public-path';
8
9
  import { getMicroMod } from './mf-global-store';
10
+ import { useEnhancedPluginManager } from './plugin-manager';
11
+ import { isRuntimePluginWrapper } from './types';
9
12
  const useMountNode = (mountNodeConfig)=>{
10
13
  const [resolvedNode, setResolvedNode] = useState(undefined);
11
14
  // 解析各种类型的 mountNode
@@ -35,6 +38,7 @@ const RemoteModuleInner = ({ module, scope, runtime, publicPath, LoadingComponen
35
38
  var _microMod, _runtime, _runtime1;
36
39
  const microMod = getMicroMod(scope);
37
40
  const resolvedMountNode = useMountNode(mountNode);
41
+ const enhancedPluginManager = useEnhancedPluginManager();
38
42
  if ((_microMod = microMod) === null || _microMod === void 0 ? void 0 : _microMod.publicPath) {
39
43
  setFederatedModulePublicPath(microMod.moduleFederatedName, microMod.publicPath);
40
44
  }
@@ -45,35 +49,76 @@ const RemoteModuleInner = ({ module, scope, runtime, publicPath, LoadingComponen
45
49
  if (!module || !scope) return null;
46
50
  return /*#__PURE__*/ React.lazy(async ()=>{
47
51
  var _typedRemoteModule;
52
+ // 使用标准 MF 加载逻辑,MF 插件自动执行
48
53
  const remoteModule = await loadRemote(`${scope}/${module}`);
49
- // 检查是否是来自 runtime plugin 的包装函数(通过标记识别)
50
- if (typeof remoteModule === 'function' && remoteModule.__ICE_MF_RUNTIME_WRAPPER__) {
51
- // 调用包装函数并传入 mountNode 和 containerClassName
52
- const ComponentFromPlugin = remoteModule(resolvedMountNode, fallbackContainerClassName);
54
+ // 使用清晰的对象结构检查是否为 Runtime Plugin 包装器
55
+ if (isRuntimePluginWrapper(remoteModule)) {
56
+ // 提取原始组件、运行时信息和 React 实例
57
+ const { originalComponent, runtimeInfo, reactInstances } = remoteModule();
58
+ const remoteReact = reactInstances.react;
59
+ const remoteReactDOM = reactInstances.reactDOM;
60
+ // 🔑 正确的 HOC 层级顺序:
61
+ // 1. 先应用增强插件(与其他情况保持一致)
62
+ const PluginWrappedComponent = enhancedPluginManager.wrapComponent(originalComponent, {
63
+ remoteName: scope,
64
+ moduleName: module,
65
+ props: componentProps || {},
66
+ React: remoteReact,
67
+ ReactDOM: remoteReactDOM
68
+ });
69
+ // 2. 再应用 FallBack(处理不同 React 版本和 mountNode)
70
+ const FinalComponent = FallBack({
71
+ Original: PluginWrappedComponent,
72
+ remoteVersion: runtimeInfo.remoteVersion ? ()=>runtimeInfo.remoteVersion : undefined,
73
+ hostVersion: runtimeInfo.hostVersion ? ()=>runtimeInfo.hostVersion : undefined,
74
+ remoteReactDOM: runtimeInfo.remoteReactDOM,
75
+ remoteReact: runtimeInfo.remoteReact,
76
+ mountNode: resolvedMountNode,
77
+ containerClassName: fallbackContainerClassName
78
+ });
53
79
  return {
54
- default: ComponentFromPlugin
80
+ default: FinalComponent
55
81
  };
56
82
  }
57
83
  const typedRemoteModule = remoteModule;
84
+ let BaseComponent;
58
85
  if (!((_typedRemoteModule = typedRemoteModule) === null || _typedRemoteModule === void 0 ? void 0 : _typedRemoteModule.default)) {
59
- return {
60
- default: remoteModule
61
- };
86
+ BaseComponent = remoteModule;
87
+ } else {
88
+ BaseComponent = typedRemoteModule.default;
62
89
  }
90
+ let FinalComponent;
91
+ // 如果需要 runtime 处理(不同 React 版本或 mountNode)
63
92
  if (runtime) {
64
93
  const { react, reactDOM } = runtime;
65
- return {
66
- default: FallBack({
67
- Original: typedRemoteModule.default,
68
- remoteReact: ()=>react,
69
- remoteReactDOM: ()=>reactDOM,
70
- mountNode: resolvedMountNode,
71
- containerClassName: fallbackContainerClassName
72
- })
73
- };
94
+ // 先应用增强插件的组件包装器,然后传给 FallBack
95
+ const PluginWrappedComponent = enhancedPluginManager.wrapComponent(BaseComponent, {
96
+ remoteName: scope,
97
+ moduleName: module,
98
+ props: componentProps || {},
99
+ React: react,
100
+ ReactDOM: reactDOM
101
+ });
102
+ FinalComponent = FallBack({
103
+ Original: PluginWrappedComponent,
104
+ remoteReact: ()=>react,
105
+ remoteReactDOM: ()=>reactDOM,
106
+ mountNode: resolvedMountNode,
107
+ containerClassName: fallbackContainerClassName
108
+ });
109
+ } else {
110
+ // 没有 runtime 需求时,直接应用插件包装器
111
+ FinalComponent = enhancedPluginManager.wrapComponent(BaseComponent, {
112
+ remoteName: scope,
113
+ moduleName: module,
114
+ props: componentProps || {},
115
+ React: React,
116
+ ReactDOM: ReactDOM
117
+ });
74
118
  }
119
+ console.log('FinalComponent', FinalComponent);
75
120
  return {
76
- default: typedRemoteModule.default
121
+ default: FinalComponent
77
122
  };
78
123
  });
79
124
  }, [
@@ -82,11 +127,18 @@ const RemoteModuleInner = ({ module, scope, runtime, publicPath, LoadingComponen
82
127
  (_runtime = runtime) === null || _runtime === void 0 ? void 0 : _runtime.react,
83
128
  (_runtime1 = runtime) === null || _runtime1 === void 0 ? void 0 : _runtime1.reactDOM,
84
129
  resolvedMountNode,
85
- fallbackContainerClassName
130
+ fallbackContainerClassName,
131
+ enhancedPluginManager,
132
+ componentProps
86
133
  ]);
87
134
  const Loading = LoadingComponent || /*#__PURE__*/ React.createElement("div", null, "Loading...");
88
135
  const ErrorFallback = ({ error })=>ErrorComponent || /*#__PURE__*/ React.createElement("div", null, "远程模块加载失败: ", error.message);
89
136
  if (!Component) return Loading;
137
+ // 应用增强插件的属性注入
138
+ const injectedProps = enhancedPluginManager.injectProps(componentProps || {}, {
139
+ remoteName: scope,
140
+ moduleName: module
141
+ });
90
142
  return /*#__PURE__*/ React.createElement(ErrorBoundary, {
91
143
  resetKeys: [
92
144
  module,
@@ -98,8 +150,8 @@ const RemoteModuleInner = ({ module, scope, runtime, publicPath, LoadingComponen
98
150
  }, /*#__PURE__*/ React.createElement(React.Suspense, {
99
151
  fallback: Loading
100
152
  }, /*#__PURE__*/ React.createElement(Component, _object_spread({
101
- ref: ref
102
- }, componentProps), children)));
153
+ ref
154
+ }, injectedProps), children)));
103
155
  };
104
156
  // 使用 forwardRef 包装组件以支持 ref
105
157
  export const RemoteModule = /*#__PURE__*/ forwardRef(RemoteModuleInner);
@@ -0,0 +1 @@
1
+ export {};