@module-federation/bridge-react 0.20.0 → 0.21.1
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 +19 -0
- package/dist/{bridge-base-Bn6DO0Fi.js → bridge-base-B2malZDo.js} +6 -4
- package/dist/{bridge-base-DxcR1fja.mjs → bridge-base-DRFFglgm.mjs} +6 -4
- package/dist/data-fetch-server-middleware.cjs.js +2 -2
- package/dist/data-fetch-server-middleware.es.js +2 -2
- package/dist/data-fetch-utils.cjs.js +2 -2
- package/dist/data-fetch-utils.es.js +4 -4
- package/dist/{index-DqCpgmgH.js → index-DRSBaSu3.js} +1 -1
- package/dist/{index-Dm-M9ouh.mjs → index-DyQNwY2M.mjs} +1 -1
- package/dist/index.cjs.js +6 -6
- package/dist/index.d.ts +26 -3
- package/dist/index.es.js +6 -6
- package/dist/{index.esm-CzoIcLts.js → index.esm-BWaKho-8.js} +34 -2
- package/dist/{index.esm-JLwyxgUK.mjs → index.esm-CPwSeCvw.mjs} +34 -2
- package/dist/{lazy-load-component-plugin-C-qNUGjT.js → lazy-load-component-plugin-IOan5uEb.js} +2 -2
- package/dist/{lazy-load-component-plugin-Bcm5-gd8.mjs → lazy-load-component-plugin-ZkRCYTos.mjs} +2 -2
- package/dist/lazy-load-component-plugin.cjs.js +2 -2
- package/dist/lazy-load-component-plugin.es.js +2 -2
- package/dist/lazy-utils.cjs.js +2 -2
- package/dist/lazy-utils.es.js +2 -2
- package/dist/{prefetch-NDhOcbO7.js → prefetch-CTmmXyx-.js} +3 -3
- package/dist/{prefetch-COMVhC39.mjs → prefetch-D6cu5QUG.mjs} +3 -3
- package/dist/router-v5.cjs.js +1 -1
- package/dist/router-v5.es.js +1 -1
- package/dist/router-v6.cjs.js +1 -1
- package/dist/router-v6.es.js +1 -1
- package/dist/router-v7.cjs.js +83 -0
- package/dist/router-v7.d.ts +20 -0
- package/dist/router-v7.es.js +61 -0
- package/dist/router.cjs.js +1 -1
- package/dist/router.es.js +1 -1
- package/dist/{utils-BTpxHmva.mjs → utils-Bx_8GGd-.mjs} +1 -1
- package/dist/{utils-0HFFqmd4.js → utils-tM9yE73c.js} +1 -1
- package/dist/v18.cjs.js +1 -1
- package/dist/v18.es.js +1 -1
- package/dist/v19.cjs.js +1 -1
- package/dist/v19.es.js +1 -1
- package/package.json +21 -6
- package/src/index.ts +5 -0
- package/src/provider/versions/bridge-base.tsx +7 -2
- package/src/provider/versions/legacy.ts +2 -1
- package/src/remote/create.tsx +4 -1
- package/src/router/v7.tsx +75 -0
- package/vite.config.ts +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @module-federation/bridge-react
|
|
2
2
|
|
|
3
|
+
## 0.21.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @module-federation/sdk@0.21.1
|
|
8
|
+
- @module-federation/bridge-shared@0.21.1
|
|
9
|
+
|
|
10
|
+
## 0.21.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- d225658: feat: Add React Router v7 Support to Module Federation Bridge
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [d1e90a4]
|
|
19
|
+
- @module-federation/sdk@0.21.0
|
|
20
|
+
- @module-federation/bridge-shared@0.21.0
|
|
21
|
+
|
|
3
22
|
## 0.20.0
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const React = require("react");
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-DRSBaSu3.js");
|
|
4
4
|
const plugin = require("./plugin.cjs.js");
|
|
5
5
|
function _interopNamespaceDefault(e) {
|
|
6
6
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -156,7 +156,7 @@ function createBaseBridgeComponent({
|
|
|
156
156
|
...rootOptions
|
|
157
157
|
};
|
|
158
158
|
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(info)) || {};
|
|
159
|
-
const
|
|
159
|
+
const BridgeWrapper = ({ basename: basename2 }) => /* @__PURE__ */ React__namespace.createElement(
|
|
160
160
|
ErrorBoundary,
|
|
161
161
|
{
|
|
162
162
|
FallbackComponent: fallback
|
|
@@ -166,16 +166,18 @@ function createBaseBridgeComponent({
|
|
|
166
166
|
{
|
|
167
167
|
appInfo: {
|
|
168
168
|
moduleName,
|
|
169
|
-
basename,
|
|
169
|
+
basename: basename2,
|
|
170
170
|
memoryRoute
|
|
171
171
|
},
|
|
172
172
|
propsInfo: {
|
|
173
173
|
...propsInfo,
|
|
174
|
+
basename: basename2,
|
|
174
175
|
...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
)
|
|
178
179
|
);
|
|
180
|
+
const rootComponentWithErrorBoundary = /* @__PURE__ */ React__namespace.createElement(BridgeWrapper, { basename });
|
|
179
181
|
if (bridgeInfo.render) {
|
|
180
182
|
await Promise.resolve(
|
|
181
183
|
bridgeInfo.render(rootComponentWithErrorBoundary, dom)
|
|
@@ -201,7 +203,7 @@ function createBaseBridgeComponent({
|
|
|
201
203
|
if ("unmount" in root) {
|
|
202
204
|
root.unmount();
|
|
203
205
|
} else {
|
|
204
|
-
|
|
206
|
+
index.LoggerInstance.warn("Root does not have unmount method");
|
|
205
207
|
}
|
|
206
208
|
rootMap.delete(dom);
|
|
207
209
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Component, createElement, createContext } from "react";
|
|
3
|
-
import { L as LoggerInstance, R as RouterContext } from "./index-
|
|
3
|
+
import { L as LoggerInstance, R as RouterContext } from "./index-DyQNwY2M.mjs";
|
|
4
4
|
import { federationRuntime } from "./plugin.es.js";
|
|
5
5
|
const ErrorBoundaryContext = createContext(null);
|
|
6
6
|
const initialState = {
|
|
@@ -139,7 +139,7 @@ function createBaseBridgeComponent({
|
|
|
139
139
|
...rootOptions
|
|
140
140
|
};
|
|
141
141
|
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(info)) || {};
|
|
142
|
-
const
|
|
142
|
+
const BridgeWrapper = ({ basename: basename2 }) => /* @__PURE__ */ React.createElement(
|
|
143
143
|
ErrorBoundary,
|
|
144
144
|
{
|
|
145
145
|
FallbackComponent: fallback
|
|
@@ -149,16 +149,18 @@ function createBaseBridgeComponent({
|
|
|
149
149
|
{
|
|
150
150
|
appInfo: {
|
|
151
151
|
moduleName,
|
|
152
|
-
basename,
|
|
152
|
+
basename: basename2,
|
|
153
153
|
memoryRoute
|
|
154
154
|
},
|
|
155
155
|
propsInfo: {
|
|
156
156
|
...propsInfo,
|
|
157
|
+
basename: basename2,
|
|
157
158
|
...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
161
|
)
|
|
161
162
|
);
|
|
163
|
+
const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(BridgeWrapper, { basename });
|
|
162
164
|
if (bridgeInfo.render) {
|
|
163
165
|
await Promise.resolve(
|
|
164
166
|
bridgeInfo.render(rootComponentWithErrorBoundary, dom)
|
|
@@ -184,7 +186,7 @@ function createBaseBridgeComponent({
|
|
|
184
186
|
if ("unmount" in root) {
|
|
185
187
|
root.unmount();
|
|
186
188
|
} else {
|
|
187
|
-
|
|
189
|
+
LoggerInstance.warn("Root does not have unmount method");
|
|
188
190
|
}
|
|
189
191
|
rootMap.delete(dom);
|
|
190
192
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const lazyUtils = require("./utils-
|
|
3
|
-
const index_esm = require("./index.esm-
|
|
2
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
3
|
+
const index_esm = require("./index.esm-BWaKho-8.js");
|
|
4
4
|
function wrapSetTimeout(targetPromise, delay = 2e4, id) {
|
|
5
5
|
if (targetPromise && typeof targetPromise.then === "function") {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DATA_FETCH_QUERY, l as logger, g as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, f as fetchData, a as loadDataFetchModule } from "./utils-
|
|
2
|
-
import { M as MANIFEST_EXT, S as SEPARATOR } from "./index.esm-
|
|
1
|
+
import { D as DATA_FETCH_QUERY, l as logger, g as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, f as fetchData, a as loadDataFetchModule } from "./utils-Bx_8GGd-.mjs";
|
|
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") {
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const lazyUtils = require("./utils-
|
|
4
|
-
const prefetch = require("./prefetch-
|
|
3
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
4
|
+
const prefetch = require("./prefetch-CTmmXyx-.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, b, e, h, c, d, r } from "./utils-
|
|
3
|
-
import { d as dataFetchFunction } from "./prefetch-
|
|
4
|
-
import { i, p } from "./prefetch-
|
|
1
|
+
import { x as DATA_FETCH_FUNCTION } from "./utils-Bx_8GGd-.mjs";
|
|
2
|
+
import { C, b, e, h, c, d, r } from "./utils-Bx_8GGd-.mjs";
|
|
3
|
+
import { d as dataFetchFunction } from "./prefetch-D6cu5QUG.mjs";
|
|
4
|
+
import { i, p } from "./prefetch-D6cu5QUG.mjs";
|
|
5
5
|
async function callDataFetch() {
|
|
6
6
|
const dataFetch = globalThis[DATA_FETCH_FUNCTION];
|
|
7
7
|
if (dataFetch) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const React = require("react");
|
|
3
|
-
const index_esm = require("./index.esm-
|
|
3
|
+
const index_esm = require("./index.esm-BWaKho-8.js");
|
|
4
4
|
const RouterContext = React.createContext(null);
|
|
5
5
|
const LoggerInstance = index_esm.createLogger(
|
|
6
6
|
"[ Module Federation Bridge React ]"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import { c as createLogger } from "./index.esm-
|
|
2
|
+
import { c as createLogger } from "./index.esm-CPwSeCvw.mjs";
|
|
3
3
|
const RouterContext = React__default.createContext(null);
|
|
4
4
|
const LoggerInstance = createLogger(
|
|
5
5
|
"[ Module Federation Bridge React ]"
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const bridgeBase = require("./bridge-base-
|
|
3
|
+
const bridgeBase = require("./bridge-base-B2malZDo.js");
|
|
4
4
|
const ReactDOM = require("react-dom");
|
|
5
|
+
const index = require("./index-DRSBaSu3.js");
|
|
5
6
|
const React = require("react");
|
|
6
|
-
const index = require("./index-DqCpgmgH.js");
|
|
7
7
|
const ReactRouterDOM = require("react-router-dom");
|
|
8
8
|
const plugin = require("./plugin.cjs.js");
|
|
9
|
-
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-
|
|
10
|
-
const lazyUtils = require("./utils-
|
|
9
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-IOan5uEb.js");
|
|
10
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
11
11
|
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
12
|
-
const prefetch = require("./prefetch-
|
|
12
|
+
const prefetch = require("./prefetch-CTmmXyx-.js");
|
|
13
13
|
function _interopNamespaceDefault(e2) {
|
|
14
14
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
15
15
|
if (e2) {
|
|
@@ -39,7 +39,7 @@ function createReact16Or17Root(container) {
|
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
if (isReact18) {
|
|
42
|
-
|
|
42
|
+
index.LoggerInstance.warn(
|
|
43
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
44
|
);
|
|
45
45
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -134,7 +134,7 @@ export declare function generateKey(dataFetchOptions: DataFetchParams): string;
|
|
|
134
134
|
|
|
135
135
|
export declare function lazyLoadComponentPlugin(): ModuleFederationRuntimePlugin;
|
|
136
136
|
|
|
137
|
-
declare type LazyRemoteComponentInfo<T, _E extends keyof T> = RemoteComponentParams<T>;
|
|
137
|
+
export declare type LazyRemoteComponentInfo<T, _E extends keyof T> = RemoteComponentParams<T>;
|
|
138
138
|
|
|
139
139
|
export declare type NoSSRRemoteInfo = {
|
|
140
140
|
name: string;
|
|
@@ -193,7 +193,7 @@ declare type ReactKey = {
|
|
|
193
193
|
/**
|
|
194
194
|
* Parameters for the remote component loader
|
|
195
195
|
*/
|
|
196
|
-
declare interface RemoteComponentParams<T = Record<string, unknown>, E extends keyof T = keyof T> {
|
|
196
|
+
export declare interface RemoteComponentParams<T = Record<string, unknown>, E extends keyof T = keyof T> {
|
|
197
197
|
loader: () => Promise<T>;
|
|
198
198
|
loading: React_2.ReactNode;
|
|
199
199
|
fallback: React_2.ComponentType<{
|
|
@@ -206,7 +206,7 @@ declare interface RemoteComponentParams<T = Record<string, unknown>, E extends k
|
|
|
206
206
|
/**
|
|
207
207
|
* Parameters for the remote component
|
|
208
208
|
*/
|
|
209
|
-
declare interface RemoteComponentProps<T = Record<string, unknown>> {
|
|
209
|
+
export declare interface RemoteComponentProps<T = Record<string, unknown>> {
|
|
210
210
|
props?: T;
|
|
211
211
|
fallback?: React_2.ComponentType<{
|
|
212
212
|
error: Error;
|
|
@@ -215,6 +215,29 @@ declare interface RemoteComponentProps<T = Record<string, unknown>> {
|
|
|
215
215
|
[key: string]: unknown;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Interface for a remote module provider
|
|
220
|
+
*/
|
|
221
|
+
export declare interface RemoteModule {
|
|
222
|
+
provider: () => {
|
|
223
|
+
render: (info: RenderFnParams) => void;
|
|
224
|
+
destroy: (info: {
|
|
225
|
+
dom: any;
|
|
226
|
+
}) => void;
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Parameters for the render function, extending ProviderParams
|
|
232
|
+
*/
|
|
233
|
+
export declare interface RenderFnParams extends ProviderParams {
|
|
234
|
+
dom: HTMLElement;
|
|
235
|
+
fallback?: React_2.ComponentType<{
|
|
236
|
+
error: Error;
|
|
237
|
+
}>;
|
|
238
|
+
[key: string]: unknown;
|
|
239
|
+
}
|
|
240
|
+
|
|
218
241
|
/**
|
|
219
242
|
* Parameters for the render function
|
|
220
243
|
*/
|
package/dist/index.es.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-
|
|
1
|
+
import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-DRFFglgm.mjs";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
|
+
import { L as LoggerInstance, p as pathJoin, g as getRootDomDefaultClassName } from "./index-DyQNwY2M.mjs";
|
|
3
4
|
import React__default, { forwardRef, useContext, useState, useEffect, useRef } from "react";
|
|
4
|
-
import { p as pathJoin, L as LoggerInstance, g as getRootDomDefaultClassName } from "./index-Dm-M9ouh.mjs";
|
|
5
5
|
import * as ReactRouterDOM from "react-router-dom";
|
|
6
6
|
import { federationRuntime } from "./plugin.es.js";
|
|
7
|
-
import { b, a, c, l } from "./lazy-load-component-plugin-
|
|
8
|
-
import { C, b as b2, E, e, h, c as c2, d, r, s } from "./utils-
|
|
7
|
+
import { b, a, c, l } from "./lazy-load-component-plugin-ZkRCYTos.mjs";
|
|
8
|
+
import { C, b as b2, E, e, h, c as c2, d, r, s } from "./utils-Bx_8GGd-.mjs";
|
|
9
9
|
import { callDataFetch } from "./data-fetch-utils.es.js";
|
|
10
|
-
import { p } from "./prefetch-
|
|
10
|
+
import { p } from "./prefetch-D6cu5QUG.mjs";
|
|
11
11
|
function createReact16Or17Root(container) {
|
|
12
12
|
return {
|
|
13
13
|
render(children) {
|
|
@@ -20,7 +20,7 @@ function createReact16Or17Root(container) {
|
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
if (isReact18) {
|
|
23
|
-
|
|
23
|
+
LoggerInstance.warn(
|
|
24
24
|
`[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'`
|
|
25
25
|
);
|
|
26
26
|
}
|
|
@@ -44,6 +44,35 @@ const warn = (msg) => {
|
|
|
44
44
|
};
|
|
45
45
|
const PREFIX = "[ Module Federation ]";
|
|
46
46
|
const DEFAULT_DELEGATE = console;
|
|
47
|
+
const LOGGER_STACK_SKIP_TOKENS = [
|
|
48
|
+
"logger.ts",
|
|
49
|
+
"logger.js",
|
|
50
|
+
"captureStackTrace",
|
|
51
|
+
"Logger.emit",
|
|
52
|
+
"Logger.log",
|
|
53
|
+
"Logger.info",
|
|
54
|
+
"Logger.warn",
|
|
55
|
+
"Logger.error",
|
|
56
|
+
"Logger.debug"
|
|
57
|
+
];
|
|
58
|
+
function captureStackTrace() {
|
|
59
|
+
try {
|
|
60
|
+
const stack = new Error().stack;
|
|
61
|
+
if (!stack) {
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
const [, ...rawLines] = stack.split("\n");
|
|
65
|
+
const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));
|
|
66
|
+
if (!filtered.length) {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
const stackPreview = filtered.slice(0, 5).join("\n");
|
|
70
|
+
return `Stack trace:
|
|
71
|
+
${stackPreview}`;
|
|
72
|
+
} catch {
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
47
76
|
class Logger {
|
|
48
77
|
constructor(prefix, delegate = DEFAULT_DELEGATE) {
|
|
49
78
|
this.prefix = prefix;
|
|
@@ -57,6 +86,9 @@ class Logger {
|
|
|
57
86
|
}
|
|
58
87
|
emit(method, args) {
|
|
59
88
|
const delegate = this.delegate;
|
|
89
|
+
const debugMode = isDebugMode();
|
|
90
|
+
const stackTrace = debugMode ? captureStackTrace() : void 0;
|
|
91
|
+
const enrichedArgs = stackTrace ? [...args, stackTrace] : args;
|
|
60
92
|
const order = (() => {
|
|
61
93
|
switch (method) {
|
|
62
94
|
case "log":
|
|
@@ -75,14 +107,14 @@ class Logger {
|
|
|
75
107
|
for (const candidate of order) {
|
|
76
108
|
const handler = delegate[candidate];
|
|
77
109
|
if (typeof handler === "function") {
|
|
78
|
-
handler.call(delegate, this.prefix, ...
|
|
110
|
+
handler.call(delegate, this.prefix, ...enrichedArgs);
|
|
79
111
|
return;
|
|
80
112
|
}
|
|
81
113
|
}
|
|
82
114
|
for (const candidate of order) {
|
|
83
115
|
const handler = DEFAULT_DELEGATE[candidate];
|
|
84
116
|
if (typeof handler === "function") {
|
|
85
|
-
handler.call(DEFAULT_DELEGATE, this.prefix, ...
|
|
117
|
+
handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);
|
|
86
118
|
return;
|
|
87
119
|
}
|
|
88
120
|
}
|
|
@@ -43,6 +43,35 @@ const warn = (msg) => {
|
|
|
43
43
|
};
|
|
44
44
|
const PREFIX = "[ Module Federation ]";
|
|
45
45
|
const DEFAULT_DELEGATE = console;
|
|
46
|
+
const LOGGER_STACK_SKIP_TOKENS = [
|
|
47
|
+
"logger.ts",
|
|
48
|
+
"logger.js",
|
|
49
|
+
"captureStackTrace",
|
|
50
|
+
"Logger.emit",
|
|
51
|
+
"Logger.log",
|
|
52
|
+
"Logger.info",
|
|
53
|
+
"Logger.warn",
|
|
54
|
+
"Logger.error",
|
|
55
|
+
"Logger.debug"
|
|
56
|
+
];
|
|
57
|
+
function captureStackTrace() {
|
|
58
|
+
try {
|
|
59
|
+
const stack = new Error().stack;
|
|
60
|
+
if (!stack) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
const [, ...rawLines] = stack.split("\n");
|
|
64
|
+
const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));
|
|
65
|
+
if (!filtered.length) {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
const stackPreview = filtered.slice(0, 5).join("\n");
|
|
69
|
+
return `Stack trace:
|
|
70
|
+
${stackPreview}`;
|
|
71
|
+
} catch {
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
46
75
|
class Logger {
|
|
47
76
|
constructor(prefix, delegate = DEFAULT_DELEGATE) {
|
|
48
77
|
this.prefix = prefix;
|
|
@@ -56,6 +85,9 @@ class Logger {
|
|
|
56
85
|
}
|
|
57
86
|
emit(method, args) {
|
|
58
87
|
const delegate = this.delegate;
|
|
88
|
+
const debugMode = isDebugMode();
|
|
89
|
+
const stackTrace = debugMode ? captureStackTrace() : void 0;
|
|
90
|
+
const enrichedArgs = stackTrace ? [...args, stackTrace] : args;
|
|
59
91
|
const order = (() => {
|
|
60
92
|
switch (method) {
|
|
61
93
|
case "log":
|
|
@@ -74,14 +106,14 @@ class Logger {
|
|
|
74
106
|
for (const candidate of order) {
|
|
75
107
|
const handler = delegate[candidate];
|
|
76
108
|
if (typeof handler === "function") {
|
|
77
|
-
handler.call(delegate, this.prefix, ...
|
|
109
|
+
handler.call(delegate, this.prefix, ...enrichedArgs);
|
|
78
110
|
return;
|
|
79
111
|
}
|
|
80
112
|
}
|
|
81
113
|
for (const candidate of order) {
|
|
82
114
|
const handler = DEFAULT_DELEGATE[candidate];
|
|
83
115
|
if (typeof handler === "function") {
|
|
84
|
-
handler.call(DEFAULT_DELEGATE, this.prefix, ...
|
|
116
|
+
handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);
|
|
85
117
|
return;
|
|
86
118
|
}
|
|
87
119
|
}
|
package/dist/{lazy-load-component-plugin-C-qNUGjT.js → lazy-load-component-plugin-IOan5uEb.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const prefetch = require("./prefetch-
|
|
3
|
-
const lazyUtils = require("./utils-
|
|
2
|
+
const prefetch = require("./prefetch-CTmmXyx-.js");
|
|
3
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const autoFetchData = () => {
|
|
6
6
|
lazyUtils.initDataFetchMap();
|
package/dist/{lazy-load-component-plugin-Bcm5-gd8.mjs → lazy-load-component-plugin-ZkRCYTos.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as injectDataFetch, p as prefetch } from "./prefetch-
|
|
2
|
-
import { i as initDataFetchMap, j as isDataLoaderExpose, k as getDataFetchInfo, m as getDataFetchMapKey, l as logger, n as getDataFetchItem, o as DATA_FETCH_CLIENT_SUFFIX, p as MF_DATA_FETCH_TYPE, q as isCSROnly, a as loadDataFetchModule, M as MF_DATA_FETCH_STATUS, g as getDataFetchMap, t as isServerEnv, u as getDataFetchIdWithErrorMsgs, v as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, w as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, x as DATA_FETCH_FUNCTION, y as getLoadedRemoteInfos, f as fetchData$1, z as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-
|
|
1
|
+
import { i as injectDataFetch, p as prefetch } from "./prefetch-D6cu5QUG.mjs";
|
|
2
|
+
import { i as initDataFetchMap, j as isDataLoaderExpose, k as getDataFetchInfo, m as getDataFetchMapKey, l as logger, n as getDataFetchItem, o as DATA_FETCH_CLIENT_SUFFIX, p as MF_DATA_FETCH_TYPE, q as isCSROnly, a as loadDataFetchModule, M as MF_DATA_FETCH_STATUS, g as getDataFetchMap, t as isServerEnv, u as getDataFetchIdWithErrorMsgs, v as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, w as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, x as DATA_FETCH_FUNCTION, y as getLoadedRemoteInfos, f as fetchData$1, z as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-Bx_8GGd-.mjs";
|
|
3
3
|
import React__default, { useRef, useState, Suspense, useEffect } from "react";
|
|
4
4
|
const autoFetchData = () => {
|
|
5
5
|
initDataFetchMap();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-
|
|
4
|
-
require("./prefetch-
|
|
3
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-IOan5uEb.js");
|
|
4
|
+
require("./prefetch-CTmmXyx-.js");
|
|
5
5
|
exports.default = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
|
|
6
6
|
exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l, l as l2 } from "./lazy-load-component-plugin-
|
|
2
|
-
import "./prefetch-
|
|
1
|
+
import { l, l as l2 } from "./lazy-load-component-plugin-ZkRCYTos.mjs";
|
|
2
|
+
import "./prefetch-D6cu5QUG.mjs";
|
|
3
3
|
export {
|
|
4
4
|
l as default,
|
|
5
5
|
l2 as lazyLoadComponentPlugin
|
package/dist/lazy-utils.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
require("./index.esm-
|
|
4
|
-
const lazyUtils = require("./utils-
|
|
3
|
+
require("./index.esm-BWaKho-8.js");
|
|
4
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
5
5
|
exports.callAllDowngrade = lazyUtils.callAllDowngrade;
|
|
6
6
|
exports.callDowngrade = lazyUtils.callDowngrade;
|
|
7
7
|
exports.fetchData = lazyUtils.fetchData;
|
package/dist/lazy-utils.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./index.esm-
|
|
2
|
-
import { G, H, f, J, I, u, k, n, g, m, B, y, i, q, j, t, a, z, s, w } from "./utils-
|
|
1
|
+
import "./index.esm-CPwSeCvw.mjs";
|
|
2
|
+
import { G, H, f, J, I, u, k, n, g, m, B, y, i, q, j, t, a, z, s, w } from "./utils-Bx_8GGd-.mjs";
|
|
3
3
|
export {
|
|
4
4
|
G as callAllDowngrade,
|
|
5
5
|
H as callDowngrade,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const lazyUtils = require("./utils-
|
|
3
|
-
const index_esm = require("./index.esm-
|
|
2
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
3
|
+
const index_esm = require("./index.esm-BWaKho-8.js");
|
|
4
4
|
const dataFetchFunction = async function(options) {
|
|
5
5
|
var _a, _b;
|
|
6
6
|
const [id, data, downgrade] = options;
|
|
@@ -211,7 +211,7 @@ function getGlobalFederationConstructor() {
|
|
|
211
211
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = index_esm.isDebugMode()) {
|
|
212
212
|
if (isDebug) {
|
|
213
213
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
214
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
214
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.21.1";
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
function getInfoWithoutType(target, key) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { x as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger$1, g as getDataFetchMap, i as initDataFetchMap, n as getDataFetchItem, M as MF_DATA_FETCH_STATUS, p as MF_DATA_FETCH_TYPE, A as DOWNGRADE_KEY, B as getDowngradeTag, G as callAllDowngrade, H as callDowngrade, k as getDataFetchInfo, m as getDataFetchMapKey } from "./utils-
|
|
2
|
-
import { i as isDebugMode, a as createLink, b as createScript, d as isBrowserEnv, c as createLogger, e as composeKeyWithSeparator, l as loadScriptNode, f as loadScript } from "./index.esm-
|
|
1
|
+
import { x as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger$1, g as getDataFetchMap, i as initDataFetchMap, n as getDataFetchItem, M as MF_DATA_FETCH_STATUS, p as MF_DATA_FETCH_TYPE, A as DOWNGRADE_KEY, B as getDowngradeTag, G as callAllDowngrade, H as callDowngrade, k as getDataFetchInfo, m as getDataFetchMapKey } from "./utils-Bx_8GGd-.mjs";
|
|
2
|
+
import { i as isDebugMode, a as createLink, b as createScript, d as isBrowserEnv, c as createLogger, e as composeKeyWithSeparator, l as loadScriptNode, f as loadScript } from "./index.esm-CPwSeCvw.mjs";
|
|
3
3
|
const dataFetchFunction = async function(options) {
|
|
4
4
|
var _a, _b;
|
|
5
5
|
const [id, data, downgrade] = options;
|
|
@@ -210,7 +210,7 @@ function getGlobalFederationConstructor() {
|
|
|
210
210
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
211
211
|
if (isDebug) {
|
|
212
212
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
213
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
213
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.21.1";
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
function getInfoWithoutType(target, key) {
|
package/dist/router-v5.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const ReactRouterDom$1 = require("react-router-dom/index.js");
|
|
5
|
-
const index = require("./index-
|
|
5
|
+
const index = require("./index-DRSBaSu3.js");
|
|
6
6
|
const ReactRouterDom = require("react-router-dom/index.js");
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
package/dist/router-v5.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default, { useContext } from "react";
|
|
2
2
|
import * as ReactRouterDom$1 from "react-router-dom/index.js";
|
|
3
|
-
import { R as RouterContext, L as LoggerInstance } from "./index-
|
|
3
|
+
import { R as RouterContext, L as LoggerInstance } from "./index-DyQNwY2M.mjs";
|
|
4
4
|
export * from "react-router-dom/index.js";
|
|
5
5
|
function WraperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
package/dist/router-v6.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const ReactRouterDom$1 = require("react-router-dom/dist/index.js");
|
|
5
|
-
const index = require("./index-
|
|
5
|
+
const index = require("./index-DRSBaSu3.js");
|
|
6
6
|
const ReactRouterDom = require("react-router-dom/dist/index.js");
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
package/dist/router-v6.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default, { useContext } from "react";
|
|
2
2
|
import * as ReactRouterDom$1 from "react-router-dom/dist/index.js";
|
|
3
|
-
import { R as RouterContext, L as LoggerInstance } from "./index-
|
|
3
|
+
import { R as RouterContext, L as LoggerInstance } from "./index-DyQNwY2M.mjs";
|
|
4
4
|
export * from "react-router-dom/dist/index.js";
|
|
5
5
|
function WraperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const ReactRouterDom = require("react-router");
|
|
5
|
+
const index = require("./index-DRSBaSu3.js");
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
+
if (e) {
|
|
9
|
+
for (const k in e) {
|
|
10
|
+
if (k !== "default") {
|
|
11
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: () => e[k]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
const ReactRouterDom__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactRouterDom);
|
|
23
|
+
function WraperRouter(props) {
|
|
24
|
+
const { basename, ...propsRes } = props;
|
|
25
|
+
const routerContextProps = React.useContext(index.RouterContext) || {};
|
|
26
|
+
index.LoggerInstance.debug(`WraperRouter info >>>`, {
|
|
27
|
+
...routerContextProps,
|
|
28
|
+
routerContextProps,
|
|
29
|
+
WraperRouterProps: props
|
|
30
|
+
});
|
|
31
|
+
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
32
|
+
return /* @__PURE__ */ React.createElement(
|
|
33
|
+
ReactRouterDom__namespace.MemoryRouter,
|
|
34
|
+
{
|
|
35
|
+
...props,
|
|
36
|
+
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ React.createElement(
|
|
41
|
+
ReactRouterDom__namespace.BrowserRouter,
|
|
42
|
+
{
|
|
43
|
+
...propsRes,
|
|
44
|
+
basename: (routerContextProps == null ? void 0 : routerContextProps.basename) || basename
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
function WraperRouterProvider(props) {
|
|
49
|
+
const { router, ...propsRes } = props;
|
|
50
|
+
const routerContextProps = React.useContext(index.RouterContext) || {};
|
|
51
|
+
const routers = router.routes;
|
|
52
|
+
index.LoggerInstance.debug(`WraperRouterProvider info >>>`, {
|
|
53
|
+
...routerContextProps,
|
|
54
|
+
routerContextProps,
|
|
55
|
+
WraperRouterProviderProps: props,
|
|
56
|
+
router
|
|
57
|
+
});
|
|
58
|
+
const RouterProvider = ReactRouterDom__namespace["RouterProvider"];
|
|
59
|
+
const createMemoryRouter = ReactRouterDom__namespace["createMemoryRouter"];
|
|
60
|
+
const createBrowserRouter = ReactRouterDom__namespace["createBrowserRouter"];
|
|
61
|
+
if (routerContextProps.memoryRoute) {
|
|
62
|
+
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
63
|
+
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
64
|
+
});
|
|
65
|
+
return /* @__PURE__ */ React.createElement(RouterProvider, { router: MemeoryRouterInstance });
|
|
66
|
+
} else {
|
|
67
|
+
const BrowserRouterInstance = createBrowserRouter(routers, {
|
|
68
|
+
// In host app, the routerContextProps is {}, so we should use router.basename as fallback
|
|
69
|
+
basename: routerContextProps.basename || router.basename,
|
|
70
|
+
future: router.future,
|
|
71
|
+
window: router.window
|
|
72
|
+
});
|
|
73
|
+
return /* @__PURE__ */ React.createElement(RouterProvider, { ...propsRes, router: BrowserRouterInstance });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.BrowserRouter = WraperRouter;
|
|
77
|
+
exports.RouterProvider = WraperRouterProvider;
|
|
78
|
+
Object.keys(ReactRouterDom).forEach((k) => {
|
|
79
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: () => ReactRouterDom[k]
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import * as ReactRouterDom from 'react-router';
|
|
3
|
+
|
|
4
|
+
export declare function BrowserRouter(props: Parameters<typeof ReactRouterDom.BrowserRouter>[0] | Parameters<typeof ReactRouterDom.MemoryRouter>[0]): default_2.JSX.Element;
|
|
5
|
+
|
|
6
|
+
export declare function RouterProvider(props: Parameters<typeof ReactRouterDom.RouterProvider>[0]): default_2.JSX.Element;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export * from "react-router";
|
|
10
|
+
|
|
11
|
+
export { }
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
declare module '@module-federation/runtime-core' {
|
|
15
|
+
interface ModuleFederation {
|
|
16
|
+
createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
|
|
17
|
+
prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
|
|
18
|
+
collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React__default, { useContext } from "react";
|
|
2
|
+
import * as ReactRouterDom from 'react-router/dist/production/index.js';
|
|
3
|
+
export * from 'react-router/dist/production/index.js';
|
|
4
|
+
import { R as RouterContext, L as LoggerInstance } from "./index-DyQNwY2M.mjs";
|
|
5
|
+
function WraperRouter(props) {
|
|
6
|
+
const { basename, ...propsRes } = props;
|
|
7
|
+
const routerContextProps = useContext(RouterContext) || {};
|
|
8
|
+
LoggerInstance.debug(`WraperRouter info >>>`, {
|
|
9
|
+
...routerContextProps,
|
|
10
|
+
routerContextProps,
|
|
11
|
+
WraperRouterProps: props
|
|
12
|
+
});
|
|
13
|
+
if (routerContextProps == null ? void 0 : routerContextProps.memoryRoute) {
|
|
14
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
15
|
+
ReactRouterDom.MemoryRouter,
|
|
16
|
+
{
|
|
17
|
+
...props,
|
|
18
|
+
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
23
|
+
ReactRouterDom.BrowserRouter,
|
|
24
|
+
{
|
|
25
|
+
...propsRes,
|
|
26
|
+
basename: (routerContextProps == null ? void 0 : routerContextProps.basename) || basename
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
function WraperRouterProvider(props) {
|
|
31
|
+
const { router, ...propsRes } = props;
|
|
32
|
+
const routerContextProps = useContext(RouterContext) || {};
|
|
33
|
+
const routers = router.routes;
|
|
34
|
+
LoggerInstance.debug(`WraperRouterProvider info >>>`, {
|
|
35
|
+
...routerContextProps,
|
|
36
|
+
routerContextProps,
|
|
37
|
+
WraperRouterProviderProps: props,
|
|
38
|
+
router
|
|
39
|
+
});
|
|
40
|
+
const RouterProvider = ReactRouterDom["RouterProvider"];
|
|
41
|
+
const createMemoryRouter = ReactRouterDom["createMemoryRouter"];
|
|
42
|
+
const createBrowserRouter = ReactRouterDom["createBrowserRouter"];
|
|
43
|
+
if (routerContextProps.memoryRoute) {
|
|
44
|
+
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
45
|
+
initialEntries: [routerContextProps == null ? void 0 : routerContextProps.memoryRoute.entryPath]
|
|
46
|
+
});
|
|
47
|
+
return /* @__PURE__ */ React__default.createElement(RouterProvider, { router: MemeoryRouterInstance });
|
|
48
|
+
} else {
|
|
49
|
+
const BrowserRouterInstance = createBrowserRouter(routers, {
|
|
50
|
+
// In host app, the routerContextProps is {}, so we should use router.basename as fallback
|
|
51
|
+
basename: routerContextProps.basename || router.basename,
|
|
52
|
+
future: router.future,
|
|
53
|
+
window: router.window
|
|
54
|
+
});
|
|
55
|
+
return /* @__PURE__ */ React__default.createElement(RouterProvider, { ...propsRes, router: BrowserRouterInstance });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
WraperRouter as BrowserRouter,
|
|
60
|
+
WraperRouterProvider as RouterProvider
|
|
61
|
+
};
|
package/dist/router.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const ReactRouterDom = require("react-router-dom/");
|
|
5
|
-
const index = require("./index-
|
|
5
|
+
const index = require("./index-DRSBaSu3.js");
|
|
6
6
|
function _interopNamespaceDefault(e) {
|
|
7
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
8
|
if (e) {
|
package/dist/router.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React__default, { useContext } from "react";
|
|
2
2
|
import * as ReactRouterDom from "react-router-dom/";
|
|
3
3
|
export * from "react-router-dom/";
|
|
4
|
-
import { R as RouterContext, L as LoggerInstance } from "./index-
|
|
4
|
+
import { R as RouterContext, L as LoggerInstance } from "./index-DyQNwY2M.mjs";
|
|
5
5
|
function WrapperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
|
7
7
|
const routerContextProps = useContext(RouterContext) || {};
|
|
@@ -18,7 +18,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
var _a, _constructing, _b, _c, _max, _maxSize, _dispose, _disposeAfter, _fetchMethod, _memoMethod, _size, _calculatedSize, _keyMap, _keyList, _valList, _next, _prev, _head, _tail, _free, _disposed, _sizes, _starts, _ttls, _hasDispose, _hasFetchMethod, _hasDisposeAfter, _LRUCache_instances, initializeTTLTracking_fn, _updateItemAge, _statusTTL, _setItemTTL, _isStale, initializeSizeTracking_fn, _removeItemSize, _addItemSize, _requireSize, indexes_fn, rindexes_fn, isValidIndex_fn, evict_fn, backgroundFetch_fn, isBackgroundFetch_fn, connect_fn, moveToTail_fn, delete_fn, clear_fn;
|
|
21
|
-
import { c as createLogger, d as isBrowserEnv, e as composeKeyWithSeparator } from "./index.esm-
|
|
21
|
+
import { c as createLogger, d as isBrowserEnv, e as composeKeyWithSeparator } from "./index.esm-CPwSeCvw.mjs";
|
|
22
22
|
const PLUGIN_IDENTIFIER = "[ Module Federation React ]";
|
|
23
23
|
const DOWNGRADE_KEY = "_mfSSRDowngrade";
|
|
24
24
|
const DATA_FETCH_FUNCTION = "_mfDataFetch";
|
|
@@ -19,7 +19,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
var _a, _constructing, _b, _c, _max, _maxSize, _dispose, _disposeAfter, _fetchMethod, _memoMethod, _size, _calculatedSize, _keyMap, _keyList, _valList, _next, _prev, _head, _tail, _free, _disposed, _sizes, _starts, _ttls, _hasDispose, _hasFetchMethod, _hasDisposeAfter, _LRUCache_instances, initializeTTLTracking_fn, _updateItemAge, _statusTTL, _setItemTTL, _isStale, initializeSizeTracking_fn, _removeItemSize, _addItemSize, _requireSize, indexes_fn, rindexes_fn, isValidIndex_fn, evict_fn, backgroundFetch_fn, isBackgroundFetch_fn, connect_fn, moveToTail_fn, delete_fn, clear_fn;
|
|
22
|
-
const index_esm = require("./index.esm-
|
|
22
|
+
const index_esm = require("./index.esm-BWaKho-8.js");
|
|
23
23
|
const PLUGIN_IDENTIFIER = "[ Module Federation React ]";
|
|
24
24
|
const DOWNGRADE_KEY = "_mfSSRDowngrade";
|
|
25
25
|
const DATA_FETCH_FUNCTION = "_mfDataFetch";
|
package/dist/v18.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const client = require("react-dom/client");
|
|
4
|
-
const bridgeBase = require("./bridge-base-
|
|
4
|
+
const bridgeBase = require("./bridge-base-B2malZDo.js");
|
|
5
5
|
function createReact18Root(container, options) {
|
|
6
6
|
return client.createRoot(container, options);
|
|
7
7
|
}
|
package/dist/v18.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRoot } from "react-dom/client";
|
|
2
|
-
import { c as createBaseBridgeComponent } from "./bridge-base-
|
|
2
|
+
import { c as createBaseBridgeComponent } from "./bridge-base-DRFFglgm.mjs";
|
|
3
3
|
function createReact18Root(container, options) {
|
|
4
4
|
return createRoot(container, options);
|
|
5
5
|
}
|
package/dist/v19.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const client = require("react-dom/client");
|
|
4
|
-
const bridgeBase = require("./bridge-base-
|
|
4
|
+
const bridgeBase = require("./bridge-base-B2malZDo.js");
|
|
5
5
|
function createReact19Root(container, options) {
|
|
6
6
|
return client.createRoot(container, options);
|
|
7
7
|
}
|
package/dist/v19.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRoot } from "react-dom/client";
|
|
2
|
-
import { c as createBaseBridgeComponent } from "./bridge-base-
|
|
2
|
+
import { c as createBaseBridgeComponent } from "./bridge-base-DRFFglgm.mjs";
|
|
3
3
|
function createReact19Root(container, options) {
|
|
4
4
|
return createRoot(container, options);
|
|
5
5
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/bridge-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -51,6 +51,11 @@
|
|
|
51
51
|
"import": "./dist/router-v6.es.js",
|
|
52
52
|
"require": "./dist/router-v6.cjs.js"
|
|
53
53
|
},
|
|
54
|
+
"./router-v7": {
|
|
55
|
+
"types": "./dist/router-v7.d.ts",
|
|
56
|
+
"import": "./dist/router-v7.es.js",
|
|
57
|
+
"require": "./dist/router-v7.cjs.js"
|
|
58
|
+
},
|
|
54
59
|
"./lazy-utils": {
|
|
55
60
|
"types": "./dist/lazy-utils.d.ts",
|
|
56
61
|
"import": "./dist/lazy-utils.es.js",
|
|
@@ -95,13 +100,22 @@
|
|
|
95
100
|
"dependencies": {
|
|
96
101
|
"react-error-boundary": "^4.1.2",
|
|
97
102
|
"lru-cache": "^10.4.3",
|
|
98
|
-
"@module-federation/sdk": "0.
|
|
99
|
-
"@module-federation/bridge-shared": "0.
|
|
103
|
+
"@module-federation/sdk": "0.21.1",
|
|
104
|
+
"@module-federation/bridge-shared": "0.21.1"
|
|
100
105
|
},
|
|
101
106
|
"peerDependencies": {
|
|
102
107
|
"react": ">=16.9.0",
|
|
103
108
|
"react-dom": ">=16.9.0",
|
|
104
|
-
"react-router-dom": "^4 || ^5 || ^6 || ^7"
|
|
109
|
+
"react-router-dom": "^4 || ^5 || ^6 || ^7",
|
|
110
|
+
"react-router": "^7"
|
|
111
|
+
},
|
|
112
|
+
"peerDependenciesMeta": {
|
|
113
|
+
"react-router-dom": {
|
|
114
|
+
"optional": true
|
|
115
|
+
},
|
|
116
|
+
"react-router": {
|
|
117
|
+
"optional": true
|
|
118
|
+
}
|
|
105
119
|
},
|
|
106
120
|
"devDependencies": {
|
|
107
121
|
"@testing-library/react": "15.0.7",
|
|
@@ -114,12 +128,13 @@
|
|
|
114
128
|
"react": "18.3.1",
|
|
115
129
|
"react-dom": "18.3.1",
|
|
116
130
|
"react-router-dom": "6.22.3",
|
|
131
|
+
"react-router": "7.9.4",
|
|
117
132
|
"typescript": "^5.2.2",
|
|
118
133
|
"vite": "^5.4.20",
|
|
119
134
|
"vite-plugin-dts": "^4.3.0",
|
|
120
135
|
"hono": "3.12.12",
|
|
121
|
-
"@module-federation/runtime": "0.
|
|
122
|
-
"@module-federation/runtime
|
|
136
|
+
"@module-federation/runtime-core": "0.21.1",
|
|
137
|
+
"@module-federation/runtime": "0.21.1"
|
|
123
138
|
},
|
|
124
139
|
"scripts": {
|
|
125
140
|
"dev": "vite",
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export {
|
|
|
7
7
|
createRemoteComponent,
|
|
8
8
|
createRemoteAppComponent,
|
|
9
9
|
} from './remote/create';
|
|
10
|
+
export type { LazyRemoteComponentInfo } from './remote/create';
|
|
10
11
|
export {
|
|
11
12
|
ERROR_TYPE,
|
|
12
13
|
createLazyComponent,
|
|
@@ -34,6 +35,10 @@ export type {
|
|
|
34
35
|
RootType,
|
|
35
36
|
DestroyParams,
|
|
36
37
|
RenderParams,
|
|
38
|
+
RemoteComponentParams,
|
|
39
|
+
RenderFnParams,
|
|
40
|
+
RemoteComponentProps,
|
|
41
|
+
RemoteModule,
|
|
37
42
|
} from './types';
|
|
38
43
|
export type {
|
|
39
44
|
DataFetchParams,
|
|
@@ -64,7 +64,7 @@ export function createBaseBridgeComponent<T>({
|
|
|
64
64
|
const beforeBridgeRenderRes =
|
|
65
65
|
instance?.bridgeHook?.lifecycle?.beforeBridgeRender?.emit(info) || {};
|
|
66
66
|
|
|
67
|
-
const
|
|
67
|
+
const BridgeWrapper = ({ basename }: { basename?: string }) => (
|
|
68
68
|
<ErrorBoundary
|
|
69
69
|
FallbackComponent={fallback as React.ComponentType<FallbackProps>}
|
|
70
70
|
>
|
|
@@ -77,6 +77,7 @@ export function createBaseBridgeComponent<T>({
|
|
|
77
77
|
propsInfo={
|
|
78
78
|
{
|
|
79
79
|
...propsInfo,
|
|
80
|
+
basename,
|
|
80
81
|
...(beforeBridgeRenderRes as any)?.extraProps,
|
|
81
82
|
} as T
|
|
82
83
|
}
|
|
@@ -84,6 +85,10 @@ export function createBaseBridgeComponent<T>({
|
|
|
84
85
|
</ErrorBoundary>
|
|
85
86
|
);
|
|
86
87
|
|
|
88
|
+
const rootComponentWithErrorBoundary = (
|
|
89
|
+
<BridgeWrapper basename={basename} />
|
|
90
|
+
);
|
|
91
|
+
|
|
87
92
|
if (bridgeInfo.render) {
|
|
88
93
|
await Promise.resolve(
|
|
89
94
|
bridgeInfo.render(rootComponentWithErrorBoundary, dom),
|
|
@@ -111,7 +116,7 @@ export function createBaseBridgeComponent<T>({
|
|
|
111
116
|
if ('unmount' in root) {
|
|
112
117
|
root.unmount();
|
|
113
118
|
} else {
|
|
114
|
-
|
|
119
|
+
LoggerInstance.warn('Root does not have unmount method');
|
|
115
120
|
}
|
|
116
121
|
rootMap.delete(dom);
|
|
117
122
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import type { ProviderFnParams } from '../../types';
|
|
6
6
|
import { createBaseBridgeComponent } from './bridge-base';
|
|
7
7
|
import ReactDOM from 'react-dom';
|
|
8
|
+
import { LoggerInstance } from '../../utils';
|
|
8
9
|
|
|
9
10
|
export interface CreateRootOptions {
|
|
10
11
|
identifierPrefix?: string;
|
|
@@ -58,7 +59,7 @@ export function createReact16Or17Root(
|
|
|
58
59
|
* Provide warning for React 18
|
|
59
60
|
*/
|
|
60
61
|
if (isReact18) {
|
|
61
|
-
|
|
62
|
+
LoggerInstance.warn(
|
|
62
63
|
`[Bridge-React] React 18 detected in legacy mode. ` +
|
|
63
64
|
`For better compatibility, please use the version-specific import: ` +
|
|
64
65
|
`import { createBridgeComponent } from '@module-federation/bridge-react/v18'`,
|
package/src/remote/create.tsx
CHANGED
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
RemoteModule,
|
|
9
9
|
} from '../types';
|
|
10
10
|
|
|
11
|
-
type LazyRemoteComponentInfo<
|
|
11
|
+
export type LazyRemoteComponentInfo<
|
|
12
|
+
T,
|
|
13
|
+
_E extends keyof T,
|
|
14
|
+
> = RemoteComponentParams<T>;
|
|
12
15
|
|
|
13
16
|
function createLazyRemoteComponent<
|
|
14
17
|
T = Record<string, unknown>,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
// The upper alias react-router$ into this file avoids the loop
|
|
3
|
+
// React Router v7 uses different dist structure, we'll import from the main entry
|
|
4
|
+
import * as ReactRouterDom from 'react-router';
|
|
5
|
+
import { RouterContext } from '../provider/context';
|
|
6
|
+
import { LoggerInstance } from '../utils';
|
|
7
|
+
|
|
8
|
+
function WraperRouter(
|
|
9
|
+
props:
|
|
10
|
+
| Parameters<typeof ReactRouterDom.BrowserRouter>[0]
|
|
11
|
+
| Parameters<typeof ReactRouterDom.MemoryRouter>[0],
|
|
12
|
+
) {
|
|
13
|
+
const { basename, ...propsRes } = props;
|
|
14
|
+
const routerContextProps = useContext(RouterContext) || {};
|
|
15
|
+
|
|
16
|
+
LoggerInstance.debug(`WraperRouter info >>>`, {
|
|
17
|
+
...routerContextProps,
|
|
18
|
+
routerContextProps,
|
|
19
|
+
WraperRouterProps: props,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
if (routerContextProps?.memoryRoute) {
|
|
23
|
+
return (
|
|
24
|
+
<ReactRouterDom.MemoryRouter
|
|
25
|
+
{...props}
|
|
26
|
+
initialEntries={[routerContextProps?.memoryRoute.entryPath]}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return (
|
|
31
|
+
<ReactRouterDom.BrowserRouter
|
|
32
|
+
{...propsRes}
|
|
33
|
+
basename={routerContextProps?.basename || basename}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function WraperRouterProvider(
|
|
39
|
+
props: Parameters<typeof ReactRouterDom.RouterProvider>[0],
|
|
40
|
+
) {
|
|
41
|
+
const { router, ...propsRes } = props;
|
|
42
|
+
const routerContextProps = useContext(RouterContext) || {};
|
|
43
|
+
const routers = router.routes;
|
|
44
|
+
LoggerInstance.debug(`WraperRouterProvider info >>>`, {
|
|
45
|
+
...routerContextProps,
|
|
46
|
+
routerContextProps,
|
|
47
|
+
WraperRouterProviderProps: props,
|
|
48
|
+
router,
|
|
49
|
+
});
|
|
50
|
+
const RouterProvider = (ReactRouterDom as any)['Router' + 'Provider'];
|
|
51
|
+
const createMemoryRouter = (ReactRouterDom as any)['create' + 'MemoryRouter'];
|
|
52
|
+
const createBrowserRouter = (ReactRouterDom as any)[
|
|
53
|
+
'create' + 'BrowserRouter'
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
if (routerContextProps.memoryRoute) {
|
|
57
|
+
const MemeoryRouterInstance = createMemoryRouter(routers, {
|
|
58
|
+
initialEntries: [routerContextProps?.memoryRoute.entryPath],
|
|
59
|
+
});
|
|
60
|
+
return <RouterProvider router={MemeoryRouterInstance} />;
|
|
61
|
+
} else {
|
|
62
|
+
const BrowserRouterInstance = createBrowserRouter(routers, {
|
|
63
|
+
// In host app, the routerContextProps is {}, so we should use router.basename as fallback
|
|
64
|
+
basename: routerContextProps.basename || router.basename,
|
|
65
|
+
future: router.future,
|
|
66
|
+
window: router.window,
|
|
67
|
+
});
|
|
68
|
+
return <RouterProvider {...propsRes} router={BrowserRouterInstance} />;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Export all from react-router for v7 compatibility
|
|
73
|
+
export * from 'react-router';
|
|
74
|
+
export { WraperRouter as BrowserRouter };
|
|
75
|
+
export { WraperRouterProvider as RouterProvider };
|
package/vite.config.ts
CHANGED
|
@@ -24,6 +24,7 @@ export default defineConfig({
|
|
|
24
24
|
router: path.resolve(__dirname, 'src/router/default.tsx'),
|
|
25
25
|
'router-v5': path.resolve(__dirname, 'src/router/v5.tsx'),
|
|
26
26
|
'router-v6': path.resolve(__dirname, 'src/router/v6.tsx'),
|
|
27
|
+
'router-v7': path.resolve(__dirname, 'src/router/v7.tsx'),
|
|
27
28
|
v18: path.resolve(__dirname, 'src/v18.ts'),
|
|
28
29
|
v19: path.resolve(__dirname, 'src/v19.ts'),
|
|
29
30
|
'lazy-load-component-plugin': path.resolve(
|
|
@@ -49,6 +50,12 @@ export default defineConfig({
|
|
|
49
50
|
'@remix-run/router',
|
|
50
51
|
/react-dom\/.*/,
|
|
51
52
|
'react-router',
|
|
53
|
+
'react-router/',
|
|
54
|
+
'react-router/index.js',
|
|
55
|
+
'react-router/dist/index.js',
|
|
56
|
+
'react-router/dist/development/index.js',
|
|
57
|
+
'react-router/dist/production/index.js',
|
|
58
|
+
/^react-router\/.*/,
|
|
52
59
|
'react-router-dom/',
|
|
53
60
|
'react-router-dom/index.js',
|
|
54
61
|
'react-router-dom/dist/index.js',
|
|
@@ -67,6 +74,23 @@ export default defineConfig({
|
|
|
67
74
|
);
|
|
68
75
|
}
|
|
69
76
|
|
|
77
|
+
if (fileName.includes('router-v7') && chunk.type === 'chunk') {
|
|
78
|
+
// Replace 'react-router' with the correct v7 dist path based on environment
|
|
79
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
80
|
+
const distPath = isProduction
|
|
81
|
+
? 'react-router/dist/production/index.js'
|
|
82
|
+
: 'react-router/dist/development/index.js';
|
|
83
|
+
|
|
84
|
+
chunk.code = chunk.code.replace(
|
|
85
|
+
/from\s+['"`]react-router['"`]/g,
|
|
86
|
+
`from '${distPath}'`,
|
|
87
|
+
);
|
|
88
|
+
chunk.code = chunk.code.replace(
|
|
89
|
+
/export\s+\*\s+from\s+['"`]react-router['"`]/g,
|
|
90
|
+
`export * from '${distPath}'`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
70
94
|
if (fileName.includes('router-v5') && chunk.type === 'chunk') {
|
|
71
95
|
chunk.code = chunk.code.replace(
|
|
72
96
|
// Match 'react-router-dom/' followed by single quotes, double quotes, or backticks, replacing only 'react-router-dom/' to react-router-v5 dist file structure
|