@module-federation/modern-js 0.0.0-next-20250613153606 → 0.0.0-next-20250616091910
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/dist/cjs/cli/configPlugin.js +1 -1
- package/dist/cjs/cli/configPlugin.spec.js +2 -2
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +9 -10
- package/dist/cjs/constant.js +2 -49
- package/dist/cjs/runtime/index.js +3 -20
- package/dist/cjs/ssr-runtime/devPlugin.js +2 -2
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +6 -101
- package/dist/esm/cli/configPlugin.js +1 -1
- package/dist/esm/cli/configPlugin.spec.js +2 -2
- package/dist/esm/cli/server/data-fetch-server-plugin.js +3 -4
- package/dist/esm/constant.js +1 -37
- package/dist/esm/runtime/index.js +2 -18
- package/dist/esm/ssr-runtime/devPlugin.js +1 -1
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js +5 -147
- package/dist/esm-node/cli/configPlugin.js +1 -1
- package/dist/esm-node/cli/configPlugin.spec.js +2 -2
- package/dist/esm-node/cli/server/data-fetch-server-plugin.js +3 -4
- package/dist/esm-node/constant.js +1 -37
- package/dist/esm-node/runtime/index.js +2 -18
- package/dist/esm-node/ssr-runtime/devPlugin.js +1 -1
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.js +5 -89
- package/dist/types/constant.d.ts +0 -23
- package/dist/types/runtime/index.d.ts +2 -9
- package/dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts +0 -3
- package/package.json +9 -16
- package/dist/cjs/cli/mfRuntimePlugins/auto-fetch-data.js +0 -100
- package/dist/cjs/interfaces/global.js +0 -16
- package/dist/cjs/runtime/AwaitDataFetch.js +0 -144
- package/dist/cjs/runtime/createRemoteComponent.js +0 -327
- package/dist/cjs/runtime/wrapNoSSR.js +0 -35
- package/dist/cjs/ssr-runtime/downgrade.js +0 -114
- package/dist/cjs/utils/dataFetch.js +0 -211
- package/dist/cjs/utils/index.js +0 -54
- package/dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js +0 -76
- package/dist/esm/interfaces/global.js +0 -0
- package/dist/esm/runtime/AwaitDataFetch.js +0 -131
- package/dist/esm/runtime/createRemoteComponent.js +0 -417
- package/dist/esm/runtime/wrapNoSSR.js +0 -12
- package/dist/esm/ssr-runtime/downgrade.js +0 -150
- package/dist/esm/utils/dataFetch.js +0 -237
- package/dist/esm/utils/index.js +0 -28
- package/dist/esm-node/cli/mfRuntimePlugins/auto-fetch-data.js +0 -70
- package/dist/esm-node/interfaces/global.js +0 -0
- package/dist/esm-node/runtime/AwaitDataFetch.js +0 -109
- package/dist/esm-node/runtime/createRemoteComponent.js +0 -291
- package/dist/esm-node/runtime/wrapNoSSR.js +0 -11
- package/dist/esm-node/ssr-runtime/downgrade.js +0 -88
- package/dist/esm-node/utils/dataFetch.js +0 -166
- package/dist/esm-node/utils/index.js +0 -27
- package/dist/types/cli/mfRuntimePlugins/auto-fetch-data.d.ts +0 -3
- package/dist/types/interfaces/global.d.ts +0 -27
- package/dist/types/runtime/AwaitDataFetch.d.ts +0 -19
- package/dist/types/runtime/createRemoteComponent.d.ts +0 -26
- package/dist/types/runtime/wrapNoSSR.d.ts +0 -9
- package/dist/types/ssr-runtime/downgrade.d.ts +0 -4
- package/dist/types/utils/dataFetch.d.ts +0 -26
- package/dist/types/utils/index.d.ts +0 -15
|
@@ -38,7 +38,7 @@ describe("patchMFConfig", async () => {
|
|
|
38
38
|
remoteType: "script",
|
|
39
39
|
runtimePlugins: [
|
|
40
40
|
require.resolve("@module-federation/modern-js/shared-strategy"),
|
|
41
|
-
require.resolve("@module-federation/
|
|
41
|
+
require.resolve("@module-federation/bridge-react/data-fetch-runtime-plugin"),
|
|
42
42
|
require.resolve("@module-federation/node/runtimePlugin"),
|
|
43
43
|
require.resolve("@module-federation/modern-js/inject-node-fetch")
|
|
44
44
|
],
|
|
@@ -67,7 +67,7 @@ describe("patchMFConfig", async () => {
|
|
|
67
67
|
remoteType: "script",
|
|
68
68
|
runtimePlugins: [
|
|
69
69
|
require.resolve("@module-federation/modern-js/shared-strategy"),
|
|
70
|
-
require.resolve("@module-federation/
|
|
70
|
+
require.resolve("@module-federation/bridge-react/data-fetch-runtime-plugin")
|
|
71
71
|
],
|
|
72
72
|
shared: {
|
|
73
73
|
react: {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { DATA_FETCH_QUERY, MF_DATA_FETCH_STATUS } from "
|
|
2
|
-
import
|
|
3
|
-
import { getDataFetchMap } from "../../utils";
|
|
4
|
-
import { fetchData, initDataFetchMap, loadDataFetchModule } from "../../utils/dataFetch";
|
|
1
|
+
import { DATA_FETCH_QUERY, MF_DATA_FETCH_STATUS } from "@module-federation/bridge-react/data-fetch-constant";
|
|
2
|
+
import { getDataFetchMap, fetchData, initDataFetchMap, loadDataFetchModule } from "@module-federation/bridge-react/data-fetch-utils";
|
|
5
3
|
import { SEPARATOR, MANIFEST_EXT } from "@module-federation/sdk";
|
|
4
|
+
import logger from "../../logger";
|
|
6
5
|
function wrapSetTimeout(targetPromise, delay = 2e4, id) {
|
|
7
6
|
if (targetPromise && typeof targetPromise.then === "function") {
|
|
8
7
|
return new Promise((resolve, reject) => {
|
|
@@ -1,42 +1,6 @@
|
|
|
1
1
|
const LOCALHOST = "localhost";
|
|
2
2
|
const PLUGIN_IDENTIFIER = "[ Modern.js Module Federation ]";
|
|
3
|
-
const DATA_FETCH_QUERY = "x-mf-data-fetch";
|
|
4
|
-
const DATA_FETCH_ERROR_PREFIX = "caught the following error during dataFetch: ";
|
|
5
|
-
const LOAD_REMOTE_ERROR_PREFIX = "caught the following error during loadRemote: ";
|
|
6
|
-
const DOWNGRADE_KEY = "_mfSSRDowngrade";
|
|
7
|
-
const DATA_FETCH_MAP_KEY = "__MF_DATA_FETCH_MAP__";
|
|
8
|
-
const DATA_FETCH_FUNCTION = "_mfDataFetch";
|
|
9
|
-
const FS_HREF = "_mfFSHref";
|
|
10
|
-
const ERROR_TYPE = {
|
|
11
|
-
DATA_FETCH: 1,
|
|
12
|
-
LOAD_REMOTE: 2,
|
|
13
|
-
UNKNOWN: 3
|
|
14
|
-
};
|
|
15
|
-
const WRAP_DATA_FETCH_ID_IDENTIFIER = "wrap_dfip_identifier";
|
|
16
|
-
var MF_DATA_FETCH_TYPE;
|
|
17
|
-
(function(MF_DATA_FETCH_TYPE2) {
|
|
18
|
-
MF_DATA_FETCH_TYPE2[MF_DATA_FETCH_TYPE2["FETCH_SERVER"] = 1] = "FETCH_SERVER";
|
|
19
|
-
MF_DATA_FETCH_TYPE2[MF_DATA_FETCH_TYPE2["FETCH_CLIENT"] = 2] = "FETCH_CLIENT";
|
|
20
|
-
})(MF_DATA_FETCH_TYPE || (MF_DATA_FETCH_TYPE = {}));
|
|
21
|
-
var MF_DATA_FETCH_STATUS;
|
|
22
|
-
(function(MF_DATA_FETCH_STATUS2) {
|
|
23
|
-
MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["LOADED"] = 1] = "LOADED";
|
|
24
|
-
MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["LOADING"] = 2] = "LOADING";
|
|
25
|
-
MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["AWAIT"] = 0] = "AWAIT";
|
|
26
|
-
MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["ERROR"] = 3] = "ERROR";
|
|
27
|
-
})(MF_DATA_FETCH_STATUS || (MF_DATA_FETCH_STATUS = {}));
|
|
28
3
|
export {
|
|
29
|
-
DATA_FETCH_ERROR_PREFIX,
|
|
30
|
-
DATA_FETCH_FUNCTION,
|
|
31
|
-
DATA_FETCH_MAP_KEY,
|
|
32
|
-
DATA_FETCH_QUERY,
|
|
33
|
-
DOWNGRADE_KEY,
|
|
34
|
-
ERROR_TYPE,
|
|
35
|
-
FS_HREF,
|
|
36
|
-
LOAD_REMOTE_ERROR_PREFIX,
|
|
37
4
|
LOCALHOST,
|
|
38
|
-
|
|
39
|
-
MF_DATA_FETCH_TYPE,
|
|
40
|
-
PLUGIN_IDENTIFIER,
|
|
41
|
-
WRAP_DATA_FETCH_ID_IDENTIFIER
|
|
5
|
+
PLUGIN_IDENTIFIER
|
|
42
6
|
};
|
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
export * from "@module-federation/enhanced/runtime";
|
|
2
|
-
import { ERROR_TYPE } from "
|
|
3
|
-
const kit = {
|
|
4
|
-
get createRemoteSSRComponent() {
|
|
5
|
-
return require("./createRemoteComponent").createRemoteSSRComponent;
|
|
6
|
-
},
|
|
7
|
-
get createRemoteComponent() {
|
|
8
|
-
return require("./createRemoteComponent").createRemoteComponent;
|
|
9
|
-
},
|
|
10
|
-
get collectSSRAssets() {
|
|
11
|
-
return require("./createRemoteComponent").collectSSRAssets;
|
|
12
|
-
},
|
|
13
|
-
get wrapNoSSR() {
|
|
14
|
-
return require("./wrapNoSSR").wrapNoSSR;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
import { setSSREnv } from "../ssr-runtime/injectDataFetchFunctionPlugin";
|
|
2
|
+
import { kit, ERROR_TYPE } from "@module-federation/bridge-react";
|
|
18
3
|
export {
|
|
19
4
|
ERROR_TYPE,
|
|
20
|
-
kit
|
|
21
|
-
setSSREnv
|
|
5
|
+
kit
|
|
22
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { SSRLiveReload } from "./SSRLiveReload";
|
|
3
|
-
import { flushDataFetch } from "
|
|
3
|
+
import { flushDataFetch } from "@module-federation/bridge-react/data-fetch-utils";
|
|
4
4
|
const mfSSRDevPlugin = () => ({
|
|
5
5
|
name: "@module-federation/modern-js",
|
|
6
6
|
setup: (api) => {
|
|
@@ -1,101 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { getDataFetchMap, getDataFetchItem, initDataFetchMap } from "../utils";
|
|
4
|
-
import { callAllDowngrade, callDowngrade, getDowngradeTag } from "./downgrade";
|
|
5
|
-
function setSSREnv({ fetchServerQuery }) {
|
|
6
|
-
globalThis.FEDERATION_SSR = true;
|
|
7
|
-
globalThis.FEDERATION_SERVER_QUERY = fetchServerQuery;
|
|
8
|
-
}
|
|
1
|
+
import { kit } from "@module-federation/bridge-react";
|
|
2
|
+
const { callDataFetch, injectDataFetch, setSSREnv } = kit;
|
|
9
3
|
const injectDataFetchFunctionPlugin = ({ fetchServerQuery }) => ({
|
|
10
4
|
name: "@module-federation/inject-data-fetch-function-plugin",
|
|
11
5
|
setup: (api) => {
|
|
12
6
|
api.onBeforeRender(async () => {
|
|
13
|
-
var _globalThis, _DATA_FETCH_FUNCTION;
|
|
14
7
|
setSSREnv({
|
|
15
8
|
fetchServerQuery
|
|
16
9
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
const dataFetchFunction = async function(options) {
|
|
21
|
-
const [id, data, downgrade] = options;
|
|
22
|
-
logger.debug("==========call data fetch function!");
|
|
23
|
-
if (data) {
|
|
24
|
-
if (!id) {
|
|
25
|
-
throw new Error("id is required!");
|
|
26
|
-
}
|
|
27
|
-
if (!getDataFetchMap()) {
|
|
28
|
-
initDataFetchMap();
|
|
29
|
-
}
|
|
30
|
-
const dataFetchItem = getDataFetchItem(id);
|
|
31
|
-
if (dataFetchItem) {
|
|
32
|
-
var _dataFetchItem__, _dataFetchItem_;
|
|
33
|
-
(_dataFetchItem_ = dataFetchItem[1]) === null || _dataFetchItem_ === void 0 ? void 0 : (_dataFetchItem__ = _dataFetchItem_[1]) === null || _dataFetchItem__ === void 0 ? void 0 : _dataFetchItem__.call(_dataFetchItem_, data);
|
|
34
|
-
dataFetchItem[2] = MF_DATA_FETCH_STATUS.LOADED;
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (!dataFetchItem) {
|
|
38
|
-
const dataFetchMap = getDataFetchMap();
|
|
39
|
-
let res;
|
|
40
|
-
let rej;
|
|
41
|
-
const p = new Promise((resolve, reject) => {
|
|
42
|
-
res = resolve;
|
|
43
|
-
rej = reject;
|
|
44
|
-
});
|
|
45
|
-
dataFetchMap[id] = [
|
|
46
|
-
[
|
|
47
|
-
async () => async () => {
|
|
48
|
-
return "";
|
|
49
|
-
},
|
|
50
|
-
MF_DATA_FETCH_TYPE.FETCH_SERVER
|
|
51
|
-
],
|
|
52
|
-
[
|
|
53
|
-
p,
|
|
54
|
-
res,
|
|
55
|
-
rej
|
|
56
|
-
],
|
|
57
|
-
MF_DATA_FETCH_STATUS.LOADED
|
|
58
|
-
];
|
|
59
|
-
res(data);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (downgrade) {
|
|
64
|
-
const mfDowngrade2 = getDowngradeTag();
|
|
65
|
-
if (!mfDowngrade2) {
|
|
66
|
-
globalThis[DOWNGRADE_KEY] = id ? [
|
|
67
|
-
id
|
|
68
|
-
] : true;
|
|
69
|
-
} else if (Array.isArray(mfDowngrade2) && id && !mfDowngrade2.includes(id)) {
|
|
70
|
-
mfDowngrade2.push(id);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const mfDowngrade = getDowngradeTag();
|
|
74
|
-
if (typeof mfDowngrade === "boolean") {
|
|
75
|
-
return callAllDowngrade();
|
|
76
|
-
}
|
|
77
|
-
if (Array.isArray(mfDowngrade)) {
|
|
78
|
-
if (!id) {
|
|
79
|
-
globalThis[DOWNGRADE_KEY] = true;
|
|
80
|
-
return callAllDowngrade();
|
|
81
|
-
}
|
|
82
|
-
if (!mfDowngrade.includes(id)) {
|
|
83
|
-
mfDowngrade.push(id);
|
|
84
|
-
}
|
|
85
|
-
return callDowngrade(id);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
globalThis[FS_HREF] = window.location.href;
|
|
89
|
-
(_globalThis = globalThis)[_DATA_FETCH_FUNCTION = DATA_FETCH_FUNCTION] || (_globalThis[_DATA_FETCH_FUNCTION] = []);
|
|
90
|
-
const dataFetch = globalThis[DATA_FETCH_FUNCTION];
|
|
91
|
-
await Promise.all(dataFetch.map(async (options) => {
|
|
92
|
-
await dataFetchFunction(options);
|
|
93
|
-
}));
|
|
94
|
-
dataFetch.push = dataFetchFunction;
|
|
10
|
+
injectDataFetch();
|
|
11
|
+
await callDataFetch();
|
|
95
12
|
});
|
|
96
13
|
}
|
|
97
14
|
});
|
|
98
15
|
export {
|
|
99
|
-
injectDataFetchFunctionPlugin
|
|
100
|
-
setSSREnv
|
|
16
|
+
injectDataFetchFunctionPlugin
|
|
101
17
|
};
|
package/dist/types/constant.d.ts
CHANGED
|
@@ -1,25 +1,2 @@
|
|
|
1
1
|
export declare const LOCALHOST = "localhost";
|
|
2
2
|
export declare const PLUGIN_IDENTIFIER = "[ Modern.js Module Federation ]";
|
|
3
|
-
export declare const DATA_FETCH_QUERY = "x-mf-data-fetch";
|
|
4
|
-
export declare const DATA_FETCH_ERROR_PREFIX = "caught the following error during dataFetch: ";
|
|
5
|
-
export declare const LOAD_REMOTE_ERROR_PREFIX = "caught the following error during loadRemote: ";
|
|
6
|
-
export declare const DOWNGRADE_KEY = "_mfSSRDowngrade";
|
|
7
|
-
export declare const DATA_FETCH_MAP_KEY = "__MF_DATA_FETCH_MAP__";
|
|
8
|
-
export declare const DATA_FETCH_FUNCTION = "_mfDataFetch";
|
|
9
|
-
export declare const FS_HREF = "_mfFSHref";
|
|
10
|
-
export declare const ERROR_TYPE: {
|
|
11
|
-
DATA_FETCH: number;
|
|
12
|
-
LOAD_REMOTE: number;
|
|
13
|
-
UNKNOWN: number;
|
|
14
|
-
};
|
|
15
|
-
export declare const WRAP_DATA_FETCH_ID_IDENTIFIER = "wrap_dfip_identifier";
|
|
16
|
-
export declare const enum MF_DATA_FETCH_TYPE {
|
|
17
|
-
FETCH_SERVER = 1,
|
|
18
|
-
FETCH_CLIENT = 2
|
|
19
|
-
}
|
|
20
|
-
export declare const enum MF_DATA_FETCH_STATUS {
|
|
21
|
-
LOADED = 1,
|
|
22
|
-
LOADING = 2,
|
|
23
|
-
AWAIT = 0,
|
|
24
|
-
ERROR = 3
|
|
25
|
-
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
export * from '@module-federation/enhanced/runtime';
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
4
|
-
export declare const kit: {
|
|
5
|
-
readonly createRemoteSSRComponent: typeof import("./createRemoteComponent").createRemoteSSRComponent;
|
|
6
|
-
readonly createRemoteComponent: typeof import("./createRemoteComponent").createRemoteComponent;
|
|
7
|
-
readonly collectSSRAssets: typeof import("./createRemoteComponent").collectSSRAssets;
|
|
8
|
-
readonly wrapNoSSR: typeof import("./wrapNoSSR").wrapNoSSR;
|
|
9
|
-
};
|
|
10
|
-
export { setSSREnv } from '../ssr-runtime/injectDataFetchFunctionPlugin';
|
|
2
|
+
export { kit, ERROR_TYPE } from '@module-federation/bridge-react';
|
|
3
|
+
export type { DataFetchParams } from '@module-federation/bridge-react';
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { RuntimePluginFuture } from '@modern-js/runtime';
|
|
2
|
-
export declare function setSSREnv({ fetchServerQuery, }: {
|
|
3
|
-
fetchServerQuery?: Record<string, unknown>;
|
|
4
|
-
}): void;
|
|
5
2
|
export declare const injectDataFetchFunctionPlugin: ({ fetchServerQuery, }: {
|
|
6
3
|
fetchServerQuery?: Record<string, unknown>;
|
|
7
4
|
}) => RuntimePluginFuture;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/modern-js",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20250616091910",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -52,11 +52,6 @@
|
|
|
52
52
|
"import": "./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js",
|
|
53
53
|
"require": "./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js"
|
|
54
54
|
},
|
|
55
|
-
"./auto-fetch-data": {
|
|
56
|
-
"types": "./dist/types/cli/mfRuntimePlugins/auto-fetch-data.d.ts",
|
|
57
|
-
"import": "./dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js",
|
|
58
|
-
"require": "./dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js"
|
|
59
|
-
},
|
|
60
55
|
"./inject-node-fetch": {
|
|
61
56
|
"types": "./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts",
|
|
62
57
|
"import": "./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js",
|
|
@@ -91,9 +86,6 @@
|
|
|
91
86
|
"resolve-entry-ipv4": [
|
|
92
87
|
"./dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts"
|
|
93
88
|
],
|
|
94
|
-
"auto-fetch-data": [
|
|
95
|
-
"./dist/types/cli/mfRuntimePlugins/auto-fetch-data.d.ts"
|
|
96
|
-
],
|
|
97
89
|
"inject-node-fetch": [
|
|
98
90
|
"./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts"
|
|
99
91
|
],
|
|
@@ -120,12 +112,13 @@
|
|
|
120
112
|
"@swc/helpers": "^0.5.17",
|
|
121
113
|
"node-fetch": "~3.3.0",
|
|
122
114
|
"react-error-boundary": "4.1.2",
|
|
123
|
-
"@module-federation/rsbuild-plugin": "0.0.0-next-
|
|
124
|
-
"@module-federation/
|
|
125
|
-
"@module-federation/
|
|
126
|
-
"@module-federation/
|
|
127
|
-
"@module-federation/
|
|
128
|
-
"@module-federation/
|
|
115
|
+
"@module-federation/rsbuild-plugin": "0.0.0-next-20250616091910",
|
|
116
|
+
"@module-federation/bridge-react": "0.0.0-next-20250616091910",
|
|
117
|
+
"@module-federation/enhanced": "0.0.0-next-20250616091910",
|
|
118
|
+
"@module-federation/runtime": "0.0.0-next-20250616091910",
|
|
119
|
+
"@module-federation/node": "0.0.0-next-20250616091910",
|
|
120
|
+
"@module-federation/sdk": "0.0.0-next-20250616091910",
|
|
121
|
+
"@module-federation/cli": "0.0.0-next-20250616091910"
|
|
129
122
|
},
|
|
130
123
|
"devDependencies": {
|
|
131
124
|
"@modern-js/core": "2.67.5",
|
|
@@ -135,7 +128,7 @@
|
|
|
135
128
|
"@modern-js/module-tools": "2.67.6",
|
|
136
129
|
"@modern-js/runtime": "2.67.6",
|
|
137
130
|
"@modern-js/tsconfig": "2.67.6",
|
|
138
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
131
|
+
"@module-federation/manifest": "0.0.0-next-20250616091910"
|
|
139
132
|
},
|
|
140
133
|
"peerDependencies": {
|
|
141
134
|
"react": ">=17",
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var auto_fetch_data_exports = {};
|
|
30
|
-
__export(auto_fetch_data_exports, {
|
|
31
|
-
default: () => auto_fetch_data_default
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(auto_fetch_data_exports);
|
|
34
|
-
var import_utils = require("../../utils");
|
|
35
|
-
var import_logger = __toESM(require("../../logger"));
|
|
36
|
-
var import_dataFetch = require("../../utils/dataFetch");
|
|
37
|
-
var import_constant = require("../../constant");
|
|
38
|
-
var import_constant2 = require("@module-federation/rsbuild-plugin/constant");
|
|
39
|
-
const autoFetchData = () => ({
|
|
40
|
-
name: "auto-fetch-data-plugin",
|
|
41
|
-
beforeInit(args) {
|
|
42
|
-
(0, import_utils.initDataFetchMap)();
|
|
43
|
-
return args;
|
|
44
|
-
},
|
|
45
|
-
afterLoadSnapshot(args) {
|
|
46
|
-
const { id, moduleInfo, remoteSnapshot, host } = args;
|
|
47
|
-
if (typeof id === "string" && (0, import_dataFetch.isDataLoaderExpose)(id)) {
|
|
48
|
-
return args;
|
|
49
|
-
}
|
|
50
|
-
if (!remoteSnapshot || !id || !("modules" in remoteSnapshot)) {
|
|
51
|
-
return args;
|
|
52
|
-
}
|
|
53
|
-
const { name, alias } = moduleInfo;
|
|
54
|
-
const dataFetchInfo = (0, import_utils.getDataFetchInfo)({
|
|
55
|
-
name,
|
|
56
|
-
alias,
|
|
57
|
-
id,
|
|
58
|
-
remoteSnapshot
|
|
59
|
-
});
|
|
60
|
-
if (!dataFetchInfo) {
|
|
61
|
-
return args;
|
|
62
|
-
}
|
|
63
|
-
const { dataFetchId, dataFetchName } = dataFetchInfo;
|
|
64
|
-
const dataFetchMapKey = (0, import_dataFetch.getDataFetchMapKey)(dataFetchInfo, {
|
|
65
|
-
name: host.name,
|
|
66
|
-
version: host.options.version
|
|
67
|
-
});
|
|
68
|
-
import_logger.default.debug("======= auto fetch plugin dataFetchMapKey: ", dataFetchMapKey);
|
|
69
|
-
if (!dataFetchMapKey) {
|
|
70
|
-
return args;
|
|
71
|
-
}
|
|
72
|
-
const dataFetchItem = (0, import_utils.getDataFetchItem)(dataFetchMapKey);
|
|
73
|
-
if (dataFetchItem) {
|
|
74
|
-
return args;
|
|
75
|
-
}
|
|
76
|
-
const dataFetchMap = (0, import_utils.getDataFetchMap)();
|
|
77
|
-
const hasSSRAsset = Boolean(remoteSnapshot.ssrRemoteEntry);
|
|
78
|
-
const hasDataFetchClient = Boolean(remoteSnapshot.modules.find((module2) => module2.moduleName === `${dataFetchName}${import_constant2.DATA_FETCH_CLIENT_SUFFIX}`));
|
|
79
|
-
const downgradeType = hasDataFetchClient ? import_constant.MF_DATA_FETCH_TYPE.FETCH_CLIENT : hasSSRAsset ? import_constant.MF_DATA_FETCH_TYPE.FETCH_SERVER : import_constant.MF_DATA_FETCH_TYPE.FETCH_CLIENT;
|
|
80
|
-
let finalDataFetchId = dataFetchId;
|
|
81
|
-
if (typeof window !== "undefined") {
|
|
82
|
-
finalDataFetchId = downgradeType === import_constant.MF_DATA_FETCH_TYPE.FETCH_CLIENT ? hasDataFetchClient ? `${dataFetchId}${import_constant2.DATA_FETCH_CLIENT_SUFFIX}` : dataFetchId : dataFetchId;
|
|
83
|
-
}
|
|
84
|
-
const getDataFetchGetter = () => (0, import_dataFetch.loadDataFetchModule)(host, finalDataFetchId);
|
|
85
|
-
const dataFetchFnItem = [
|
|
86
|
-
getDataFetchGetter,
|
|
87
|
-
downgradeType
|
|
88
|
-
];
|
|
89
|
-
if (typeof window === "undefined" || (0, import_utils.isCSROnly)()) {
|
|
90
|
-
dataFetchFnItem.push(getDataFetchGetter());
|
|
91
|
-
}
|
|
92
|
-
dataFetchMap[dataFetchMapKey] = [
|
|
93
|
-
dataFetchFnItem,
|
|
94
|
-
void 0,
|
|
95
|
-
import_constant.MF_DATA_FETCH_STATUS.AWAIT
|
|
96
|
-
];
|
|
97
|
-
return args;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
var auto_fetch_data_default = autoFetchData;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var global_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(global_exports);
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var AwaitDataFetch_exports = {};
|
|
30
|
-
__export(AwaitDataFetch_exports, {
|
|
31
|
-
AwaitDataFetch: () => AwaitDataFetch,
|
|
32
|
-
transformError: () => transformError
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(AwaitDataFetch_exports);
|
|
35
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
-
var import_react = require("react");
|
|
37
|
-
var import_logger = __toESM(require("../logger"));
|
|
38
|
-
var import_constant = require("../constant");
|
|
39
|
-
var import_utils = require("../utils");
|
|
40
|
-
function isPromise(obj) {
|
|
41
|
-
return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
|
|
42
|
-
}
|
|
43
|
-
const AWAIT_ERROR_PREFIX = "<Await /> caught the following error during render: ";
|
|
44
|
-
const transformError = (err) => {
|
|
45
|
-
const errMsg = err instanceof Error ? err.message : err;
|
|
46
|
-
const originalMsg = errMsg.replace(AWAIT_ERROR_PREFIX, "");
|
|
47
|
-
const dataFetchMapKey = (0, import_utils.getDataFetchIdWithErrorMsgs)(originalMsg);
|
|
48
|
-
if (originalMsg.indexOf(import_constant.DATA_FETCH_ERROR_PREFIX) === 0) {
|
|
49
|
-
return {
|
|
50
|
-
error: new Error(originalMsg.replace(import_constant.DATA_FETCH_ERROR_PREFIX, "").replace((0, import_utils.wrapDataFetchId)(dataFetchMapKey), "")),
|
|
51
|
-
errorType: import_constant.ERROR_TYPE.DATA_FETCH,
|
|
52
|
-
dataFetchMapKey
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (originalMsg.indexOf(import_constant.LOAD_REMOTE_ERROR_PREFIX) === 0) {
|
|
56
|
-
return {
|
|
57
|
-
error: new Error(originalMsg.replace(import_constant.LOAD_REMOTE_ERROR_PREFIX, "").replace((0, import_utils.wrapDataFetchId)(dataFetchMapKey), "")),
|
|
58
|
-
errorType: import_constant.ERROR_TYPE.LOAD_REMOTE,
|
|
59
|
-
dataFetchMapKey
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
error: new Error(originalMsg.replace((0, import_utils.wrapDataFetchId)(dataFetchMapKey), "")),
|
|
64
|
-
errorType: import_constant.ERROR_TYPE.UNKNOWN,
|
|
65
|
-
dataFetchMapKey
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
const DefaultLoading = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
|
|
69
|
-
const DefaultErrorElement = (_data) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
70
|
-
children: "Error"
|
|
71
|
-
});
|
|
72
|
-
function AwaitDataFetch({ resolve, loading = DefaultLoading, errorElement = DefaultErrorElement, children, params }) {
|
|
73
|
-
const dataRef = (0, import_react.useRef)();
|
|
74
|
-
const data = dataRef.current || resolve;
|
|
75
|
-
const getData = isPromise(data) ? fetchData(data, dataRef) : () => data;
|
|
76
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AwaitSuspense, {
|
|
77
|
-
params,
|
|
78
|
-
loading,
|
|
79
|
-
errorElement,
|
|
80
|
-
// @ts-ignore
|
|
81
|
-
resolve: getData,
|
|
82
|
-
children
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
function AwaitSuspense({ resolve, children, loading = DefaultLoading, errorElement = DefaultErrorElement }) {
|
|
86
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, {
|
|
87
|
-
fallback: loading,
|
|
88
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResolveAwait, {
|
|
89
|
-
resolve,
|
|
90
|
-
errorElement,
|
|
91
|
-
children
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
function ResolveAwait({ children, resolve, errorElement, params }) {
|
|
96
|
-
const data = resolve();
|
|
97
|
-
import_logger.default.debug("resolve data: ", data);
|
|
98
|
-
if (typeof data === "string" && data.indexOf(AWAIT_ERROR_PREFIX) === 0) {
|
|
99
|
-
const transformedError = transformError(data);
|
|
100
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
101
|
-
children: typeof errorElement === "function" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
102
|
-
children: [
|
|
103
|
-
globalThis.FEDERATION_SSR && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("script", {
|
|
104
|
-
suppressHydrationWarning: true,
|
|
105
|
-
dangerouslySetInnerHTML: {
|
|
106
|
-
__html: String.raw`
|
|
107
|
-
globalThis['${import_constant.DATA_FETCH_FUNCTION}'] = globalThis['${import_constant.DATA_FETCH_FUNCTION}'] || []
|
|
108
|
-
globalThis['${import_constant.DATA_FETCH_FUNCTION}'].push([${transformedError.dataFetchMapKey ? `'${transformedError.dataFetchMapKey}'` : ""},${params ? JSON.stringify(params) : null},true]);`
|
|
109
|
-
}
|
|
110
|
-
}),
|
|
111
|
-
errorElement(transformedError)
|
|
112
|
-
]
|
|
113
|
-
}) : errorElement
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
const toRender = typeof children === "function" ? children(data) : children;
|
|
117
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
118
|
-
children: toRender
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
const fetchData = (promise, ref) => {
|
|
122
|
-
let data;
|
|
123
|
-
let status = "pending";
|
|
124
|
-
const suspender = promise.then((res) => {
|
|
125
|
-
status = "success";
|
|
126
|
-
data = res;
|
|
127
|
-
ref.current = res;
|
|
128
|
-
}).catch((e) => {
|
|
129
|
-
status = "success";
|
|
130
|
-
console.warn(e);
|
|
131
|
-
data = AWAIT_ERROR_PREFIX + e;
|
|
132
|
-
});
|
|
133
|
-
return () => {
|
|
134
|
-
if (status === "pending") {
|
|
135
|
-
throw suspender;
|
|
136
|
-
}
|
|
137
|
-
return data;
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
141
|
-
0 && (module.exports = {
|
|
142
|
-
AwaitDataFetch,
|
|
143
|
-
transformError
|
|
144
|
-
});
|