@module-federation/bridge-react 0.7.6 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @module-federation/bridge-react
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 542164e: chore(bridge-react): set react-router-dom peer version to >=4 <7
8
+ - @module-federation/sdk@0.8.0
9
+ - @module-federation/bridge-shared@0.8.0
10
+
11
+ ## 0.7.7
12
+
13
+ ### Patch Changes
14
+
15
+ - ae5ee1e: feat: mount bridge api to module instance
16
+ - @module-federation/sdk@0.7.7
17
+ - @module-federation/bridge-shared@0.7.7
18
+
3
19
  ## 0.7.6
4
20
 
5
21
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const context = require("./context-BcJ-YlNr.cjs");
5
5
  const ReactRouterDOM = require("react-router-dom");
6
- const runtime = require("@module-federation/runtime");
6
+ const plugin = require("./plugin.cjs.js");
7
7
  const ReactDOM = require("react-dom");
8
8
  function _interopNamespaceDefault(e2) {
9
9
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -135,11 +135,11 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
135
135
  fallback,
136
136
  ...resProps
137
137
  } = props;
138
+ const instance = plugin.federationRuntime.instance;
138
139
  const rootRef = ref && "current" in ref ? ref : React.useRef(null);
139
140
  const renderDom = React.useRef(null);
140
141
  const providerInfoRef = React.useRef(null);
