@module-federation/bridge-react 0.21.5 → 0.22.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 +14 -0
- package/dist/base.cjs.js +29 -0
- package/dist/base.d.ts +311 -0
- package/dist/base.es.js +30 -0
- package/dist/createHelpers-B_L612IN.js +190 -0
- package/dist/createHelpers-Ui5pt7je.mjs +191 -0
- package/dist/data-fetch-server-middleware.es.js +1 -1
- package/dist/data-fetch-utils.cjs.js +1 -1
- package/dist/data-fetch-utils.es.js +8 -8
- package/dist/index.cjs.js +10 -178
- package/dist/index.d.ts +5 -3
- package/dist/index.es.js +19 -186
- package/dist/{lazy-load-component-plugin-BbiXdUFQ.mjs → lazy-load-component-plugin-BkcO9pUC.mjs} +2 -2
- package/dist/{lazy-load-component-plugin-2wIGAon4.js → lazy-load-component-plugin-Bt990iJq.js} +1 -1
- package/dist/lazy-load-component-plugin.cjs.js +2 -2
- package/dist/lazy-load-component-plugin.es.js +2 -2
- package/dist/lazy-utils.es.js +3 -3
- package/dist/{prefetch-CBwY1k41.js → prefetch-D-d4LlJ3.js} +1 -1
- package/dist/{prefetch-yYPFtZpU.mjs → prefetch-DAwiqbcO.mjs} +2 -2
- package/dist/{utils-Bx_8GGd-.mjs → utils-dUgb9Jkm.mjs} +6 -6
- package/package.json +13 -5
- package/src/base.ts +50 -0
- package/src/index.ts +2 -2
- package/src/remote/RemoteAppWrapper.tsx +108 -0
- package/src/remote/base-component/component.tsx +2 -0
- package/src/remote/base-component/create.tsx +23 -0
- package/src/remote/base-component/index.tsx +10 -0
- package/src/remote/createHelpers.tsx +130 -0
- package/src/remote/{component.tsx → router-component/component.tsx} +3 -110
- package/src/remote/router-component/create.tsx +23 -0
- package/src/remote/router-component/index.tsx +10 -0
- package/vite.config.ts +1 -0
- package/src/remote/create.tsx +0 -106
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-CPSTBjEp.mjs";
|
|
2
|
+
import ReactDOM from "react-dom";
|
|
3
|
+
import { L as LoggerInstance, g as getRootDomDefaultClassName } from "./index-DyQNwY2M.mjs";
|
|
4
|
+
import React__default, { forwardRef, useRef, useState, useEffect } from "react";
|
|
5
|
+
import { federationRuntime } from "./plugin.es.js";
|
|
6
|
+
function createReact16Or17Root(container) {
|
|
7
|
+
return {
|
|
8
|
+
render(children) {
|
|
9
|
+
const reactVersion = ReactDOM.version || "";
|
|
10
|
+
const isReact18 = reactVersion.startsWith("18");
|
|
11
|
+
const isReact19 = reactVersion.startsWith("19");
|
|
12
|
+
if (isReact19) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
`React 19 detected in legacy mode. This is not supported. Please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v19'`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
if (isReact18) {
|
|
18
|
+
LoggerInstance.warn(
|
|
19
|
+
`[Bridge-React] React 18 detected in legacy mode. For better compatibility, please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v18'`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
ReactDOM.render(children, container);
|
|
23
|
+
},
|
|
24
|
+
unmount() {
|
|
25
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function createBridgeComponent(bridgeInfo) {
|
|
30
|
+
const fullBridgeInfo = {
|
|
31
|
+
createRoot: createReact16Or17Root,
|
|
32
|
+
...bridgeInfo
|
|
33
|
+
};
|
|
34
|
+
return createBaseBridgeComponent(fullBridgeInfo);
|
|
35
|
+
}
|
|
36
|
+
const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
37
|
+
const {
|
|
38
|
+
moduleName,
|
|
39
|
+
memoryRoute,
|
|
40
|
+
basename,
|
|
41
|
+
providerInfo,
|
|
42
|
+
className,
|
|
43
|
+
style,
|
|
44
|
+
fallback,
|
|
45
|
+
loading,
|
|
46
|
+
...resProps
|
|
47
|
+
} = props;
|
|
48
|
+
const instance = federationRuntime.instance;
|
|
49
|
+
const rootRef = ref && "current" in ref ? ref : useRef(null);
|
|
50
|
+
const renderDom = useRef(null);
|
|
51
|
+
const providerInfoRef = useRef(null);
|
|
52
|
+
const [initialized, setInitialized] = useState(false);
|
|
53
|
+
LoggerInstance.debug(`RemoteAppWrapper instance from props >>>`, instance);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (initialized) return;
|
|
56
|
+
const providerReturn = providerInfo();
|
|
57
|
+
providerInfoRef.current = providerReturn;
|
|
58
|
+
setInitialized(true);
|
|
59
|
+
return () => {
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
61
|
+
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
62
|
+
LoggerInstance.debug(
|
|
63
|
+
`createRemoteAppComponent LazyComponent destroy >>>`,
|
|
64
|
+
{ moduleName, basename, dom: renderDom.current }
|
|
65
|
+
);
|
|
66
|
+
(_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
|
|
67
|
+
moduleName,
|
|
68
|
+
dom: renderDom.current,
|
|
69
|
+
basename,
|
|
70
|
+
memoryRoute,
|
|
71
|
+
fallback,
|
|
72
|
+
...resProps
|
|
73
|
+
});
|
|
74
|
+
(_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
|
|
75
|
+
moduleName,
|
|
76
|
+
dom: renderDom.current
|
|
77
|
+
});
|
|
78
|
+
(_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
|
|
79
|
+
moduleName,
|
|
80
|
+
dom: renderDom.current,
|
|
81
|
+
basename,
|
|
82
|
+
memoryRoute,
|
|
83
|
+
fallback,
|
|
84
|
+
...resProps
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}, [moduleName]);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
var _a, _b, _c, _d, _e, _f;
|
|
91
|
+
if (!initialized || !providerInfoRef.current) return;
|
|
92
|
+
let renderProps = {
|
|
93
|
+
moduleName,
|
|
94
|
+
dom: rootRef.current,
|
|
95
|
+
basename,
|
|
96
|
+
memoryRoute,
|
|
97
|
+
fallback,
|
|
98
|
+
...resProps
|
|
99
|
+
};
|
|
100
|
+
renderDom.current = rootRef.current;
|
|
101
|
+
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(renderProps)) || {};
|
|
102
|
+
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
|
|
103
|
+
providerInfoRef.current.render(renderProps);
|
|
104
|
+
(_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);
|
|
105
|
+
}, [initialized, ...Object.values(props)]);
|
|
106
|
+
const rootComponentClassName = `${getRootDomDefaultClassName(moduleName)} ${className || ""}`;
|
|
107
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: rootComponentClassName, style, ref: rootRef }, loading);
|
|
108
|
+
});
|
|
109
|
+
function createLazyRemoteComponentFactory(RemoteApp) {
|
|
110
|
+
return function createLazyRemoteComponent(info) {
|
|
111
|
+
const exportName = (info == null ? void 0 : info.export) || "default";
|
|
112
|
+
return React__default.lazy(async () => {
|
|
113
|
+
LoggerInstance.debug(
|
|
114
|
+
`createRemoteAppComponent LazyComponent create >>>`,
|
|
115
|
+
{
|
|
116
|
+
lazyComponent: info.loader,
|
|
117
|
+
exportName
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
try {
|
|
121
|
+
const m = await info.loader();
|
|
122
|
+
const moduleName = m && m[Symbol.for("mf_module_id")];
|
|
123
|
+
LoggerInstance.debug(
|
|
124
|
+
`createRemoteAppComponent LazyComponent loadRemote info >>>`,
|
|
125
|
+
{ name: moduleName, module: m, exportName }
|
|
126
|
+
);
|
|
127
|
+
const exportFn = m[exportName];
|
|
128
|
+
if (exportName in m && typeof exportFn === "function") {
|
|
129
|
+
const RemoteAppComponent = forwardRef((props, ref) => {
|
|
130
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
131
|
+
RemoteApp,
|
|
132
|
+
{
|
|
133
|
+
moduleName,
|
|
134
|
+
providerInfo: exportFn,
|
|
135
|
+
exportName: info.export || "default",
|
|
136
|
+
fallback: info.fallback,
|
|
137
|
+
loading: info.loading,
|
|
138
|
+
ref,
|
|
139
|
+
...props
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
default: RemoteAppComponent
|
|
145
|
+
};
|
|
146
|
+
} else {
|
|
147
|
+
LoggerInstance.debug(
|
|
148
|
+
`createRemoteAppComponent LazyComponent module not found >>>`,
|
|
149
|
+
{ name: moduleName, module: m, exportName }
|
|
150
|
+
);
|
|
151
|
+
throw Error(
|
|
152
|
+
`Make sure that ${moduleName} has the correct export when export is ${String(
|
|
153
|
+
exportName
|
|
154
|
+
)}`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
} catch (error) {
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function createRemoteAppComponentFactory(RemoteApp) {
|
|
164
|
+
const createLazyRemoteComponent = createLazyRemoteComponentFactory(RemoteApp);
|
|
165
|
+
return function createRemoteAppComponent(info) {
|
|
166
|
+
const LazyComponent = createLazyRemoteComponent(info);
|
|
167
|
+
return forwardRef((props, ref) => {
|
|
168
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
169
|
+
ErrorBoundary,
|
|
170
|
+
{
|
|
171
|
+
FallbackComponent: info.fallback
|
|
172
|
+
},
|
|
173
|
+
/* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: info.loading }, /* @__PURE__ */ React__default.createElement(LazyComponent, { ...props, ref }))
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function createDeprecatedRemoteComponentFactory(createFn) {
|
|
179
|
+
return function createRemoteComponent(info) {
|
|
180
|
+
LoggerInstance.warn(
|
|
181
|
+
`createRemoteComponent is deprecated, please use createRemoteAppComponent instead!`
|
|
182
|
+
);
|
|
183
|
+
return createFn(info);
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
export {
|
|
187
|
+
RemoteAppWrapper as R,
|
|
188
|
+
createRemoteAppComponentFactory as a,
|
|
189
|
+
createBridgeComponent as b,
|
|
190
|
+
createDeprecatedRemoteComponentFactory as c
|
|
191
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DATA_FETCH_QUERY, l as logger,
|
|
1
|
+
import { D as DATA_FETCH_QUERY, l as logger, e as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, f as fetchData, h as loadDataFetchModule } from "./utils-dUgb9Jkm.mjs";
|
|
2
2
|
import { M as MANIFEST_EXT, S as SEPARATOR } from "./index.esm-CPwSeCvw.mjs";
|
|
3
3
|
function wrapSetTimeout(targetPromise, delay = 2e4, id) {
|
|
4
4
|
if (targetPromise && typeof targetPromise.then === "function") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
4
|
-
const prefetch = require("./prefetch-
|
|
4
|
+
const prefetch = require("./prefetch-D-d4LlJ3.js");
|
|
5
5
|
async function callDataFetch() {
|
|
6
6
|
const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
|
|
7
7
|
if (dataFetch) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { x as DATA_FETCH_FUNCTION } from "./utils-
|
|
2
|
-
import { C,
|
|
3
|
-
import { d as dataFetchFunction } from "./prefetch-
|
|
4
|
-
import { i, p } from "./prefetch-
|
|
1
|
+
import { x as DATA_FETCH_FUNCTION } from "./utils-dUgb9Jkm.mjs";
|
|
2
|
+
import { C, a, b, d, c, g, r } from "./utils-dUgb9Jkm.mjs";
|
|
3
|
+
import { d as dataFetchFunction } from "./prefetch-DAwiqbcO.mjs";
|
|
4
|
+
import { i, p } from "./prefetch-DAwiqbcO.mjs";
|
|
5
5
|
async function callDataFetch() {
|
|
6
6
|
const dataFetch = globalThis[DATA_FETCH_FUNCTION];
|
|
7
7
|
if (dataFetch) {
|
|
@@ -14,12 +14,12 @@ async function callDataFetch() {
|
|
|
14
14
|
}
|
|
15
15
|
export {
|
|
16
16
|
C as CacheSize,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
a as CacheTime,
|
|
18
|
+
b as cache,
|
|
19
19
|
callDataFetch,
|
|
20
|
-
|
|
20
|
+
d as clearStore,
|
|
21
21
|
c as configureCache,
|
|
22
|
-
|
|
22
|
+
g as generateKey,
|
|
23
23
|
i as injectDataFetch,
|
|
24
24
|
p as prefetch,
|
|
25
25
|
r as revalidateTag
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const index = require("./index-DRSBaSu3.js");
|
|
3
|
+
const createHelpers = require("./createHelpers-B_L612IN.js");
|
|
4
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-Bt990iJq.js");
|
|
6
5
|
const React = require("react");
|
|
7
6
|
const ReactRouterDOM = require("react-router-dom");
|
|
8
|
-
const
|
|
9
|
-
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-2wIGAon4.js");
|
|
7
|
+
const index = require("./index-DRSBaSu3.js");
|
|
10
8
|
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
11
9
|
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
12
|
-
const prefetch = require("./prefetch-
|
|
10
|
+
const prefetch = require("./prefetch-D-d4LlJ3.js");
|
|
13
11
|
function _interopNamespaceDefault(e2) {
|
|
14
12
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
15
13
|
if (e2) {
|
|
@@ -27,113 +25,10 @@ function _interopNamespaceDefault(e2) {
|
|
|
27
25
|
return Object.freeze(n);
|
|
28
26
|
}
|
|
29
27
|
const ReactRouterDOM__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactRouterDOM);
|
|
30
|
-
function createReact16Or17Root(container) {
|
|
31
|
-
return {
|
|
32
|
-
render(children) {
|
|
33
|
-
const reactVersion = ReactDOM.version || "";
|
|
34
|
-
const isReact18 = reactVersion.startsWith("18");
|
|
35
|
-
const isReact19 = reactVersion.startsWith("19");
|
|
36
|
-
if (isReact19) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
`React 19 detected in legacy mode. This is not supported. Please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v19'`
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
if (isReact18) {
|
|
42
|
-
index.LoggerInstance.warn(
|
|
43
|
-
`[Bridge-React] React 18 detected in legacy mode. For better compatibility, please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v18'`
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
ReactDOM.render(children, container);
|
|
47
|
-
},
|
|
48
|
-
unmount() {
|
|
49
|
-
ReactDOM.unmountComponentAtNode(container);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function createBridgeComponent(bridgeInfo) {
|
|
54
|
-
const fullBridgeInfo = {
|
|
55
|
-
createRoot: createReact16Or17Root,
|
|
56
|
-
...bridgeInfo
|
|
57
|
-
};
|
|
58
|
-
return bridgeBase.createBaseBridgeComponent(fullBridgeInfo);
|
|
59
|
-
}
|
|
60
28
|
function e() {
|
|
61
29
|
const t = new PopStateEvent("popstate", { state: window.history.state });
|
|
62
30
|
window.dispatchEvent(t);
|
|
63
31
|
}
|
|
64
|
-
const RemoteAppWrapper = React.forwardRef(function(props, ref) {
|
|
65
|
-
const {
|
|
66
|
-
moduleName,
|
|
67
|
-
memoryRoute,
|
|
68
|
-
basename,
|
|
69
|
-
providerInfo,
|
|
70
|
-
className,
|
|
71
|
-
style,
|
|
72
|
-
fallback,
|
|
73
|
-
loading,
|
|
74
|
-
...resProps
|
|
75
|
-
} = props;
|
|
76
|
-
const instance = plugin.federationRuntime.instance;
|
|
77
|
-
const rootRef = ref && "current" in ref ? ref : React.useRef(null);
|
|
78
|
-
const renderDom = React.useRef(null);
|
|
79
|
-
const providerInfoRef = React.useRef(null);
|
|
80
|
-
const [initialized, setInitialized] = React.useState(false);
|
|
81
|
-
index.LoggerInstance.debug(`RemoteAppWrapper instance from props >>>`, instance);
|
|
82
|
-
React.useEffect(() => {
|
|
83
|
-
if (initialized) return;
|
|
84
|
-
const providerReturn = providerInfo();
|
|
85
|
-
providerInfoRef.current = providerReturn;
|
|
86
|
-
setInitialized(true);
|
|
87
|
-
return () => {
|
|
88
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
89
|
-
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
|
|
90
|
-
index.LoggerInstance.debug(
|
|
91
|
-
`createRemoteAppComponent LazyComponent destroy >>>`,
|
|
92
|
-
{ moduleName, basename, dom: renderDom.current }
|
|
93
|
-
);
|
|
94
|
-
(_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
|
|
95
|
-
moduleName,
|
|
96
|
-
dom: renderDom.current,
|
|
97
|
-
basename,
|
|
98
|
-
memoryRoute,
|
|
99
|
-
fallback,
|
|
100
|
-
...resProps
|
|
101
|
-
});
|
|
102
|
-
(_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
|
|
103
|
-
moduleName,
|
|
104
|
-
dom: renderDom.current
|
|
105
|
-
});
|
|
106
|
-
(_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
|
|
107
|
-
moduleName,
|
|
108
|
-
dom: renderDom.current,
|
|
109
|
-
basename,
|
|
110
|
-
memoryRoute,
|
|
111
|
-
fallback,
|
|
112
|
-
...resProps
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}, [moduleName]);
|
|
117
|
-
React.useEffect(() => {
|
|
118
|
-
var _a, _b, _c, _d, _e, _f;
|
|
119
|
-
if (!initialized || !providerInfoRef.current) return;
|
|
120
|
-
let renderProps = {
|
|
121
|
-
moduleName,
|
|
122
|
-
dom: rootRef.current,
|
|
123
|
-
basename,
|
|
124
|
-
memoryRoute,
|
|
125
|
-
fallback,
|
|
126
|
-
...resProps
|
|
127
|
-
};
|
|
128
|
-
renderDom.current = rootRef.current;
|
|
129
|
-
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(renderProps)) || {};
|
|
130
|
-
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
|
|
131
|
-
providerInfoRef.current.render(renderProps);
|
|
132
|
-
(_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);
|
|
133
|
-
}, [initialized, ...Object.values(props)]);
|
|
134
|
-
const rootComponentClassName = `${index.getRootDomDefaultClassName(moduleName)} ${className || ""}`;
|
|
135
|
-
return /* @__PURE__ */ React.createElement("div", { className: rootComponentClassName, style, ref: rootRef }, loading);
|
|
136
|
-
});
|
|
137
32
|
function withRouterData(WrappedComponent) {
|
|
138
33
|
const Component = React.forwardRef(function(props, ref) {
|
|
139
34
|
var _a;
|
|
@@ -205,74 +100,12 @@ function withRouterData(WrappedComponent) {
|
|
|
205
100
|
return /* @__PURE__ */ React.createElement(Component, { ...props, ref });
|
|
206
101
|
});
|
|
207
102
|
}
|
|
208
|
-
const RemoteApp = withRouterData(RemoteAppWrapper);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
exportName
|
|
215
|
-
});
|
|
216
|
-
try {
|
|
217
|
-
const m = await info.loader();
|
|
218
|
-
const moduleName = m && m[Symbol.for("mf_module_id")];
|
|
219
|
-
index.LoggerInstance.debug(
|
|
220
|
-
`createRemoteAppComponent LazyComponent loadRemote info >>>`,
|
|
221
|
-
{ name: moduleName, module: m, exportName }
|
|
222
|
-
);
|
|
223
|
-
const exportFn = m[exportName];
|
|
224
|
-
if (exportName in m && typeof exportFn === "function") {
|
|
225
|
-
const RemoteAppComponent = React.forwardRef((props, ref) => {
|
|
226
|
-
return /* @__PURE__ */ React.createElement(
|
|
227
|
-
RemoteApp,
|
|
228
|
-
{
|
|
229
|
-
moduleName,
|
|
230
|
-
providerInfo: exportFn,
|
|
231
|
-
exportName: info.export || "default",
|
|
232
|
-
fallback: info.fallback,
|
|
233
|
-
loading: info.loading,
|
|
234
|
-
ref,
|
|
235
|
-
...props
|
|
236
|
-
}
|
|
237
|
-
);
|
|
238
|
-
});
|
|
239
|
-
return {
|
|
240
|
-
default: RemoteAppComponent
|
|
241
|
-
};
|
|
242
|
-
} else {
|
|
243
|
-
index.LoggerInstance.debug(
|
|
244
|
-
`createRemoteAppComponent LazyComponent module not found >>>`,
|
|
245
|
-
{ name: moduleName, module: m, exportName }
|
|
246
|
-
);
|
|
247
|
-
throw Error(
|
|
248
|
-
`Make sure that ${moduleName} has the correct export when export is ${String(
|
|
249
|
-
exportName
|
|
250
|
-
)}`
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
} catch (error) {
|
|
254
|
-
throw error;
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
function createRemoteAppComponent(info) {
|
|
259
|
-
const LazyComponent = createLazyRemoteComponent(info);
|
|
260
|
-
return React.forwardRef((props, ref) => {
|
|
261
|
-
return /* @__PURE__ */ React.createElement(
|
|
262
|
-
bridgeBase.ErrorBoundary,
|
|
263
|
-
{
|
|
264
|
-
FallbackComponent: info.fallback
|
|
265
|
-
},
|
|
266
|
-
/* @__PURE__ */ React.createElement(React.Suspense, { fallback: info.loading }, /* @__PURE__ */ React.createElement(LazyComponent, { ...props, ref }))
|
|
267
|
-
);
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
function createRemoteComponent(info) {
|
|
271
|
-
index.LoggerInstance.warn(
|
|
272
|
-
`createRemoteComponent is deprecated, please use createRemoteAppComponent instead!`
|
|
273
|
-
);
|
|
274
|
-
return createRemoteAppComponent(info);
|
|
275
|
-
}
|
|
103
|
+
const RemoteApp = withRouterData(createHelpers.RemoteAppWrapper);
|
|
104
|
+
const createRemoteAppComponent = createHelpers.createRemoteAppComponentFactory(RemoteApp);
|
|
105
|
+
const createRemoteComponent = createHelpers.createDeprecatedRemoteComponentFactory(
|
|
106
|
+
createRemoteAppComponent
|
|
107
|
+
);
|
|
108
|
+
exports.createBridgeComponent = createHelpers.createBridgeComponent;
|
|
276
109
|
exports.autoFetchDataPlugin = lazyLoadComponentPlugin.autoFetchData;
|
|
277
110
|
exports.collectSSRAssets = lazyLoadComponentPlugin.collectSSRAssets;
|
|
278
111
|
exports.createLazyComponent = lazyLoadComponentPlugin.createLazyComponent;
|
|
@@ -288,6 +121,5 @@ exports.revalidateTag = lazyUtils.revalidateTag;
|
|
|
288
121
|
exports.setSSREnv = lazyUtils.setSSREnv;
|
|
289
122
|
exports.callDataFetch = dataFetchUtils.callDataFetch;
|
|
290
123
|
exports.prefetch = prefetch.prefetch;
|
|
291
|
-
exports.createBridgeComponent = createBridgeComponent;
|
|
292
124
|
exports.createRemoteAppComponent = createRemoteAppComponent;
|
|
293
125
|
exports.createRemoteComponent = createRemoteComponent;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { default as default_2 } from 'react';
|
|
2
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
2
3
|
import { getInstance } from '@module-federation/runtime';
|
|
3
4
|
import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
|
|
4
5
|
import * as React_2 from 'react';
|
|
5
6
|
import { ReactNode } from 'react';
|
|
7
|
+
import { RefAttributes } from 'react';
|
|
6
8
|
|
|
7
9
|
export declare const autoFetchDataPlugin: () => ModuleFederationRuntimePlugin;
|
|
8
10
|
|
|
@@ -82,12 +84,12 @@ export declare type CreateLazyComponentOptions<T, E extends keyof T> = {
|
|
|
82
84
|
injectLink?: boolean;
|
|
83
85
|
};
|
|
84
86
|
|
|
85
|
-
export declare
|
|
87
|
+
export declare const createRemoteAppComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => ForwardRefExoticComponent<Omit<RemoteComponentProps<Record<string, unknown>>, "ref"> & RefAttributes<HTMLDivElement>>;
|
|
86
88
|
|
|
87
89
|
/**
|
|
88
|
-
* @deprecated
|
|
90
|
+
* @deprecated createRemoteComponent is deprecated, please use createRemoteAppComponent instead!
|
|
89
91
|
*/
|
|
90
|
-
export declare
|
|
92
|
+
export declare const createRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => any;
|
|
91
93
|
|
|
92
94
|
export declare interface CreateRootOptions {
|
|
93
95
|
identifierPrefix?: string;
|