@module-federation/bridge-react 0.0.0-next-20250618090118 → 0.0.0-next-20250620084158
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 +3 -8
- package/__tests__/bridge.spec.tsx +7 -7
- package/dist/{bridge-base-DKPEvcPJ.js → bridge-base-BBH982Tz.cjs} +1 -1
- package/dist/{bridge-base-YDjQh_vg.mjs → bridge-base-P6pEjY1q.js} +1 -1
- package/dist/{index.esm-BjwhLgko.js → index-Cv3p6r66.cjs} +43 -21
- package/dist/{index.esm-nDSYG6Nj.mjs → index-D4yt7Udv.js} +43 -21
- package/dist/index.cjs.js +9 -427
- package/dist/index.d.ts +0 -77
- package/dist/index.es.js +11 -430
- 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.cjs.js +1 -1
- package/dist/router.es.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 +5 -44
- package/src/index.ts +1 -21
- package/src/remote/component.tsx +3 -3
- package/src/remote/create.tsx +4 -17
- package/vite.config.ts +0 -13
- package/dist/data-fetch-runtime-plugin.cjs.js +0 -71
- package/dist/data-fetch-runtime-plugin.d.ts +0 -6
- package/dist/data-fetch-runtime-plugin.es.js +0 -72
- package/dist/data-fetch-server-middleware.cjs.js +0 -158
- package/dist/data-fetch-server-middleware.d.ts +0 -6
- package/dist/data-fetch-server-middleware.es.js +0 -159
- package/dist/data-fetch-utils.cjs.js +0 -90
- package/dist/data-fetch-utils.d.ts +0 -5
- package/dist/data-fetch-utils.es.js +0 -90
- package/dist/index-BYOQ_Qrb.js +0 -45
- package/dist/index-CUrEc0Q1.mjs +0 -46
- package/dist/lazy-utils.cjs.js +0 -22
- package/dist/lazy-utils.d.ts +0 -114
- package/dist/lazy-utils.es.js +0 -22
- package/dist/utils-DhtukXOQ.mjs +0 -327
- package/dist/utils-YoyAVYsh.js +0 -326
- package/src/lazy/AwaitDataFetch.tsx +0 -176
- package/src/lazy/constant.ts +0 -30
- package/src/lazy/createLazyComponent.tsx +0 -390
- package/src/lazy/data-fetch/call-data-fetch.ts +0 -13
- package/src/lazy/data-fetch/data-fetch-server-middleware.ts +0 -191
- package/src/lazy/data-fetch/index.ts +0 -2
- package/src/lazy/data-fetch/inject-data-fetch.ts +0 -109
- package/src/lazy/data-fetch/runtime-plugin.ts +0 -113
- package/src/lazy/index.ts +0 -18
- package/src/lazy/logger.ts +0 -6
- package/src/lazy/types.ts +0 -49
- package/src/lazy/utils.ts +0 -355
- package/src/lazy/wrapNoSSR.tsx +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
# @module-federation/bridge-react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- eb0d1dc: refactor(bridge-react): rename createRemoteComponent as createRemoteAppComponent
|
|
3
|
+
## 0.0.0-next-20250620084158
|
|
8
4
|
|
|
9
5
|
### Patch Changes
|
|
10
6
|
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
- @module-federation/bridge-shared@0.0.0-next-20250618090118
|
|
7
|
+
- @module-federation/sdk@0.0.0-next-20250620084158
|
|
8
|
+
- @module-federation/bridge-shared@0.0.0-next-20250620084158
|
|
14
9
|
|
|
15
10
|
## 0.15.0
|
|
16
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { assert, describe, it } from 'vitest';
|
|
3
|
-
import { createBridgeComponent,
|
|
3
|
+
import { createBridgeComponent, createRemoteComponent } from '../src';
|
|
4
4
|
import {
|
|
5
5
|
act,
|
|
6
6
|
fireEvent,
|
|
@@ -44,14 +44,14 @@ describe('bridge', () => {
|
|
|
44
44
|
expect(document.querySelector('#container')!.innerHTML).toContain('');
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
it('
|
|
47
|
+
it('createRemoteComponent', async () => {
|
|
48
48
|
function Component({ props }: { props?: Record<string, any> }) {
|
|
49
49
|
return <div>life cycle render {props?.msg}</div>;
|
|
50
50
|
}
|
|
51
51
|
const BridgeComponent = createBridgeComponent({
|
|
52
52
|
rootComponent: Component,
|
|
53
53
|
});
|
|
54
|
-
const RemoteComponent =
|
|
54
|
+
const RemoteComponent = createRemoteComponent({
|
|
55
55
|
loader: async () => {
|
|
56
56
|
return {
|
|
57
57
|
default: BridgeComponent,
|
|
@@ -71,7 +71,7 @@ describe('bridge', () => {
|
|
|
71
71
|
expect(getHtml(container)).toMatch('hello world');
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
it('
|
|
74
|
+
it('createRemoteComponent and obtain ref property', async () => {
|
|
75
75
|
const ref = {
|
|
76
76
|
current: null,
|
|
77
77
|
};
|
|
@@ -82,7 +82,7 @@ describe('bridge', () => {
|
|
|
82
82
|
const BridgeComponent = createBridgeComponent({
|
|
83
83
|
rootComponent: Component,
|
|
84
84
|
});
|
|
85
|
-
const RemoteComponent =
|
|
85
|
+
const RemoteComponent = createRemoteComponent({
|
|
86
86
|
loader: async () => {
|
|
87
87
|
return {
|
|
88
88
|
default: BridgeComponent,
|
|
@@ -103,7 +103,7 @@ describe('bridge', () => {
|
|
|
103
103
|
expect(ref.current).not.toBeNull();
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
it('
|
|
106
|
+
it('createRemoteComponent with custom createRoot prop', async () => {
|
|
107
107
|
const renderMock = vi.fn();
|
|
108
108
|
|
|
109
109
|
function Component({ props }: { props?: Record<string, any> }) {
|
|
@@ -118,7 +118,7 @@ describe('bridge', () => {
|
|
|
118
118
|
};
|
|
119
119
|
},
|
|
120
120
|
});
|
|
121
|
-
const RemoteComponent =
|
|
121
|
+
const RemoteComponent = createRemoteComponent({
|
|
122
122
|
loader: async () => {
|
|
123
123
|
return {
|
|
124
124
|
default: BridgeComponent,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const React = require("react");
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-Cv3p6r66.cjs");
|
|
4
4
|
const plugin = require("./plugin.cjs.js");
|
|
5
5
|
function _interopNamespaceDefault(e) {
|
|
6
6
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -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-D4yt7Udv.js";
|
|
4
4
|
import { federationRuntime } from "./plugin.es.js";
|
|
5
5
|
const ErrorBoundaryContext = createContext(null);
|
|
6
6
|
const initialState = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
2
|
+
const React = require("react");
|
|
3
|
+
const RouterContext = React.createContext(null);
|
|
3
4
|
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
4
|
-
const SEPARATOR = ":";
|
|
5
5
|
function isBrowserEnv() {
|
|
6
6
|
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
7
7
|
}
|
|
@@ -24,20 +24,6 @@ function isDebugMode() {
|
|
|
24
24
|
}
|
|
25
25
|
return isBrowserDebug();
|
|
26
26
|
}
|
|
27
|
-
const composeKeyWithSeparator = function(...args) {
|
|
28
|
-
if (!args.length) {
|
|
29
|
-
return "";
|
|
30
|
-
}
|
|
31
|
-
return args.reduce((sum, cur) => {
|
|
32
|
-
if (!cur) {
|
|
33
|
-
return sum;
|
|
34
|
-
}
|
|
35
|
-
if (!sum) {
|
|
36
|
-
return cur;
|
|
37
|
-
}
|
|
38
|
-
return `${sum}${SEPARATOR}${cur}`;
|
|
39
|
-
}, "");
|
|
40
|
-
};
|
|
41
27
|
let Logger = class Logger2 {
|
|
42
28
|
setPrefix(prefix) {
|
|
43
29
|
this.prefix = prefix;
|
|
@@ -206,8 +192,44 @@ async function loadModule(url2, options) {
|
|
|
206
192
|
});
|
|
207
193
|
return module2;
|
|
208
194
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
195
|
+
const LoggerInstance = createLogger(
|
|
196
|
+
"[ Module Federation Bridge React ]"
|
|
197
|
+
);
|
|
198
|
+
function pathJoin(...args) {
|
|
199
|
+
const res2 = args.reduce((res22, path2) => {
|
|
200
|
+
let nPath = path2;
|
|
201
|
+
if (!nPath || typeof nPath !== "string") {
|
|
202
|
+
return res22;
|
|
203
|
+
}
|
|
204
|
+
if (nPath[0] !== "/") {
|
|
205
|
+
nPath = `/${nPath}`;
|
|
206
|
+
}
|
|
207
|
+
const lastIndex = nPath.length - 1;
|
|
208
|
+
if (nPath[lastIndex] === "/") {
|
|
209
|
+
nPath = nPath.substring(0, lastIndex);
|
|
210
|
+
}
|
|
211
|
+
return res22 + nPath;
|
|
212
|
+
}, "");
|
|
213
|
+
return res2 || "/";
|
|
214
|
+
}
|
|
215
|
+
const getModuleName = (id) => {
|
|
216
|
+
if (!id) {
|
|
217
|
+
return id;
|
|
218
|
+
}
|
|
219
|
+
const idArray = id.split("/");
|
|
220
|
+
if (idArray.length < 2) {
|
|
221
|
+
return id;
|
|
222
|
+
}
|
|
223
|
+
return idArray[0] + "/" + idArray[1];
|
|
224
|
+
};
|
|
225
|
+
const getRootDomDefaultClassName = (moduleName) => {
|
|
226
|
+
if (!moduleName) {
|
|
227
|
+
return "";
|
|
228
|
+
}
|
|
229
|
+
const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
|
|
230
|
+
return `bridge-root-component-${name}`;
|
|
231
|
+
};
|
|
232
|
+
exports.LoggerInstance = LoggerInstance;
|
|
233
|
+
exports.RouterContext = RouterContext;
|
|
234
|
+
exports.getRootDomDefaultClassName = getRootDomDefaultClassName;
|
|
235
|
+
exports.pathJoin = pathJoin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
const RouterContext = React__default.createContext(null);
|
|
2
3
|
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
3
|
-
const SEPARATOR = ":";
|
|
4
4
|
function isBrowserEnv() {
|
|
5
5
|
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
6
6
|
}
|
|
@@ -23,20 +23,6 @@ function isDebugMode() {
|
|
|
23
23
|
}
|
|
24
24
|
return isBrowserDebug();
|
|
25
25
|
}
|
|
26
|
-
const composeKeyWithSeparator = function(...args) {
|
|
27
|
-
if (!args.length) {
|
|
28
|
-
return "";
|
|
29
|
-
}
|
|
30
|
-
return args.reduce((sum, cur) => {
|
|
31
|
-
if (!cur) {
|
|
32
|
-
return sum;
|
|
33
|
-
}
|
|
34
|
-
if (!sum) {
|
|
35
|
-
return cur;
|
|
36
|
-
}
|
|
37
|
-
return `${sum}${SEPARATOR}${cur}`;
|
|
38
|
-
}, "");
|
|
39
|
-
};
|
|
40
26
|
let Logger = class Logger2 {
|
|
41
27
|
setPrefix(prefix) {
|
|
42
28
|
this.prefix = prefix;
|
|
@@ -205,10 +191,46 @@ async function loadModule(url2, options) {
|
|
|
205
191
|
});
|
|
206
192
|
return module;
|
|
207
193
|
}
|
|
194
|
+
const LoggerInstance = createLogger(
|
|
195
|
+
"[ Module Federation Bridge React ]"
|
|
196
|
+
);
|
|
197
|
+
function pathJoin(...args) {
|
|
198
|
+
const res2 = args.reduce((res22, path2) => {
|
|
199
|
+
let nPath = path2;
|
|
200
|
+
if (!nPath || typeof nPath !== "string") {
|
|
201
|
+
return res22;
|
|
202
|
+
}
|
|
203
|
+
if (nPath[0] !== "/") {
|
|
204
|
+
nPath = `/${nPath}`;
|
|
205
|
+
}
|
|
206
|
+
const lastIndex = nPath.length - 1;
|
|
207
|
+
if (nPath[lastIndex] === "/") {
|
|
208
|
+
nPath = nPath.substring(0, lastIndex);
|
|
209
|
+
}
|
|
210
|
+
return res22 + nPath;
|
|
211
|
+
}, "");
|
|
212
|
+
return res2 || "/";
|
|
213
|
+
}
|
|
214
|
+
const getModuleName = (id) => {
|
|
215
|
+
if (!id) {
|
|
216
|
+
return id;
|
|
217
|
+
}
|
|
218
|
+
const idArray = id.split("/");
|
|
219
|
+
if (idArray.length < 2) {
|
|
220
|
+
return id;
|
|
221
|
+
}
|
|
222
|
+
return idArray[0] + "/" + idArray[1];
|
|
223
|
+
};
|
|
224
|
+
const getRootDomDefaultClassName = (moduleName) => {
|
|
225
|
+
if (!moduleName) {
|
|
226
|
+
return "";
|
|
227
|
+
}
|
|
228
|
+
const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
|
|
229
|
+
return `bridge-root-component-${name}`;
|
|
230
|
+
};
|
|
208
231
|
export {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
isBrowserEnv as i
|
|
232
|
+
LoggerInstance as L,
|
|
233
|
+
RouterContext as R,
|
|
234
|
+
getRootDomDefaultClassName as g,
|
|
235
|
+
pathJoin as p
|
|
214
236
|
};
|