141
- const hostInstance = runtime.getInstance();
142
- context.LoggerInstance.log(`RemoteAppWrapper hostInstance >>>`, hostInstance);
142
+ context.LoggerInstance.log(`RemoteAppWrapper instance from props >>>`, instance);
143
143
  React.useEffect(() => {
144
144
  const renderTimeout = setTimeout(() => {
145
145
  var _a, _b, _c, _d, _e, _f;
@@ -160,16 +160,14 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
160
160
  );
161
161
  context.LoggerInstance.log(
162
162
  `createRemoteComponent LazyComponent hostInstance >>>`,
163
- hostInstance
163
+ instance
164
164
  );
165
- const beforeBridgeRenderRes = ((_c = (_b = (_a = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(
165
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(
166
166
  renderProps
167
167
  )) || {};
168
168
  renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
169
169
  providerReturn.render(renderProps);
170
- (_f = (_e = (_d = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(
171
- renderProps
172
- );
170
+ (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps);
173
171
  });
174
172
  return () => {
175
173
  clearTimeout(renderTimeout);
@@ -180,7 +178,7 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
180
178
  `createRemoteComponent LazyComponent destroy >>>`,
181
179
  { moduleName, basename, dom: renderDom.current }
182
180
  );
183
- (_d = (_c = (_b = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
181
+ (_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
184
182
  moduleName,
185
183
  dom: renderDom.current,
186
184
  basename,
@@ -192,7 +190,7 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
192
190
  moduleName,
193
191
  dom: renderDom.current
194
192
  });
195
- (_h = (_g = (_f = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
193
+ (_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
196
194
  moduleName,
197
195
  dom: renderDom.current,
198
196
  basename,
@@ -214,7 +212,7 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
214
212
  }
215
213
  );
216
214
  };
217
- RemoteApp2["__APP_VERSION__"] = "0.7.6";
215
+ RemoteApp2["__APP_VERSION__"] = "0.8.0";
218
216
  return /* @__PURE__ */ React.createElement(RemoteApp2, null);
219
217
  });
220
218
  function withRouterData(WrappedComponent) {
@@ -366,8 +364,11 @@ if (process.env.NODE_ENV === "production") {
366
364
  function createBridgeComponent(bridgeInfo) {
367
365
  return () => {
368
366
  const rootMap = /* @__PURE__ */ new Map();
369
- const instance = runtime.getInstance();
370
- context.LoggerInstance.log(`createBridgeComponent remote instance`, instance);
367
+ const instance = plugin.federationRuntime.instance;
368
+ context.LoggerInstance.log(
369
+ `createBridgeComponent instance from props >>>`,
370
+ instance
371
+ );
371
372
  const RawComponent = (info) => {
372
373
  const { appInfo, propsInfo, ...restProps } = info;
373
374
  const { moduleName, memoryRoute, basename = "/" } = appInfo;
package/dist/index.d.ts CHANGED
@@ -12,12 +12,7 @@ export declare function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>
12
12
  __BRIDGE_FN__: (_args: T) => void;
13
13
  };
14
14
 
15
- export declare function createRemoteComponent<T, E extends keyof T>(info: {
16
- loader: () => Promise<T>;
17
- loading: default_2.ReactNode;
18
- fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
19
- export?: E;
20
- }): default_2.ForwardRefExoticComponent<default_2.PropsWithoutRef<ProviderParams & ("__BRIDGE_FN__" extends keyof (T[E] extends (...args: any) => any ? ReturnType<T[E]> : never) ? (T[E] extends (...args: any) => any ? ReturnType<T[E]> : never)["__BRIDGE_FN__"] extends (...args: any) => any ? Parameters<(T[E] extends (...args: any) => any ? ReturnType<T[E]> : never)["__BRIDGE_FN__"]>[0] : {} : {})> & default_2.RefAttributes<HTMLDivElement>>;
15
+ export declare function createRemoteComponent<T, E extends keyof T>(info: LazyRemoteComponentInfo<T, E>): default_2.ForwardRefExoticComponent<default_2.PropsWithoutRef<ProviderParams & ("__BRIDGE_FN__" extends keyof (T[E] extends (...args: any) => any ? ReturnType<T[E]> : never) ? (T[E] extends (...args: any) => any ? ReturnType<T[E]> : never)["__BRIDGE_FN__"] extends (...args: any) => any ? Parameters<(T[E] extends (...args: any) => any ? ReturnType<T[E]> : never)["__BRIDGE_FN__"]>[0] : {} : {})> & default_2.RefAttributes<HTMLDivElement>>;
21
16
 
22
17
  declare type DestroyParams = {
23
18
  moduleName: string;
@@ -48,6 +43,13 @@ declare type FallbackProps = {
48
43
  resetErrorBoundary: (...args: any[]) => void;
49
44
  };
50
45
 
46
+ declare type LazyRemoteComponentInfo<T, E extends keyof T> = {
47
+ loader: () => Promise<T>;
48
+ loading: default_2.ReactNode;
49
+ fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
50
+ export?: E;
51
+ };
52
+
51
53
  declare type ProviderFnParams<T> = {
52
54
  rootComponent: React_2.ComponentType<T>;
53
55
  render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
package/dist/index.es.js CHANGED
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import React__default, { createContext, Component, createElement, isValidElement, forwardRef, useRef, useEffect, useContext, useState } from "react";
3
3
  import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin, a as atLeastReact18, R as RouterContext } from "./context-CUbFnlO5.js";
4
4
  import * as ReactRouterDOM from "react-router-dom";
5
- import { getInstance } from "@module-federation/runtime";
5
+ import { federationRuntime } from "./plugin.es.js";
6
6
  import ReactDOM from "react-dom";
7
7
  const ErrorBoundaryContext = createContext(null);
8
8
  const initialState = {
@@ -116,11 +116,11 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
116
116
  fallback,
117
117
  ...resProps
118
118
  } = props;
119
+ const instance = federationRuntime.instance;
119
120
  const rootRef = ref && "current" in ref ? ref : useRef(null);
120
121
  const renderDom = useRef(null);
121
122
  const providerInfoRef = useRef(null);
122
- const hostInstance = getInstance();
123
- LoggerInstance.log(`RemoteAppWrapper hostInstance >>>`, hostInstance);
123
+ LoggerInstance.log(`RemoteAppWrapper instance from props >>>`, instance);
124
124
  useEffect(() => {
125
125
  const renderTimeout = setTimeout(() => {
126
126
  var _a, _b, _c, _d, _e, _f;
@@ -141,16 +141,14 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
141
141
  );
142
142
  LoggerInstance.log(
143
143
  `createRemoteComponent LazyComponent hostInstance >>>`,
144
- hostInstance
144
+ instance
145
145
  );
146
- const beforeBridgeRenderRes = ((_c = (_b = (_a = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(
146
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(
147
147
  renderProps
148
148
  )) || {};
149
149
  renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
150
150
  providerReturn.render(renderProps);
151
- (_f = (_e = (_d = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(
152
- renderProps
153
- );
151
+ (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps);
154
152
  });
155
153
  return () => {
156
154
  clearTimeout(renderTimeout);
@@ -161,7 +159,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
161
159
  `createRemoteComponent LazyComponent destroy >>>`,
162
160
  { moduleName, basename, dom: renderDom.current }
163
161
  );
164
- (_d = (_c = (_b = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
162
+ (_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
165
163
  moduleName,
166
164
  dom: renderDom.current,
167
165
  basename,
@@ -173,7 +171,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
173
171
  moduleName,
174
172
  dom: renderDom.current
175
173
  });
176
- (_h = (_g = (_f = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
174
+ (_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
177
175
  moduleName,
178
176
  dom: renderDom.current,
179
177
  basename,
@@ -195,7 +193,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
195
193
  }
196
194
  );
197
195
  };
198
- RemoteApp2["__APP_VERSION__"] = "0.7.6";
196
+ RemoteApp2["__APP_VERSION__"] = "0.8.0";
199
197
  return /* @__PURE__ */ React__default.createElement(RemoteApp2, null);
200
198
  });
201
199
  function withRouterData(WrappedComponent) {
@@ -347,8 +345,11 @@ if (process.env.NODE_ENV === "production") {
347
345
  function createBridgeComponent(bridgeInfo) {
348
346
  return () => {
349
347
  const rootMap = /* @__PURE__ */ new Map();
350
- const instance = getInstance();
351
- LoggerInstance.log(`createBridgeComponent remote instance`, instance);
348
+ const instance = federationRuntime.instance;
349
+ LoggerInstance.log(
350
+ `createBridgeComponent instance from props >>>`,
351
+ instance
352
+ );
352
353
  const RawComponent = (info) => {
353
354
  const { appInfo, propsInfo, ...restProps } = info;
354
355
  const { moduleName, memoryRoute, basename = "/" } = appInfo;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const federationRuntime = { instance: null };
4
+ function BridgeReactPlugin() {
5
+ return {
6
+ name: "bridge-react-plugin",
7
+ beforeInit(args) {
8
+ federationRuntime.instance = args.origin;
9
+ return args;
10
+ }
11
+ };
12
+ }
13
+ exports.default = BridgeReactPlugin;
14
+ exports.federationRuntime = federationRuntime;
@@ -0,0 +1,13 @@
1
+ import { FederationHost } from '@module-federation/runtime';
2
+ import { FederationRuntimePlugin } from '@module-federation/runtime';
3
+
4
+ declare function BridgeReactPlugin(): FederationRuntimePlugin;
5
+ export default BridgeReactPlugin;
6
+
7
+ export declare const federationRuntime: FederationRuntimeType;
8
+
9
+ export declare type FederationRuntimeType = {
10
+ instance: FederationHost | null;
11
+ };
12
+
13
+ export { }
@@ -0,0 +1,14 @@
1
+ const federationRuntime = { instance: null };
2
+ function BridgeReactPlugin() {
3
+ return {
4
+ name: "bridge-react-plugin",
5
+ beforeInit(args) {
6
+ federationRuntime.instance = args.origin;
7
+ return args;
8
+ }
9
+ };
10
+ }
11
+ export {
12
+ BridgeReactPlugin as default,
13
+ federationRuntime
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-react",
3
- "version": "0.7.6",
3
+ "version": "0.8.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -26,6 +26,11 @@
26
26
  "import": "./dist/router.es.js",
27
27
  "require": "./dist/router.cjs.js"
28
28
  },
29
+ "./plugin": {
30
+ "types": "./dist/plugin.d.ts",
31
+ "import": "./dist/plugin.es.js",
32
+ "require": "./dist/plugin.es.js"
33
+ },
29
34
  "./router-v5": {
30
35
  "types": "./dist/router-v5.d.ts",
31
36
  "import": "./dist/router-v5.es.js",
@@ -41,20 +46,19 @@
41
46
  "dependencies": {
42
47
  "@loadable/component": "^5.16.4",
43
48
  "react-error-boundary": "^4.0.13",
44
- "@module-federation/bridge-shared": "0.7.6",
45
- "@module-federation/sdk": "0.7.6",
46
- "@module-federation/runtime": "0.7.6"
49
+ "@module-federation/bridge-shared": "0.8.0",
50
+ "@module-federation/sdk": "0.8.0"
47
51
  },
48
52
  "peerDependencies": {
49
53
  "react": ">=16.9.0",
50
54
  "react-dom": ">=16.9.0",
51
- "react-router-dom": ">=4"
55
+ "react-router-dom": "^4 || ^5 || ^6"
52
56
  },
53
57
  "devDependencies": {
54
58
  "@testing-library/react": "15.0.7",
55
59
  "@types/react": "18.2.79",
56
60
  "@types/react-dom": "18.3.0",
57
- "@vitejs/plugin-react": "^4.3.0",
61
+ "@vitejs/plugin-react": "^4.3.3",
58
62
  "@vitejs/plugin-vue": "^5.0.4",
59
63
  "@vitejs/plugin-vue-jsx": "^4.0.0",
60
64
  "jsdom": "^24.1.0",
@@ -63,7 +67,8 @@
63
67
  "react-router-dom": "6.22.3",
64
68
  "typescript": "^5.2.2",
65
69
  "vite": "^5.2.14",
66
- "vite-plugin-dts": "^3.9.1"
70
+ "vite-plugin-dts": "^4.3.0",
71
+ "@module-federation/runtime": "0.8.0"
67
72
  },
68
73
  "scripts": {
69
74
  "dev": "vite",
package/src/create.tsx CHANGED
@@ -18,12 +18,16 @@ interface RemoteModule {
18
18
  };
19
19
  }
20
20
 
21
- function createLazyRemoteComponent<T, E extends keyof T>(info: {
21
+ type LazyRemoteComponentInfo<T, E extends keyof T> = {
22
22
  loader: () => Promise<T>;
23
23
  loading: React.ReactNode;
24
24
  fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
25
25
  export?: E;
26
- }) {
26
+ };
27
+
28
+ function createLazyRemoteComponent<T, E extends keyof T>(
29
+ info: LazyRemoteComponentInfo<T, E>,
30
+ ) {
27
31
  const exportName = info?.export || 'default';
28
32
  return React.lazy(async () => {
29
33
  LoggerInstance.log(`createRemoteComponent LazyComponent create >>>`, {
@@ -83,12 +87,9 @@ function createLazyRemoteComponent<T, E extends keyof T>(info: {
83
87
  });
84
88
  }
85
89
 
86
- export function createRemoteComponent<T, E extends keyof T>(info: {
87
- loader: () => Promise<T>;
88
- loading: React.ReactNode;
89
- fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
90
- export?: E;
91
- }) {
90
+ export function createRemoteComponent<T, E extends keyof T>(
91
+ info: LazyRemoteComponentInfo<T, E>,
92
+ ) {
92
93
  type ExportType = T[E] extends (...args: any) => any
93
94
  ? ReturnType<T[E]>
94
95
  : never;
package/src/plugin.ts ADDED
@@ -0,0 +1,20 @@
1
+ import type { FederationRuntimePlugin } from '@module-federation/runtime';
2
+ import type { FederationHost } from '@module-federation/runtime';
3
+
4
+ export type FederationRuntimeType = {
5
+ instance: FederationHost | null;
6
+ };
7
+
8
+ export const federationRuntime: FederationRuntimeType = { instance: null };
9
+
10
+ function BridgeReactPlugin(): FederationRuntimePlugin {
11
+ return {
12
+ name: 'bridge-react-plugin',
13
+ beforeInit(args) {
14
+ federationRuntime.instance = args.origin;
15
+ return args;
16
+ },
17
+ };
18
+ }
19
+
20
+ export default BridgeReactPlugin;
package/src/provider.tsx CHANGED
@@ -9,7 +9,7 @@ import type {
9
9
  import { ErrorBoundary } from 'react-error-boundary';
10
10
  import { RouterContext } from './context';
11
11
  import { LoggerInstance, atLeastReact18 } from './utils';
12
- import { getInstance } from '@module-federation/runtime';
12
+ import { federationRuntime } from './plugin';
13
13
 
14
14
  type RenderParams = RenderFnParams & {
15
15
  [key: string]: unknown;
@@ -20,7 +20,7 @@ type DestroyParams = {
20
20
  };
21
21
  type RootType = HTMLElement | ReactDOMClient.Root;
22
22
 
23
- type ProviderFnParams<T> = {
23
+ export type ProviderFnParams<T> = {
24
24
  rootComponent: React.ComponentType<T>;
25
25
  render?: (
26
26
  App: React.ReactElement,
@@ -31,8 +31,11 @@ type ProviderFnParams<T> = {
31
31
  export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
32
32
  return () => {
33
33
  const rootMap = new Map<any, RootType>();
34
- const instance = getInstance();
35
- LoggerInstance.log(`createBridgeComponent remote instance`, instance);
34
+ const instance = federationRuntime.instance;
35
+ LoggerInstance.log(
36
+ `createBridgeComponent instance from props >>>`,
37
+ instance,
38
+ );
36
39
 
37
40
  const RawComponent = (info: { propsInfo: T; appInfo: ProviderParams }) => {
38
41
  const { appInfo, propsInfo, ...restProps } = info;
@@ -95,7 +98,6 @@ export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
95
98
  const renderFn = bridgeInfo?.render || ReactDOM.render;
96
99
  renderFn?.(rootComponentWithErrorBoundary, info.dom);
97
100
  }
98
-
99
101
  instance?.bridgeHook?.lifecycle?.afterBridgeRender?.emit(info) || {};
100
102
  },
101
103
 
@@ -103,7 +105,6 @@ export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
103
105
  LoggerInstance.log(`createBridgeComponent destroy Info`, {
104
106
  dom: info.dom,
105
107
  });
106
-
107
108
  instance?.bridgeHook?.lifecycle?.beforeBridgeDestroy?.emit(info);
108
109
 
109
110
  // call destroy function
@@ -10,7 +10,7 @@ import type { ProviderParams } from '@module-federation/bridge-shared';
10
10
  import { dispatchPopstateEnv } from '@module-federation/bridge-shared';
11
11
  import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
12
12
  import { LoggerInstance, pathJoin, getRootDomDefaultClassName } from '../utils';
13
- import { getInstance } from '@module-federation/runtime';
13
+ import { federationRuntime } from '../plugin';
14
14
 
15
15
  declare const __APP_VERSION__: string;
16
16
  export interface RenderFnParams extends ProviderParams {
@@ -53,6 +53,7 @@ const RemoteAppWrapper = forwardRef(function (
53
53
  ...resProps
54
54
  } = props;
55
55
 
56
+ const instance = federationRuntime.instance;
56
57
  const rootRef: React.MutableRefObject<HTMLDivElement | null> =
57
58
  ref && 'current' in ref
58
59
  ? (ref as React.MutableRefObject<HTMLDivElement | null>)
@@ -60,8 +61,8 @@ const RemoteAppWrapper = forwardRef(function (
60
61
 
61
62
  const renderDom: React.MutableRefObject<HTMLElement | null> = useRef(null);
62
63
  const providerInfoRef = useRef<any>(null);
63
- const hostInstance = getInstance();
64
- LoggerInstance.log(`RemoteAppWrapper hostInstance >>>`, hostInstance);
64
+
65
+ LoggerInstance.log(`RemoteAppWrapper instance from props >>>`, instance);
65
66
 
66
67
  useEffect(() => {
67
68
  const renderTimeout = setTimeout(() => {
@@ -84,18 +85,16 @@ const RemoteAppWrapper = forwardRef(function (
84
85
 
85
86
  LoggerInstance.log(
86
87
  `createRemoteComponent LazyComponent hostInstance >>>`,
87
- hostInstance,
88
+ instance,
88
89
  );
89
90
  const beforeBridgeRenderRes =
90
- hostInstance?.bridgeHook?.lifecycle?.beforeBridgeRender?.emit(
91
+ instance?.bridgeHook?.lifecycle?.beforeBridgeRender?.emit(
91
92
  renderProps,
92
93
  ) || {};
93
94
  // @ts-ignore
94
95
  renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
95
96
  providerReturn.render(renderProps);
96
- hostInstance?.bridgeHook?.lifecycle?.afterBridgeRender?.emit(
97
- renderProps,
98
- );
97
+ instance?.bridgeHook?.lifecycle?.afterBridgeRender?.emit(renderProps);
99
98
  });
100
99
 
101
100
  return () => {
@@ -107,7 +106,7 @@ const RemoteAppWrapper = forwardRef(function (
107
106
  { moduleName, basename, dom: renderDom.current },
108
107
  );
109
108
 
110
- hostInstance?.bridgeHook?.lifecycle?.beforeBridgeDestroy?.emit({
109
+ instance?.bridgeHook?.lifecycle?.beforeBridgeDestroy?.emit({
111
110
  moduleName,
112
111
  dom: renderDom.current,
113
112
  basename,
@@ -121,7 +120,7 @@ const RemoteAppWrapper = forwardRef(function (
121
120
  dom: renderDom.current,
122
121
  });
123
122
 
124
- hostInstance?.bridgeHook?.lifecycle?.afterBridgeDestroy?.emit({
123
+ instance?.bridgeHook?.lifecycle?.afterBridgeDestroy?.emit({
125
124
  moduleName,
126
125
  dom: renderDom.current,
127
126
  basename,
package/vite.config.ts CHANGED
@@ -21,6 +21,7 @@ export default defineConfig({
21
21
  lib: {
22
22
  entry: {
23
23
  index: path.resolve(__dirname, 'src/index.ts'),
24
+ plugin: path.resolve(__dirname, 'src/plugin.ts'),
24
25
  router: path.resolve(__dirname, 'src/router.tsx'),
25
26
  'router-v5': path.resolve(__dirname, 'src/router-v5.tsx'),
26
27
  'router-v6': path.resolve(__dirname, 'src/router-v6.tsx'),
@@ -36,7 +37,6 @@ export default defineConfig({
36
37
  'react-router-dom/',
37
38
  'react-router-dom/index.js',
38
39
  'react-router-dom/dist/index.js',
39
- '@module-federation/runtime',
40
40
  ],
41
41
  plugins: [
42
42
  {