@module-federation/bridge-react 0.0.0-next-20250926024003 → 0.0.0-perf-devtools-20260106124142
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 +81 -3
- package/__tests__/bridge.spec.tsx +37 -14
- package/dist/base.cjs.js +29 -0
- package/dist/base.d.ts +311 -0
- package/dist/base.es.js +30 -0
- package/dist/{bridge-base-BwHtOqw_.mjs → bridge-base-CPSTBjEp.mjs} +30 -18
- package/dist/{bridge-base-Ds850AOx.js → bridge-base-RStDxH71.js} +30 -18
- package/dist/createHelpers-B_L612IN.js +190 -0
- package/dist/createHelpers-Ui5pt7je.mjs +191 -0
- 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 +8 -8
- package/dist/{index-eN2xRRXs.js → index-DRSBaSu3.js} +1 -1
- package/dist/{index-rAO0Wr0M.mjs → index-DyQNwY2M.mjs} +1 -1
- package/dist/index.cjs.js +11 -179
- package/dist/index.d.ts +31 -6
- package/dist/index.es.js +19 -186
- package/dist/{index.esm-Ju4RY-yW.js → index.esm-BWaKho-8.js} +108 -46
- package/dist/{index.esm-CtI0uQUR.mjs → index.esm-CPwSeCvw.mjs} +113 -51
- package/dist/{lazy-load-component-plugin-CWNzJM0v.js → lazy-load-component-plugin-BbKBABLx.js} +2 -2
- package/dist/{lazy-load-component-plugin-D6tEPyvX.mjs → lazy-load-component-plugin-CHUcCRrF.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 +4 -4
- package/dist/{prefetch-DCF_oa3O.mjs → prefetch-CBBSKet3.mjs} +43 -141
- package/dist/{prefetch-hTVJ80G6.js → prefetch-DcwCyN6i.js} +43 -141
- 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-VSOJTX_o.mjs → utils-dUgb9Jkm.mjs} +7 -7
- package/dist/{utils-vIpCrZmn.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 +54 -10
- package/src/base.ts +50 -0
- package/src/index.ts +6 -1
- package/src/provider/versions/bridge-base.tsx +45 -17
- package/src/provider/versions/legacy.ts +2 -1
- 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/src/router/v7.tsx +75 -0
- package/vite.config.ts +25 -0
- package/src/remote/create.tsx +0 -103
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,90 @@
|
|
|
1
1
|
# @module-federation/bridge-react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-perf-devtools-20260106124142
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- @module-federation/sdk@0.0.0-perf-devtools-20260106124142
|
|
8
|
+
- @module-federation/bridge-shared@0.0.0-perf-devtools-20260106124142
|
|
9
|
+
|
|
10
|
+
## 0.22.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- @module-federation/sdk@0.22.0
|
|
15
|
+
- @module-federation/bridge-shared@0.22.0
|
|
16
|
+
|
|
17
|
+
## 0.21.6
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- @module-federation/sdk@0.21.6
|
|
22
|
+
- @module-federation/bridge-shared@0.21.6
|
|
23
|
+
|
|
24
|
+
## 0.21.5
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [94d8868]
|
|
29
|
+
- @module-federation/sdk@0.21.5
|
|
30
|
+
- @module-federation/bridge-shared@0.21.5
|
|
31
|
+
|
|
32
|
+
## 0.21.4
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- 444db72: fix(bridge-react): hoist BridgeWrapper to prevent component recreation
|
|
37
|
+
- Updated dependencies [a50e068]
|
|
38
|
+
- @module-federation/sdk@0.21.4
|
|
39
|
+
- @module-federation/bridge-shared@0.21.4
|
|
40
|
+
|
|
41
|
+
## 0.21.3
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- @module-federation/sdk@0.21.3
|
|
46
|
+
- @module-federation/bridge-shared@0.21.3
|
|
47
|
+
|
|
48
|
+
## 0.21.2
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- e98133e: feat: Re-export the exports of the v18/v19/plugin from @module-federation/bridge-react in modernjs
|
|
53
|
+
- dc103ee: fix: support React Router v6 in peer dependencies
|
|
54
|
+
|
|
55
|
+
Update react-router peer dependency from "^7" to "^6 || ^7" to fix npm install failures for projects using React Router v6.
|
|
56
|
+
|
|
57
|
+
- @module-federation/sdk@0.21.2
|
|
58
|
+
- @module-federation/bridge-shared@0.21.2
|
|
59
|
+
|
|
60
|
+
## 0.21.1
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- @module-federation/sdk@0.21.1
|
|
65
|
+
- @module-federation/bridge-shared@0.21.1
|
|
66
|
+
|
|
67
|
+
## 0.21.0
|
|
68
|
+
|
|
69
|
+
### Minor Changes
|
|
70
|
+
|
|
71
|
+
- d225658: feat: Add React Router v7 Support to Module Federation Bridge
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- Updated dependencies [d1e90a4]
|
|
76
|
+
- @module-federation/sdk@0.21.0
|
|
77
|
+
- @module-federation/bridge-shared@0.21.0
|
|
78
|
+
|
|
79
|
+
## 0.20.0
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- 0008621: test(bridge-react): stabilize async assertions for bridge tests
|
|
7
84
|
- Updated dependencies [37346d4]
|
|
8
|
-
|
|
9
|
-
- @module-federation/
|
|
85
|
+
- Updated dependencies [639a83b]
|
|
86
|
+
- @module-federation/sdk@0.20.0
|
|
87
|
+
- @module-federation/bridge-shared@0.20.0
|
|
10
88
|
|
|
11
89
|
## 0.19.1
|
|
12
90
|
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
screen,
|
|
8
8
|
waitFor,
|
|
9
9
|
} from '@testing-library/react';
|
|
10
|
-
import { createContainer, getHtml
|
|
10
|
+
import { createContainer, getHtml } from './util';
|
|
11
11
|
|
|
12
12
|
describe('bridge', () => {
|
|
13
13
|
let containerInfo: ReturnType<typeof createContainer>;
|
|
@@ -31,9 +31,13 @@ describe('bridge', () => {
|
|
|
31
31
|
dom: containerInfo?.container,
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
await
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
await waitFor(
|
|
35
|
+
() => {
|
|
36
|
+
expect(document.querySelector('#container')?.innerHTML).toContain(
|
|
37
|
+
'<div>life cycle render</div>',
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
{ timeout: 2000 },
|
|
37
41
|
);
|
|
38
42
|
|
|
39
43
|
lifeCycle.destroy({
|
|
@@ -41,7 +45,14 @@ describe('bridge', () => {
|
|
|
41
45
|
moduleName: 'test',
|
|
42
46
|
});
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
await waitFor(
|
|
49
|
+
() => {
|
|
50
|
+
expect(
|
|
51
|
+
(document.querySelector('#container')?.innerHTML || '').trim(),
|
|
52
|
+
).toBe('');
|
|
53
|
+
},
|
|
54
|
+
{ timeout: 2000 },
|
|
55
|
+
);
|
|
45
56
|
});
|
|
46
57
|
|
|
47
58
|
it('createRemoteAppComponent', async () => {
|
|
@@ -66,9 +77,13 @@ describe('bridge', () => {
|
|
|
66
77
|
);
|
|
67
78
|
expect(getHtml(container)).toMatch('loading');
|
|
68
79
|
|
|
69
|
-
await
|
|
70
|
-
|
|
71
|
-
|
|
80
|
+
await waitFor(
|
|
81
|
+
() => {
|
|
82
|
+
expect(getHtml(container)).toMatch('life cycle render');
|
|
83
|
+
expect(getHtml(container)).toMatch('hello world');
|
|
84
|
+
},
|
|
85
|
+
{ timeout: 2000 },
|
|
86
|
+
);
|
|
72
87
|
});
|
|
73
88
|
|
|
74
89
|
it('createRemoteAppComponent and obtain ref property', async () => {
|
|
@@ -97,10 +112,14 @@ describe('bridge', () => {
|
|
|
97
112
|
);
|
|
98
113
|
expect(getHtml(container)).toMatch('loading');
|
|
99
114
|
|
|
100
|
-
await
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
115
|
+
await waitFor(
|
|
116
|
+
() => {
|
|
117
|
+
expect(getHtml(container)).toMatch('life cycle render');
|
|
118
|
+
expect(getHtml(container)).toMatch('hello world');
|
|
119
|
+
expect(ref.current).not.toBeNull();
|
|
120
|
+
},
|
|
121
|
+
{ timeout: 2000 },
|
|
122
|
+
);
|
|
104
123
|
});
|
|
105
124
|
|
|
106
125
|
it('createRemoteAppComponent with custom createRoot prop', async () => {
|
|
@@ -131,7 +150,11 @@ describe('bridge', () => {
|
|
|
131
150
|
const { container } = render(<RemoteComponent />);
|
|
132
151
|
expect(getHtml(container)).toMatch('loading');
|
|
133
152
|
|
|
134
|
-
await
|
|
135
|
-
|
|
153
|
+
await waitFor(
|
|
154
|
+
() => {
|
|
155
|
+
expect(renderMock).toHaveBeenCalledTimes(1);
|
|
156
|
+
},
|
|
157
|
+
{ timeout: 2000 },
|
|
158
|
+
);
|
|
136
159
|
});
|
|
137
160
|
});
|
package/dist/base.cjs.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const createHelpers = require("./createHelpers-B_L612IN.js");
|
|
4
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-BbKBABLx.js");
|
|
5
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
6
|
+
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
7
|
+
const prefetch = require("./prefetch-DcwCyN6i.js");
|
|
8
|
+
const createRemoteAppComponent = createHelpers.createRemoteAppComponentFactory(createHelpers.RemoteAppWrapper);
|
|
9
|
+
const createRemoteComponent = createHelpers.createDeprecatedRemoteComponentFactory(
|
|
10
|
+
createRemoteAppComponent
|
|
11
|
+
);
|
|
12
|
+
exports.createBridgeComponent = createHelpers.createBridgeComponent;
|
|
13
|
+
exports.autoFetchDataPlugin = lazyLoadComponentPlugin.autoFetchData;
|
|
14
|
+
exports.collectSSRAssets = lazyLoadComponentPlugin.collectSSRAssets;
|
|
15
|
+
exports.createLazyComponent = lazyLoadComponentPlugin.createLazyComponent;
|
|
16
|
+
exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
|
|
17
|
+
exports.CacheSize = lazyUtils.CacheSize;
|
|
18
|
+
exports.CacheTime = lazyUtils.CacheTime;
|
|
19
|
+
exports.ERROR_TYPE = lazyUtils.ERROR_TYPE;
|
|
20
|
+
exports.cache = lazyUtils.cache;
|
|
21
|
+
exports.clearStore = lazyUtils.clearStore;
|
|
22
|
+
exports.configureCache = lazyUtils.configureCache;
|
|
23
|
+
exports.generateKey = lazyUtils.generateKey;
|
|
24
|
+
exports.revalidateTag = lazyUtils.revalidateTag;
|
|
25
|
+
exports.setSSREnv = lazyUtils.setSSREnv;
|
|
26
|
+
exports.callDataFetch = dataFetchUtils.callDataFetch;
|
|
27
|
+
exports.prefetch = prefetch.prefetch;
|
|
28
|
+
exports.createRemoteAppComponent = createRemoteAppComponent;
|
|
29
|
+
exports.createRemoteComponent = createRemoteComponent;
|
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
3
|
+
import { getInstance } from '@module-federation/runtime';
|
|
4
|
+
import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
|
|
5
|
+
import * as React_2 from 'react';
|
|
6
|
+
import { ReactNode } from 'react';
|
|
7
|
+
import { RefAttributes } from 'react';
|
|
8
|
+
|
|
9
|
+
export declare const autoFetchDataPlugin: () => ModuleFederationRuntimePlugin;
|
|
10
|
+
|
|
11
|
+
export declare function cache<T>(fn: DataFetch<T>, options?: CacheOptions): DataFetch<T>;
|
|
12
|
+
|
|
13
|
+
declare interface CacheConfig {
|
|
14
|
+
maxSize?: number;
|
|
15
|
+
unstable_shouldDisable?: ({ request, }: {
|
|
16
|
+
request: Request;
|
|
17
|
+
}) => boolean | Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare interface CacheOptions {
|
|
21
|
+
tag?: string | string[];
|
|
22
|
+
maxAge?: number;
|
|
23
|
+
revalidate?: number;
|
|
24
|
+
getKey?: <Args extends any[]>(...args: Args) => string;
|
|
25
|
+
onCache?: (info: CacheStatsInfo) => boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export declare const CacheSize: {
|
|
29
|
+
readonly KB: 1024;
|
|
30
|
+
readonly MB: number;
|
|
31
|
+
readonly GB: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export declare interface CacheStatsInfo {
|
|
35
|
+
status: CacheStatus;
|
|
36
|
+
key: string | symbol;
|
|
37
|
+
params: DataFetchParams;
|
|
38
|
+
result: any;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export declare type CacheStatus = 'hit' | 'stale' | 'miss';
|
|
42
|
+
|
|
43
|
+
export declare const CacheTime: {
|
|
44
|
+
readonly SECOND: 1000;
|
|
45
|
+
readonly MINUTE: number;
|
|
46
|
+
readonly HOUR: number;
|
|
47
|
+
readonly DAY: number;
|
|
48
|
+
readonly WEEK: number;
|
|
49
|
+
readonly MONTH: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export declare function callDataFetch(): Promise<void>;
|
|
53
|
+
|
|
54
|
+
export declare function clearStore(): void;
|
|
55
|
+
|
|
56
|
+
export declare function collectSSRAssets(options: CollectSSRAssetsOptions): default_2.ReactNode[];
|
|
57
|
+
|
|
58
|
+
export declare type CollectSSRAssetsOptions = {
|
|
59
|
+
id: string;
|
|
60
|
+
instance: ReturnType<typeof getInstance>;
|
|
61
|
+
injectScript?: boolean;
|
|
62
|
+
injectLink?: boolean;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export declare function configureCache(config: CacheConfig): void;
|
|
66
|
+
|
|
67
|
+
export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
|
|
68
|
+
render(info: RenderParams): Promise<void>;
|
|
69
|
+
destroy(info: DestroyParams): void;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export declare function createLazyComponent<T, E extends keyof T>(options: CreateLazyComponentOptions<T, E>): (props: T[E] extends (...args: any) => any ? Parameters<T[E]>[0] extends undefined ? ReactKey : Parameters<T[E]>[0] & ReactKey : ReactKey) => default_2.JSX.Element;
|
|
73
|
+
|
|
74
|
+
export declare type CreateLazyComponentOptions<T, E extends keyof T> = {
|
|
75
|
+
loader: () => Promise<T>;
|
|
76
|
+
instance: ReturnType<typeof getInstance>;
|
|
77
|
+
loading: default_2.ReactNode;
|
|
78
|
+
delayLoading?: number;
|
|
79
|
+
fallback: ReactNode | ((errorInfo: ErrorInfo) => ReactNode);
|
|
80
|
+
export?: E;
|
|
81
|
+
dataFetchParams?: DataFetchParams;
|
|
82
|
+
noSSR?: boolean;
|
|
83
|
+
injectScript?: boolean;
|
|
84
|
+
injectLink?: boolean;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export declare const createRemoteAppComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => ForwardRefExoticComponent<Omit<RemoteComponentProps_2<Record<string, unknown>>, "ref"> & RefAttributes<HTMLDivElement>>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated createRemoteComponent is deprecated, please use createRemoteAppComponent instead!
|
|
91
|
+
*/
|
|
92
|
+
export declare const createRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => any;
|
|
93
|
+
|
|
94
|
+
export declare interface CreateRootOptions {
|
|
95
|
+
identifierPrefix?: string;
|
|
96
|
+
onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Options for creating a React root
|
|
101
|
+
*/
|
|
102
|
+
declare interface CreateRootOptions_2 {
|
|
103
|
+
identifierPrefix?: string;
|
|
104
|
+
onRecoverableError?: (error: unknown) => void;
|
|
105
|
+
transitionCallbacks?: unknown;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare type DataFetch<T> = (params: DataFetchParams) => Promise<T>;
|
|
109
|
+
|
|
110
|
+
export declare type DataFetchParams = {
|
|
111
|
+
isDowngrade: boolean;
|
|
112
|
+
_id?: string;
|
|
113
|
+
} & Record<string, unknown>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Parameters for the destroy function
|
|
117
|
+
*/
|
|
118
|
+
export declare interface DestroyParams {
|
|
119
|
+
moduleName: string;
|
|
120
|
+
dom: HTMLElement;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export declare const ERROR_TYPE: {
|
|
124
|
+
DATA_FETCH: number;
|
|
125
|
+
LOAD_REMOTE: number;
|
|
126
|
+
UNKNOWN: number;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
declare type ErrorInfo = {
|
|
130
|
+
error: Error;
|
|
131
|
+
errorType: number;
|
|
132
|
+
dataFetchMapKey?: string;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export declare function generateKey(dataFetchOptions: DataFetchParams): string;
|
|
136
|
+
|
|
137
|
+
export declare function lazyLoadComponentPlugin(): ModuleFederationRuntimePlugin;
|
|
138
|
+
|
|
139
|
+
export declare type LazyRemoteComponentInfo<T, _E extends keyof T> = RemoteComponentParams<T>;
|
|
140
|
+
|
|
141
|
+
export declare type NoSSRRemoteInfo = {
|
|
142
|
+
name: string;
|
|
143
|
+
version: string;
|
|
144
|
+
ssrPublicPath: string;
|
|
145
|
+
ssrRemoteEntry: string;
|
|
146
|
+
globalName: string;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export declare function prefetch(options: PrefetchOptions): Promise<void>;
|
|
150
|
+
|
|
151
|
+
declare type PrefetchOptions = {
|
|
152
|
+
id: string;
|
|
153
|
+
instance: ReturnType<typeof getInstance>;
|
|
154
|
+
dataFetchParams?: DataFetchParams;
|
|
155
|
+
preloadComponentResource?: boolean;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Parameters for the provider function
|
|
160
|
+
*/
|
|
161
|
+
export declare interface ProviderFnParams<T> {
|
|
162
|
+
rootComponent: React_2.ComponentType<T>;
|
|
163
|
+
render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
|
|
164
|
+
createRoot?: (container: Element | DocumentFragment, options?: CreateRootOptions_2) => Root_2;
|
|
165
|
+
/**
|
|
166
|
+
* Default options to pass to createRoot for React 18 and 19
|
|
167
|
+
* These options will be used when creating a root unless overridden by rootOptions in render params
|
|
168
|
+
* @example
|
|
169
|
+
* {
|
|
170
|
+
* identifierPrefix: 'app-',
|
|
171
|
+
* onRecoverableError: (err) => console.error(err)
|
|
172
|
+
* }
|
|
173
|
+
*/
|
|
174
|
+
defaultRootOptions?: CreateRootOptions_2;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Parameters for the provider function
|
|
179
|
+
*/
|
|
180
|
+
export declare interface ProviderParams {
|
|
181
|
+
moduleName?: string;
|
|
182
|
+
basename?: string;
|
|
183
|
+
memoryRoute?: {
|
|
184
|
+
entryPath: string;
|
|
185
|
+
initialState?: Record<string, unknown>;
|
|
186
|
+
};
|
|
187
|
+
style?: React_2.CSSProperties;
|
|
188
|
+
className?: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
declare type ReactKey = {
|
|
192
|
+
key?: default_2.Key | null;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Parameters for the remote component loader
|
|
197
|
+
*/
|
|
198
|
+
export declare interface RemoteComponentParams<T = Record<string, unknown>, E extends keyof T = keyof T> {
|
|
199
|
+
loader: () => Promise<T>;
|
|
200
|
+
loading: React_2.ReactNode;
|
|
201
|
+
fallback: React_2.ComponentType<{
|
|
202
|
+
error: Error;
|
|
203
|
+
}>;
|
|
204
|
+
export?: E;
|
|
205
|
+
props?: T;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Parameters for the remote component
|
|
210
|
+
*/
|
|
211
|
+
export declare interface RemoteComponentProps<T = Record<string, unknown>> {
|
|
212
|
+
props?: T;
|
|
213
|
+
fallback?: React_2.ComponentType<{
|
|
214
|
+
error: Error;
|
|
215
|
+
}>;
|
|
216
|
+
loading?: React_2.ReactNode;
|
|
217
|
+
[key: string]: unknown;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Parameters for the remote component
|
|
222
|
+
*/
|
|
223
|
+
declare interface RemoteComponentProps_2<T = Record<string, unknown>> {
|
|
224
|
+
props?: T;
|
|
225
|
+
fallback?: React_2.ComponentType<{
|
|
226
|
+
error: Error;
|
|
227
|
+
}>;
|
|
228
|
+
loading?: React_2.ReactNode;
|
|
229
|
+
[key: string]: unknown;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Interface for a remote module provider
|
|
234
|
+
*/
|
|
235
|
+
export declare interface RemoteModule {
|
|
236
|
+
provider: () => {
|
|
237
|
+
render: (info: RenderFnParams) => void;
|
|
238
|
+
destroy: (info: {
|
|
239
|
+
dom: any;
|
|
240
|
+
}) => void;
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Parameters for the render function, extending ProviderParams
|
|
246
|
+
*/
|
|
247
|
+
export declare interface RenderFnParams extends ProviderParams {
|
|
248
|
+
dom: HTMLElement;
|
|
249
|
+
fallback?: React_2.ComponentType<{
|
|
250
|
+
error: Error;
|
|
251
|
+
}>;
|
|
252
|
+
[key: string]: unknown;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Parameters for the render function
|
|
257
|
+
*/
|
|
258
|
+
export declare interface RenderParams {
|
|
259
|
+
moduleName?: string;
|
|
260
|
+
basename?: string;
|
|
261
|
+
memoryRoute?: {
|
|
262
|
+
entryPath: string;
|
|
263
|
+
initialState?: Record<string, unknown>;
|
|
264
|
+
};
|
|
265
|
+
dom: HTMLElement;
|
|
266
|
+
/**
|
|
267
|
+
* Options to pass to createRoot for React 18 and 19
|
|
268
|
+
* @example
|
|
269
|
+
* {
|
|
270
|
+
* identifierPrefix: 'app-',
|
|
271
|
+
* onRecoverableError: (err) => console.error(err)
|
|
272
|
+
* }
|
|
273
|
+
*/
|
|
274
|
+
rootOptions?: CreateRootOptions_2;
|
|
275
|
+
[key: string]: unknown;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export declare function revalidateTag(tag: string): void;
|
|
279
|
+
|
|
280
|
+
export declare interface Root {
|
|
281
|
+
render(children: React.ReactNode): void;
|
|
282
|
+
unmount(): void;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Interface for a React root object
|
|
287
|
+
*/
|
|
288
|
+
declare interface Root_2 {
|
|
289
|
+
render(children: React_2.ReactNode): void;
|
|
290
|
+
unmount(): void;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Type for a root element, which can be either an HTMLElement or a React root
|
|
295
|
+
*/
|
|
296
|
+
export declare type RootType = HTMLElement | Root_2;
|
|
297
|
+
|
|
298
|
+
export declare function setSSREnv({ fetchServerQuery, }: {
|
|
299
|
+
fetchServerQuery?: Record<string, unknown>;
|
|
300
|
+
}): void;
|
|
301
|
+
|
|
302
|
+
export { }
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
declare module '@module-federation/runtime-core' {
|
|
306
|
+
interface ModuleFederation {
|
|
307
|
+
createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
|
|
308
|
+
prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
|
|
309
|
+
collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
|
|
310
|
+
}
|
|
311
|
+
}
|
package/dist/base.es.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { c as createDeprecatedRemoteComponentFactory, a as createRemoteAppComponentFactory, R as RemoteAppWrapper } from "./createHelpers-Ui5pt7je.mjs";
|
|
2
|
+
import { b } from "./createHelpers-Ui5pt7je.mjs";
|
|
3
|
+
import { b as b2, a, c, l } from "./lazy-load-component-plugin-CHUcCRrF.mjs";
|
|
4
|
+
import { C, a as a2, E, b as b3, d, c as c2, g, r, s } from "./utils-dUgb9Jkm.mjs";
|
|
5
|
+
import { callDataFetch } from "./data-fetch-utils.es.js";
|
|
6
|
+
import { p } from "./prefetch-CBBSKet3.mjs";
|
|
7
|
+
const createRemoteAppComponent = createRemoteAppComponentFactory(RemoteAppWrapper);
|
|
8
|
+
const createRemoteComponent = createDeprecatedRemoteComponentFactory(
|
|
9
|
+
createRemoteAppComponent
|
|
10
|
+
);
|
|
11
|
+
export {
|
|
12
|
+
C as CacheSize,
|
|
13
|
+
a2 as CacheTime,
|
|
14
|
+
E as ERROR_TYPE,
|
|
15
|
+
b2 as autoFetchDataPlugin,
|
|
16
|
+
b3 as cache,
|
|
17
|
+
callDataFetch,
|
|
18
|
+
d as clearStore,
|
|
19
|
+
a as collectSSRAssets,
|
|
20
|
+
c2 as configureCache,
|
|
21
|
+
b as createBridgeComponent,
|
|
22
|
+
c as createLazyComponent,
|
|
23
|
+
createRemoteAppComponent,
|
|
24
|
+
createRemoteComponent,
|
|
25
|
+
g as generateKey,
|
|
26
|
+
l as lazyLoadComponentPlugin,
|
|
27
|
+
p as prefetch,
|
|
28
|
+
r as revalidateTag,
|
|
29
|
+
s as setSSREnv
|
|
30
|
+
};
|
|
@@ -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 = {
|
|
@@ -121,6 +121,24 @@ function createBaseBridgeComponent({
|
|
|
121
121
|
}
|
|
122
122
|
));
|
|
123
123
|
};
|
|
124
|
+
const DefaultFallback = ({ error }) => /* @__PURE__ */ React.createElement("div", { role: "alert" }, /* @__PURE__ */ React.createElement("p", null, "Something went wrong:"), /* @__PURE__ */ React.createElement("pre", { style: { color: "red" } }, error.message));
|
|
125
|
+
const BridgeWrapper = ({
|
|
126
|
+
basename,
|
|
127
|
+
moduleName,
|
|
128
|
+
memoryRoute,
|
|
129
|
+
propsInfo,
|
|
130
|
+
fallback
|
|
131
|
+
}) => /* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: fallback || DefaultFallback }, /* @__PURE__ */ React.createElement(
|
|
132
|
+
RawComponent,
|
|
133
|
+
{
|
|
134
|
+
appInfo: {
|
|
135
|
+
moduleName,
|
|
136
|
+
basename,
|
|
137
|
+
memoryRoute
|
|
138
|
+
},
|
|
139
|
+
propsInfo
|
|
140
|
+
}
|
|
141
|
+
));
|
|
124
142
|
return {
|
|
125
143
|
async render(info) {
|
|
126
144
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -140,24 +158,18 @@ function createBaseBridgeComponent({
|
|
|
140
158
|
};
|
|
141
159
|
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
160
|
const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(
|
|
143
|
-
|
|
161
|
+
BridgeWrapper,
|
|
144
162
|
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
memoryRoute
|
|
154
|
-
},
|
|
155
|
-
propsInfo: {
|
|
156
|
-
...propsInfo,
|
|
157
|
-
...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
|
|
158
|
-
}
|
|
163
|
+
basename,
|
|
164
|
+
moduleName,
|
|
165
|
+
memoryRoute,
|
|
166
|
+
fallback,
|
|
167
|
+
propsInfo: {
|
|
168
|
+
...propsInfo,
|
|
169
|
+
basename,
|
|
170
|
+
...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
|
|
159
171
|
}
|
|
160
|
-
|
|
172
|
+
}
|
|
161
173
|
);
|
|
162
174
|
if (bridgeInfo.render) {
|
|
163
175
|
await Promise.resolve(
|
|
@@ -184,7 +196,7 @@ function createBaseBridgeComponent({
|
|
|
184
196
|
if ("unmount" in root) {
|
|
185
197
|
root.unmount();
|
|
186
198
|
} else {
|
|
187
|
-
|
|
199
|
+
LoggerInstance.warn("Root does not have unmount method");
|
|
188
200
|
}
|
|
189
201
|
rootMap.delete(dom);
|
|
190
202
|
}
|