@module-federation/bridge-react 0.17.0 → 0.17.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 +26 -0
- package/__tests__/bridge.spec.tsx +3 -3
- package/__tests__/createLazyComponent.spec.tsx +12 -13
- package/__tests__/prefetch.spec.ts +25 -22
- package/__tests__/router.spec.tsx +3 -3
- package/__tests__/setupTests.ts +5 -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 +4 -4
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.es.js +5 -5
- package/dist/{lazy-load-component-plugin-C1tVve-W.js → lazy-load-component-plugin-B80Ud11k.js} +1 -1
- package/dist/{lazy-load-component-plugin-PERjiaFJ.mjs → lazy-load-component-plugin-_UbR2mWQ.mjs} +2 -2
- package/dist/lazy-load-component-plugin.cjs.js +2 -2
- package/dist/lazy-load-component-plugin.d.ts +2 -2
- package/dist/lazy-load-component-plugin.es.js +2 -2
- package/dist/lazy-utils.es.js +3 -3
- package/dist/{prefetch-CZvoIftg.js → prefetch-BaKIdUwP.js} +7 -3
- package/dist/{prefetch-Dux8GUpr.mjs → prefetch-YpJYjpWC.mjs} +9 -5
- package/dist/{utils-Cy-amYU5.mjs → utils-C4oPJV34.mjs} +2 -2
- package/jest.config.ts +21 -0
- package/package.json +6 -6
- package/project.json +4 -8
- package/src/lazy/data-fetch/runtime-plugin.ts +4 -4
- package/src/plugins/lazy-load-component-plugin.ts +2 -2
- package/src/remote/create.tsx +1 -1
- package/tsconfig.spec.json +26 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @module-federation/bridge-react
|
|
2
2
|
|
|
3
|
+
## 0.17.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 65aa038: chore(bridge-react): set sideEffects false
|
|
8
|
+
- a7cf276: chore: upgrade NX to 21.2.3, Storybook to 9.0.9, and TypeScript to 5.8.3
|
|
9
|
+
|
|
10
|
+
- Upgraded NX from 21.0.3 to 21.2.3 with workspace configuration updates
|
|
11
|
+
- Migrated Storybook from 8.3.5 to 9.0.9 with updated configurations and automigrations
|
|
12
|
+
- Upgraded TypeScript from 5.7.3 to 5.8.3 with compatibility fixes
|
|
13
|
+
- Fixed package exports and type declaration paths across all packages
|
|
14
|
+
- Resolved module resolution issues and TypeScript compatibility problems
|
|
15
|
+
- Updated build configurations and dependencies to support latest versions
|
|
16
|
+
|
|
17
|
+
- d31a326: refactor: sink React packages from root to individual packages
|
|
18
|
+
|
|
19
|
+
- Removed React dependencies from root package.json and moved them to packages that actually need them
|
|
20
|
+
- Fixed rsbuild-plugin configuration to match workspace patterns
|
|
21
|
+
- Updated tests to handle platform-specific files
|
|
22
|
+
- This change improves dependency management by ensuring packages only have the dependencies they actually use
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [a7cf276]
|
|
25
|
+
- Updated dependencies [d31a326]
|
|
26
|
+
- @module-federation/sdk@0.17.1
|
|
27
|
+
- @module-federation/bridge-shared@0.17.1
|
|
28
|
+
|
|
3
29
|
## 0.17.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { assert, describe, it } from 'vitest';
|
|
3
2
|
import { createBridgeComponent, createRemoteAppComponent } from '../src';
|
|
4
3
|
import {
|
|
5
4
|
act,
|
|
@@ -39,6 +38,7 @@ describe('bridge', () => {
|
|
|
39
38
|
|
|
40
39
|
lifeCycle.destroy({
|
|
41
40
|
dom: containerInfo?.container,
|
|
41
|
+
moduleName: 'test',
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
expect(document.querySelector('#container')!.innerHTML).toContain('');
|
|
@@ -104,7 +104,7 @@ describe('bridge', () => {
|
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
it('createRemoteAppComponent with custom createRoot prop', async () => {
|
|
107
|
-
const renderMock =
|
|
107
|
+
const renderMock = jest.fn();
|
|
108
108
|
|
|
109
109
|
function Component({ props }: { props?: Record<string, any> }) {
|
|
110
110
|
return <div>life cycle render {props?.msg}</div>;
|
|
@@ -114,7 +114,7 @@ describe('bridge', () => {
|
|
|
114
114
|
createRoot: () => {
|
|
115
115
|
return {
|
|
116
116
|
render: renderMock,
|
|
117
|
-
unmount:
|
|
117
|
+
unmount: jest.fn(),
|
|
118
118
|
};
|
|
119
119
|
},
|
|
120
120
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { Suspense } from 'react';
|
|
2
2
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
4
3
|
import {
|
|
5
4
|
createLazyComponent,
|
|
6
5
|
collectSSRAssets,
|
|
@@ -9,13 +8,13 @@ import * as runtime from '@module-federation/runtime';
|
|
|
9
8
|
import * as utils from '../src/lazy/utils';
|
|
10
9
|
|
|
11
10
|
// Mocking dependencies
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
jest.mock('@module-federation/runtime');
|
|
12
|
+
jest.mock('../src/lazy/utils');
|
|
14
13
|
|
|
15
|
-
const mockGetInstance = runtime.getInstance as
|
|
16
|
-
const mockGetLoadedRemoteInfos = utils.getLoadedRemoteInfos as
|
|
17
|
-
const mockGetDataFetchMapKey = utils.getDataFetchMapKey as
|
|
18
|
-
const mockFetchData = utils.fetchData as
|
|
14
|
+
const mockGetInstance = runtime.getInstance as jest.Mock;
|
|
15
|
+
const mockGetLoadedRemoteInfos = utils.getLoadedRemoteInfos as jest.Mock;
|
|
16
|
+
const mockGetDataFetchMapKey = utils.getDataFetchMapKey as jest.Mock;
|
|
17
|
+
const mockFetchData = utils.fetchData as jest.Mock;
|
|
19
18
|
|
|
20
19
|
const MockComponent = () => <div>Mock Component</div>;
|
|
21
20
|
const LoadingComponent = () => <div>Loading...</div>;
|
|
@@ -25,11 +24,11 @@ describe('createLazyComponent', () => {
|
|
|
25
24
|
let mockInstance: any;
|
|
26
25
|
|
|
27
26
|
beforeEach(() => {
|
|
28
|
-
|
|
27
|
+
jest.clearAllMocks();
|
|
29
28
|
mockInstance = {
|
|
30
29
|
name: 'host-app',
|
|
31
30
|
options: { version: '1.0.0' },
|
|
32
|
-
getModuleInfo:
|
|
31
|
+
getModuleInfo: jest.fn(),
|
|
33
32
|
};
|
|
34
33
|
mockGetInstance.mockReturnValue(mockInstance);
|
|
35
34
|
mockGetLoadedRemoteInfos.mockReturnValue({
|
|
@@ -56,7 +55,7 @@ describe('createLazyComponent', () => {
|
|
|
56
55
|
});
|
|
57
56
|
|
|
58
57
|
it('should render loading component then the actual component', async () => {
|
|
59
|
-
const loader =
|
|
58
|
+
const loader = jest.fn().mockResolvedValue({
|
|
60
59
|
default: MockComponent,
|
|
61
60
|
[Symbol.for('mf_module_id')]: 'remoteApp/Component',
|
|
62
61
|
});
|
|
@@ -84,7 +83,7 @@ describe('createLazyComponent', () => {
|
|
|
84
83
|
it('should render fallback component on data fetch error', async () => {
|
|
85
84
|
mockFetchData.mockRejectedValue(new Error('Data fetch failed'));
|
|
86
85
|
const LazyComponentWithDataFetch = createLazyComponent({
|
|
87
|
-
loader:
|
|
86
|
+
loader: jest.fn().mockResolvedValue({
|
|
88
87
|
default: MockComponent,
|
|
89
88
|
[Symbol.for('mf_module_id')]: 'remoteApp/Component',
|
|
90
89
|
}),
|
|
@@ -101,7 +100,7 @@ describe('createLazyComponent', () => {
|
|
|
101
100
|
});
|
|
102
101
|
|
|
103
102
|
it('should fetch data and pass it to the component', async () => {
|
|
104
|
-
const loader =
|
|
103
|
+
const loader = jest.fn().mockResolvedValue({
|
|
105
104
|
default: (props: { mfData: any }) => (
|
|
106
105
|
<div>Data: {JSON.stringify(props.mfData)}</div>
|
|
107
106
|
),
|
|
@@ -131,7 +130,7 @@ describe('collectSSRAssets', () => {
|
|
|
131
130
|
let mockInstance: any;
|
|
132
131
|
|
|
133
132
|
beforeEach(() => {
|
|
134
|
-
|
|
133
|
+
jest.clearAllMocks();
|
|
135
134
|
mockInstance = {
|
|
136
135
|
name: 'host-app',
|
|
137
136
|
options: { version: '1.0.0' },
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
2
1
|
import { prefetch } from '../src/lazy/data-fetch/prefetch';
|
|
3
2
|
import * as utils from '../src/lazy/utils';
|
|
4
3
|
import logger from '../src/lazy/logger';
|
|
5
4
|
import helpers from '@module-federation/runtime/helpers';
|
|
6
5
|
|
|
7
6
|
// Mock dependencies
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
jest.mock('../src/lazy/logger');
|
|
8
|
+
jest.mock('../src/lazy/utils');
|
|
9
|
+
jest.mock('@module-federation/runtime/helpers', () => ({
|
|
11
10
|
default: {
|
|
12
11
|
utils: {
|
|
13
|
-
matchRemoteWithNameAndExpose:
|
|
14
|
-
getRemoteInfo:
|
|
12
|
+
matchRemoteWithNameAndExpose: jest.fn(),
|
|
13
|
+
getRemoteInfo: jest.fn(),
|
|
15
14
|
},
|
|
16
15
|
},
|
|
16
|
+
utils: {
|
|
17
|
+
matchRemoteWithNameAndExpose: jest.fn(),
|
|
18
|
+
getRemoteInfo: jest.fn(),
|
|
19
|
+
},
|
|
17
20
|
}));
|
|
18
21
|
|
|
19
22
|
describe('prefetch', () => {
|
|
20
23
|
let mockInstance: any;
|
|
21
24
|
|
|
22
25
|
beforeEach(() => {
|
|
23
|
-
|
|
26
|
+
jest.clearAllMocks();
|
|
24
27
|
mockInstance = {
|
|
25
28
|
name: 'host',
|
|
26
29
|
options: {
|
|
@@ -34,13 +37,13 @@ describe('prefetch', () => {
|
|
|
34
37
|
],
|
|
35
38
|
},
|
|
36
39
|
snapshotHandler: {
|
|
37
|
-
loadRemoteSnapshotInfo:
|
|
40
|
+
loadRemoteSnapshotInfo: jest.fn(),
|
|
38
41
|
},
|
|
39
42
|
remoteHandler: {
|
|
40
43
|
hooks: {
|
|
41
44
|
lifecycle: {
|
|
42
45
|
generatePreloadAssets: {
|
|
43
|
-
emit:
|
|
46
|
+
emit: jest.fn(),
|
|
44
47
|
},
|
|
45
48
|
},
|
|
46
49
|
},
|
|
@@ -63,7 +66,7 @@ describe('prefetch', () => {
|
|
|
63
66
|
});
|
|
64
67
|
|
|
65
68
|
it('should log an error if remote is not found', async () => {
|
|
66
|
-
(helpers.utils.matchRemoteWithNameAndExpose as
|
|
69
|
+
(helpers.utils.matchRemoteWithNameAndExpose as jest.Mock).mockReturnValue(
|
|
67
70
|
undefined,
|
|
68
71
|
);
|
|
69
72
|
await prefetch({ id: 'nonexistent/component', instance: mockInstance });
|
|
@@ -77,40 +80,40 @@ describe('prefetch', () => {
|
|
|
77
80
|
remote: { name: 'remote1', alias: 'remote1_alias' },
|
|
78
81
|
expose: './component1',
|
|
79
82
|
};
|
|
80
|
-
(helpers.utils.matchRemoteWithNameAndExpose as
|
|
83
|
+
(helpers.utils.matchRemoteWithNameAndExpose as jest.Mock).mockReturnValue(
|
|
81
84
|
mockRemoteInfo,
|
|
82
85
|
);
|
|
83
86
|
(
|
|
84
|
-
mockInstance.snapshotHandler.loadRemoteSnapshotInfo as
|
|
87
|
+
mockInstance.snapshotHandler.loadRemoteSnapshotInfo as jest.Mock
|
|
85
88
|
).mockResolvedValue({
|
|
86
89
|
remoteSnapshot: {},
|
|
87
90
|
globalSnapshot: {},
|
|
88
91
|
});
|
|
89
|
-
(helpers.utils.getRemoteInfo as
|
|
92
|
+
(helpers.utils.getRemoteInfo as jest.Mock).mockReturnValue({});
|
|
90
93
|
|
|
91
|
-
const mockDataFetchFn =
|
|
94
|
+
const mockDataFetchFn = jest
|
|
92
95
|
.fn()
|
|
93
96
|
.mockResolvedValue({ data: 'prefetched data' });
|
|
94
|
-
const mockGetDataFetchGetter =
|
|
97
|
+
const mockGetDataFetchGetter = jest.fn().mockResolvedValue(mockDataFetchFn);
|
|
95
98
|
const mockDataFetchMap = {
|
|
96
99
|
'remote1_alias@remote1/component1': [
|
|
97
100
|
[mockGetDataFetchGetter, 'GET', undefined],
|
|
98
101
|
],
|
|
99
102
|
};
|
|
100
|
-
(utils.getDataFetchMap as
|
|
101
|
-
(utils.getDataFetchInfo as
|
|
103
|
+
(utils.getDataFetchMap as jest.Mock).mockReturnValue(mockDataFetchMap);
|
|
104
|
+
(utils.getDataFetchInfo as jest.Mock).mockReturnValue({
|
|
102
105
|
name: 'remote1',
|
|
103
106
|
alias: 'remote1_alias',
|
|
104
107
|
id: 'remote1/component1',
|
|
105
108
|
});
|
|
106
|
-
(utils.getDataFetchMapKey as
|
|
109
|
+
(utils.getDataFetchMapKey as jest.Mock).mockReturnValue(
|
|
107
110
|
'remote1_alias@remote1/component1',
|
|
108
111
|
);
|
|
109
112
|
|
|
110
113
|
await prefetch({
|
|
111
114
|
id: 'remote1/component1',
|
|
112
115
|
instance: mockInstance,
|
|
113
|
-
dataFetchParams: { some: 'param' },
|
|
116
|
+
dataFetchParams: { some: 'param', isDowngrade: false } as any,
|
|
114
117
|
preloadComponentResource: true,
|
|
115
118
|
});
|
|
116
119
|
|
|
@@ -132,16 +135,16 @@ describe('prefetch', () => {
|
|
|
132
135
|
remote: { name: 'remote1', alias: 'remote1_alias' },
|
|
133
136
|
expose: './component1',
|
|
134
137
|
};
|
|
135
|
-
(helpers.utils.matchRemoteWithNameAndExpose as
|
|
138
|
+
(helpers.utils.matchRemoteWithNameAndExpose as jest.Mock).mockReturnValue(
|
|
136
139
|
mockRemoteInfo,
|
|
137
140
|
);
|
|
138
141
|
(
|
|
139
|
-
mockInstance.snapshotHandler.loadRemoteSnapshotInfo as
|
|
142
|
+
mockInstance.snapshotHandler.loadRemoteSnapshotInfo as jest.Mock
|
|
140
143
|
).mockResolvedValue({
|
|
141
144
|
remoteSnapshot: {},
|
|
142
145
|
globalSnapshot: {},
|
|
143
146
|
});
|
|
144
|
-
(utils.getDataFetchMap as
|
|
147
|
+
(utils.getDataFetchMap as jest.Mock).mockReturnValue(undefined);
|
|
145
148
|
|
|
146
149
|
await prefetch({
|
|
147
150
|
id: 'remote1/component1',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// Test file for router
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import {
|
|
@@ -15,7 +15,7 @@ import { getHtml, getWindowImpl } from './util';
|
|
|
15
15
|
describe('react router proxy', () => {
|
|
16
16
|
it('BrowserRouter not wraper context', async () => {
|
|
17
17
|
let { container } = render(
|
|
18
|
-
<RouterContext.Provider value={{
|
|
18
|
+
<RouterContext.Provider value={{ basename: '/test' } as any}>
|
|
19
19
|
<BrowserRouter basename="/" window={getWindowImpl('/test', false)}>
|
|
20
20
|
<ul>
|
|
21
21
|
<li>
|
|
@@ -73,7 +73,7 @@ describe('react router proxy', () => {
|
|
|
73
73
|
},
|
|
74
74
|
);
|
|
75
75
|
let { container } = render(
|
|
76
|
-
<RouterContext.Provider value={{
|
|
76
|
+
<RouterContext.Provider value={{ basename: '/test' } as any}>
|
|
77
77
|
<RouterProvider router={router} />
|
|
78
78
|
</RouterContext.Provider>,
|
|
79
79
|
);
|
package/__tests__/setupTests.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
// In vitest, you can use the setupFiles option in your configuration file to import any necessary setup files for your tests.
|
|
2
2
|
// For example, if you want to use testing-library's custom matchers, you can import them in a setup file like this:
|
|
3
3
|
import '@testing-library/jest-dom';
|
|
4
|
+
|
|
5
|
+
// Fix TextEncoder/TextDecoder not defined in Node.js
|
|
6
|
+
import { TextEncoder, TextDecoder } from 'util';
|
|
7
|
+
global.TextEncoder = TextEncoder;
|
|
8
|
+
global.TextDecoder = TextDecoder as any;
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-C4oPJV34.mjs";
|
|
2
2
|
import { M as MANIFEST_EXT, S as SEPARATOR } from "./index.esm-BCeUd-x9.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-iEVlDmyk.js");
|
|
4
|
-
const prefetch = require("./prefetch-
|
|
4
|
+
const prefetch = require("./prefetch-BaKIdUwP.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-C4oPJV34.mjs";
|
|
2
|
+
import { C, b, e, h, c, d, r } from "./utils-C4oPJV34.mjs";
|
|
3
|
+
import { d as dataFetchFunction } from "./prefetch-YpJYjpWC.mjs";
|
|
4
|
+
import { i, p } from "./prefetch-YpJYjpWC.mjs";
|
|
5
5
|
async function callDataFetch() {
|
|
6
6
|
const dataFetch = globalThis[DATA_FETCH_FUNCTION];
|
|
7
7
|
if (dataFetch) {
|
package/dist/index.cjs.js
CHANGED
|
@@ -6,10 +6,10 @@ const React = require("react");
|
|
|
6
6
|
const index = require("./index-C0fDZB5b.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-
|
|
9
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-B80Ud11k.js");
|
|
10
10
|
const lazyUtils = require("./utils-iEVlDmyk.js");
|
|
11
11
|
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
12
|
-
const prefetch = require("./prefetch-
|
|
12
|
+
const prefetch = require("./prefetch-BaKIdUwP.js");
|
|
13
13
|
function _interopNamespaceDefault(e2) {
|
|
14
14
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
15
15
|
if (e2) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { default as default_2 } from 'react';
|
|
2
|
-
import { FederationRuntimePlugin } from '@module-federation/runtime';
|
|
3
2
|
import { getInstance } from '@module-federation/runtime';
|
|
3
|
+
import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
|
|
4
4
|
import * as React_2 from 'react';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
6
|
|
|
7
|
-
export declare const autoFetchDataPlugin: () =>
|
|
7
|
+
export declare const autoFetchDataPlugin: () => ModuleFederationRuntimePlugin;
|
|
8
8
|
|
|
9
9
|
export declare function cache<T>(fn: DataFetch<T>, options?: CacheOptions): DataFetch<T>;
|
|
10
10
|
|
|
@@ -132,9 +132,9 @@ declare type ErrorInfo = {
|
|
|
132
132
|
|
|
133
133
|
export declare function generateKey(dataFetchOptions: DataFetchParams): string;
|
|
134
134
|
|
|
135
|
-
export declare function lazyLoadComponentPlugin():
|
|
135
|
+
export declare function lazyLoadComponentPlugin(): ModuleFederationRuntimePlugin;
|
|
136
136
|
|
|
137
|
-
declare type LazyRemoteComponentInfo<T,
|
|
137
|
+
declare type LazyRemoteComponentInfo<T, _E extends keyof T> = RemoteComponentParams<T>;
|
|
138
138
|
|
|
139
139
|
export declare type NoSSRRemoteInfo = {
|
|
140
140
|
name: string;
|
package/dist/index.es.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-BoshEggF.mjs";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
|
-
import React__default, { forwardRef,
|
|
4
|
-
import {
|
|
3
|
+
import React__default, { forwardRef, useContext, useState, useEffect, useRef } from "react";
|
|
4
|
+
import { p as pathJoin, L as LoggerInstance, g as getRootDomDefaultClassName } from "./index-CqxytsLY.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-_UbR2mWQ.mjs";
|
|
8
|
+
import { C, b as b2, E, e, h, c as c2, d, r, s } from "./utils-C4oPJV34.mjs";
|
|
9
9
|
import { callDataFetch } from "./data-fetch-utils.es.js";
|
|
10
|
-
import { p } from "./prefetch-
|
|
10
|
+
import { p } from "./prefetch-YpJYjpWC.mjs";
|
|
11
11
|
function createReact16Or17Root(container) {
|
|
12
12
|
return {
|
|
13
13
|
render(children) {
|
package/dist/{lazy-load-component-plugin-PERjiaFJ.mjs → lazy-load-component-plugin-_UbR2mWQ.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
|
|
1
|
+
import { i as injectDataFetch, p as prefetch } from "./prefetch-YpJYjpWC.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-C4oPJV34.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-B80Ud11k.js");
|
|
4
|
+
require("./prefetch-BaKIdUwP.js");
|
|
5
5
|
exports.default = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
|
|
6
6
|
exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
|
|
2
2
|
|
|
3
|
-
declare function lazyLoadComponentPlugin():
|
|
3
|
+
declare function lazyLoadComponentPlugin(): ModuleFederationRuntimePlugin;
|
|
4
4
|
export default lazyLoadComponentPlugin;
|
|
5
5
|
export { lazyLoadComponentPlugin }
|
|
6
6
|
|
|
@@ -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-_UbR2mWQ.mjs";
|
|
2
|
+
import "./prefetch-YpJYjpWC.mjs";
|
|
3
3
|
export {
|
|
4
4
|
l as default,
|
|
5
5
|
l2 as lazyLoadComponentPlugin
|
package/dist/lazy-utils.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./index.esm-BCeUd-x9.mjs";
|
|
2
|
-
import { G, H, f, J, I, u, k, n, g, m, B, y, i,
|
|
2
|
+
import { G, H, f, J, I, u, k, n, g, m, B, y, i, q, j, t, a, z, s, w } from "./utils-C4oPJV34.mjs";
|
|
3
3
|
export {
|
|
4
4
|
G as callAllDowngrade,
|
|
5
5
|
H as callDowngrade,
|
|
@@ -14,9 +14,9 @@ export {
|
|
|
14
14
|
B as getDowngradeTag,
|
|
15
15
|
y as getLoadedRemoteInfos,
|
|
16
16
|
i as initDataFetchMap,
|
|
17
|
-
|
|
17
|
+
q as isCSROnly,
|
|
18
18
|
j as isDataLoaderExpose,
|
|
19
|
-
|
|
19
|
+
t as isServerEnv,
|
|
20
20
|
a as loadDataFetchModule,
|
|
21
21
|
z as setDataFetchItemLoadedStatus,
|
|
22
22
|
s as setSSREnv,
|
|
@@ -172,14 +172,18 @@ function assert(condition, msg) {
|
|
|
172
172
|
}
|
|
173
173
|
function error(msg) {
|
|
174
174
|
if (msg instanceof Error) {
|
|
175
|
-
msg.message
|
|
175
|
+
if (!msg.message.startsWith(LOG_CATEGORY)) {
|
|
176
|
+
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
177
|
+
}
|
|
176
178
|
throw msg;
|
|
177
179
|
}
|
|
178
180
|
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
179
181
|
}
|
|
180
182
|
function warn(msg) {
|
|
181
183
|
if (msg instanceof Error) {
|
|
182
|
-
msg.message
|
|
184
|
+
if (!msg.message.startsWith(LOG_CATEGORY)) {
|
|
185
|
+
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
186
|
+
}
|
|
183
187
|
logger.warn(msg);
|
|
184
188
|
} else {
|
|
185
189
|
logger.warn(msg);
|
|
@@ -267,7 +271,7 @@ function getGlobalFederationConstructor() {
|
|
|
267
271
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = index_esm.isDebugMode()) {
|
|
268
272
|
if (isDebug) {
|
|
269
273
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
270
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.17.
|
|
274
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.17.1";
|
|
271
275
|
}
|
|
272
276
|
}
|
|
273
277
|
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 { b as isDebugMode, d as createLink, e as createScript, i as isBrowserEnv,
|
|
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-C4oPJV34.mjs";
|
|
2
|
+
import { b as isDebugMode, c as createLogger, d as createLink, e as createScript, i as isBrowserEnv, a as composeKeyWithSeparator, l as loadScriptNode, f as loadScript } from "./index.esm-BCeUd-x9.mjs";
|
|
3
3
|
const dataFetchFunction = async function(options) {
|
|
4
4
|
var _a, _b;
|
|
5
5
|
const [id, data, downgrade] = options;
|
|
@@ -171,14 +171,18 @@ function assert(condition, msg) {
|
|
|
171
171
|
}
|
|
172
172
|
function error(msg) {
|
|
173
173
|
if (msg instanceof Error) {
|
|
174
|
-
msg.message
|
|
174
|
+
if (!msg.message.startsWith(LOG_CATEGORY)) {
|
|
175
|
+
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
176
|
+
}
|
|
175
177
|
throw msg;
|
|
176
178
|
}
|
|
177
179
|
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
178
180
|
}
|
|
179
181
|
function warn(msg) {
|
|
180
182
|
if (msg instanceof Error) {
|
|
181
|
-
msg.message
|
|
183
|
+
if (!msg.message.startsWith(LOG_CATEGORY)) {
|
|
184
|
+
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
185
|
+
}
|
|
182
186
|
logger.warn(msg);
|
|
183
187
|
} else {
|
|
184
188
|
logger.warn(msg);
|
|
@@ -266,7 +270,7 @@ function getGlobalFederationConstructor() {
|
|
|
266
270
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
267
271
|
if (isDebug) {
|
|
268
272
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
269
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.17.
|
|
273
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.17.1";
|
|
270
274
|
}
|
|
271
275
|
}
|
|
272
276
|
function getInfoWithoutType(target, key) {
|
|
@@ -2003,10 +2003,10 @@ export {
|
|
|
2003
2003
|
getDataFetchItem as n,
|
|
2004
2004
|
DATA_FETCH_CLIENT_SUFFIX as o,
|
|
2005
2005
|
MF_DATA_FETCH_TYPE as p,
|
|
2006
|
-
|
|
2006
|
+
isCSROnly as q,
|
|
2007
2007
|
revalidateTag as r,
|
|
2008
2008
|
setSSREnv as s,
|
|
2009
|
-
|
|
2009
|
+
isServerEnv as t,
|
|
2010
2010
|
getDataFetchIdWithErrorMsgs as u,
|
|
2011
2011
|
DATA_FETCH_ERROR_PREFIX as v,
|
|
2012
2012
|
wrapDataFetchId as w,
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
displayName: 'bridge-react',
|
|
3
|
+
preset: '../../../jest.preset.js',
|
|
4
|
+
transform: {
|
|
5
|
+
'^.+\\.[tj]sx?$': [
|
|
6
|
+
'ts-jest',
|
|
7
|
+
{
|
|
8
|
+
tsconfig: '<rootDir>/tsconfig.spec.json',
|
|
9
|
+
isolatedModules: true,
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
14
|
+
coverageDirectory: '../../../coverage/packages/bridge/bridge-react',
|
|
15
|
+
testEnvironment: 'jsdom',
|
|
16
|
+
setupFilesAfterEnv: ['<rootDir>/__tests__/setupTests.ts'],
|
|
17
|
+
testMatch: [
|
|
18
|
+
'<rootDir>/__tests__/**/*.spec.ts',
|
|
19
|
+
'<rootDir>/__tests__/**/*.spec.tsx',
|
|
20
|
+
],
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/bridge-react",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
|
+
"sideEffects": false,
|
|
4
5
|
"publishConfig": {
|
|
5
6
|
"access": "public"
|
|
6
7
|
},
|
|
@@ -94,8 +95,8 @@
|
|
|
94
95
|
"dependencies": {
|
|
95
96
|
"react-error-boundary": "^4.1.2",
|
|
96
97
|
"lru-cache": "^10.4.3",
|
|
97
|
-
"@module-federation/bridge-shared": "0.17.
|
|
98
|
-
"@module-federation/sdk": "0.17.
|
|
98
|
+
"@module-federation/bridge-shared": "0.17.1",
|
|
99
|
+
"@module-federation/sdk": "0.17.1"
|
|
99
100
|
},
|
|
100
101
|
"peerDependencies": {
|
|
101
102
|
"react": ">=16.9.0",
|
|
@@ -110,7 +111,6 @@
|
|
|
110
111
|
"@vitejs/plugin-react": "^4.3.3",
|
|
111
112
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
112
113
|
"@vitejs/plugin-vue-jsx": "^4.0.0",
|
|
113
|
-
"jsdom": "^24.1.0",
|
|
114
114
|
"react": "18.3.1",
|
|
115
115
|
"react-dom": "18.3.1",
|
|
116
116
|
"react-router-dom": "6.22.3",
|
|
@@ -118,8 +118,8 @@
|
|
|
118
118
|
"vite": "^5.4.18",
|
|
119
119
|
"vite-plugin-dts": "^4.3.0",
|
|
120
120
|
"hono": "3.12.12",
|
|
121
|
-
"@module-federation/runtime": "0.17.
|
|
122
|
-
"@module-federation/runtime-core": "0.17.
|
|
121
|
+
"@module-federation/runtime": "0.17.1",
|
|
122
|
+
"@module-federation/runtime-core": "0.17.1"
|
|
123
123
|
},
|
|
124
124
|
"scripts": {
|
|
125
125
|
"dev": "vite",
|
package/project.json
CHANGED
|
@@ -12,15 +12,11 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"test": {
|
|
15
|
-
"executor": "nx:
|
|
15
|
+
"executor": "@nx/jest:jest",
|
|
16
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
16
17
|
"options": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
{
|
|
20
|
-
"command": "vitest run -c packages/bridge/bridge-react/vitest.config.ts",
|
|
21
|
-
"forwardAllArgs": false
|
|
22
|
-
}
|
|
23
|
-
]
|
|
18
|
+
"jestConfig": "packages/bridge/bridge-react/jest.config.ts",
|
|
19
|
+
"passWithNoTests": true
|
|
24
20
|
}
|
|
25
21
|
}
|
|
26
22
|
}
|
|
@@ -18,14 +18,14 @@ import {
|
|
|
18
18
|
} from '../constant';
|
|
19
19
|
|
|
20
20
|
import type { MF_DATA_FETCH_MAP_VALUE } from '../types';
|
|
21
|
-
import type {
|
|
21
|
+
import type { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
|
|
22
22
|
|
|
23
|
-
const autoFetchData: () =>
|
|
23
|
+
const autoFetchData: () => ModuleFederationRuntimePlugin = () => {
|
|
24
24
|
initDataFetchMap();
|
|
25
25
|
injectDataFetch();
|
|
26
26
|
return {
|
|
27
27
|
name: 'auto-fetch-data-plugin',
|
|
28
|
-
afterLoadSnapshot(args) {
|
|
28
|
+
afterLoadSnapshot(args: any) {
|
|
29
29
|
const { id, moduleInfo, remoteSnapshot, host } = args;
|
|
30
30
|
if (typeof id === 'string' && isDataLoaderExpose(id)) {
|
|
31
31
|
return args;
|
|
@@ -68,7 +68,7 @@ const autoFetchData: () => FederationRuntimePlugin = () => {
|
|
|
68
68
|
const hasSSRAsset = Boolean(remoteSnapshot.ssrRemoteEntry);
|
|
69
69
|
const hasDataFetchClient = Boolean(
|
|
70
70
|
remoteSnapshot.modules.find(
|
|
71
|
-
(module) =>
|
|
71
|
+
(module: any) =>
|
|
72
72
|
module.moduleName === `${dataFetchName}${DATA_FETCH_CLIENT_SUFFIX}`,
|
|
73
73
|
),
|
|
74
74
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ModuleFederation,
|
|
3
|
-
|
|
3
|
+
ModuleFederationRuntimePlugin,
|
|
4
4
|
} from '@module-federation/runtime';
|
|
5
5
|
import {
|
|
6
6
|
createLazyComponent,
|
|
@@ -24,7 +24,7 @@ declare module '@module-federation/runtime-core' {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function lazyLoadComponentPlugin():
|
|
27
|
+
export function lazyLoadComponentPlugin(): ModuleFederationRuntimePlugin {
|
|
28
28
|
return {
|
|
29
29
|
name: 'lazy-load-component-plugin',
|
|
30
30
|
apply(instance: ModuleFederation) {
|
package/src/remote/create.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
RemoteModule,
|
|
9
9
|
} from '../types';
|
|
10
10
|
|
|
11
|
-
type LazyRemoteComponentInfo<T,
|
|
11
|
+
type LazyRemoteComponentInfo<T, _E extends keyof T> = RemoteComponentParams<T>;
|
|
12
12
|
|
|
13
13
|
function createLazyRemoteComponent<
|
|
14
14
|
T = Record<string, unknown>,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../../dist/out-tsc",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"types": ["jest", "node", "@testing-library/jest-dom"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"noUnusedLocals": false,
|
|
9
|
+
"noUnusedParameters": false,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true
|
|
13
|
+
},
|
|
14
|
+
"include": [
|
|
15
|
+
"**/*.test.ts",
|
|
16
|
+
"**/*.test.tsx",
|
|
17
|
+
"**/*.test.js",
|
|
18
|
+
"**/*.test.jsx",
|
|
19
|
+
"**/*.spec.ts",
|
|
20
|
+
"**/*.spec.tsx",
|
|
21
|
+
"**/*.spec.js",
|
|
22
|
+
"**/*.spec.jsx",
|
|
23
|
+
"**/*.d.ts",
|
|
24
|
+
"__tests__/**/*"
|
|
25
|
+
]
|
|
26
|
+
}
|