@module-federation/modern-js 0.0.0-next-20250523091841 → 0.0.0-next-20250523110447
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/server/data-fetch-server-plugin.js +4 -4
- package/dist/cjs/ssr-runtime/downgrade.js +1 -1
- package/dist/esm/cli/server/data-fetch-server-plugin.js +12 -16
- package/dist/esm/ssr-runtime/downgrade.js +1 -1
- package/dist/esm-node/cli/server/data-fetch-server-plugin.js +5 -5
- package/dist/esm-node/ssr-runtime/downgrade.js +1 -1
- package/package.json +8 -8
|
@@ -84,15 +84,16 @@ const middleware = async (ctx, next) => {
|
|
|
84
84
|
if (!dataFetchId) {
|
|
85
85
|
return next();
|
|
86
86
|
}
|
|
87
|
-
import_logger.default.
|
|
87
|
+
import_logger.default.log("fetch data from server, dataFetchId: ", dataFetchId);
|
|
88
88
|
try {
|
|
89
|
-
var _dataFetchMap_dataFetchId;
|
|
89
|
+
var _dataFetchMap_dataFetchId, _dataFetchMap_dataFetchId1;
|
|
90
90
|
const dataFetchMap = (0, import_utils.getDataFetchMap)();
|
|
91
91
|
if (!dataFetchMap) {
|
|
92
92
|
(0, import_dataFetch.initDataFetchMap)();
|
|
93
93
|
}
|
|
94
94
|
const fetchDataPromise = (_dataFetchMap_dataFetchId = dataFetchMap[dataFetchId]) === null || _dataFetchMap_dataFetchId === void 0 ? void 0 : _dataFetchMap_dataFetchId[1];
|
|
95
|
-
if (fetchDataPromise) {
|
|
95
|
+
if (fetchDataPromise && ((_dataFetchMap_dataFetchId1 = dataFetchMap[dataFetchId]) === null || _dataFetchMap_dataFetchId1 === void 0 ? void 0 : _dataFetchMap_dataFetchId1[2]) !== import_constant.MF_DATA_FETCH_STATUS.ERROR) {
|
|
96
|
+
import_logger.default.log("fetch data from server, fetchDataPromise: ", fetchDataPromise);
|
|
96
97
|
const targetPromise = fetchDataPromise[0];
|
|
97
98
|
const wrappedPromise = wrapSetTimeout(targetPromise, 2e4, dataFetchId);
|
|
98
99
|
if (wrappedPromise) {
|
|
@@ -147,7 +148,6 @@ const middleware = async (ctx, next) => {
|
|
|
147
148
|
const res = await wrappedPromise;
|
|
148
149
|
return ctx.json(res);
|
|
149
150
|
}
|
|
150
|
-
return next();
|
|
151
151
|
}
|
|
152
152
|
const remoteId = dataFetchId.split(import_sdk.SEPARATOR)[0];
|
|
153
153
|
const hostInstance = globalThis.__FEDERATION__.__INSTANCES__[0];
|
|
@@ -44,7 +44,7 @@ async function callDowngrade(id, params, remoteInfo) {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
const mfDataFetch = dataFetchMap[id];
|
|
47
|
-
if (mfDataFetch[2] === import_constant2.MF_DATA_FETCH_STATUS.AWAIT) {
|
|
47
|
+
if ((mfDataFetch === null || mfDataFetch === void 0 ? void 0 : mfDataFetch[2]) === import_constant2.MF_DATA_FETCH_STATUS.AWAIT) {
|
|
48
48
|
mfDataFetch[2] = import_constant2.MF_DATA_FETCH_STATUS.LOADING;
|
|
49
49
|
let promise, res, rej;
|
|
50
50
|
if (mfDataFetch[1]) {
|
|
@@ -2,7 +2,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
|
2
2
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
|
-
import { DATA_FETCH_QUERY } from "../../constant";
|
|
5
|
+
import { DATA_FETCH_QUERY, MF_DATA_FETCH_STATUS } from "../../constant";
|
|
6
6
|
import logger from "../../logger";
|
|
7
7
|
import { getDataFetchMap } from "../../utils";
|
|
8
8
|
import { fetchData, initDataFetchMap, loadDataFetchModule } from "../../utils/dataFetch";
|
|
@@ -40,7 +40,7 @@ var getDecodeQuery = function(url, name) {
|
|
|
40
40
|
};
|
|
41
41
|
var middleware = function() {
|
|
42
42
|
var _ref = _async_to_generator(function(ctx, next) {
|
|
43
|
-
var url, dataFetchId, params, remoteInfo, remoteInfoQuery, _dataFetchMap_dataFetchId, dataFetchMap, fetchDataPromise, targetPromise, wrappedPromise, res, hostInstance, remoteEntry, remote, _hostInstance_snapshotHandler_getGlobalRemoteInfo, hostGlobalSnapshot, remoteSnapshot, dataFetchItem, callFetchDataPromise, wrappedPromise1, res1, remoteId, hostInstance1, dataFetchFn, data, e;
|
|
43
|
+
var url, dataFetchId, params, remoteInfo, remoteInfoQuery, _dataFetchMap_dataFetchId, _dataFetchMap_dataFetchId1, dataFetchMap, fetchDataPromise, targetPromise, wrappedPromise, res, hostInstance, remoteEntry, remote, _hostInstance_snapshotHandler_getGlobalRemoteInfo, hostGlobalSnapshot, remoteSnapshot, dataFetchItem, callFetchDataPromise, wrappedPromise1, res1, remoteId, hostInstance1, dataFetchFn, data, e;
|
|
44
44
|
return _ts_generator(this, function(_state) {
|
|
45
45
|
switch (_state.label) {
|
|
46
46
|
case 0:
|
|
@@ -63,25 +63,26 @@ var middleware = function() {
|
|
|
63
63
|
next()
|
|
64
64
|
];
|
|
65
65
|
}
|
|
66
|
-
logger.
|
|
66
|
+
logger.log("fetch data from server, dataFetchId: ", dataFetchId);
|
|
67
67
|
_state.label = 1;
|
|
68
68
|
case 1:
|
|
69
69
|
_state.trys.push([
|
|
70
70
|
1,
|
|
71
|
-
|
|
71
|
+
9,
|
|
72
72
|
,
|
|
73
|
-
|
|
73
|
+
10
|
|
74
74
|
]);
|
|
75
75
|
dataFetchMap = getDataFetchMap();
|
|
76
76
|
if (!dataFetchMap) {
|
|
77
77
|
initDataFetchMap();
|
|
78
78
|
}
|
|
79
79
|
fetchDataPromise = (_dataFetchMap_dataFetchId = dataFetchMap[dataFetchId]) === null || _dataFetchMap_dataFetchId === void 0 ? void 0 : _dataFetchMap_dataFetchId[1];
|
|
80
|
-
if (!fetchDataPromise)
|
|
80
|
+
if (!(fetchDataPromise && ((_dataFetchMap_dataFetchId1 = dataFetchMap[dataFetchId]) === null || _dataFetchMap_dataFetchId1 === void 0 ? void 0 : _dataFetchMap_dataFetchId1[2]) !== MF_DATA_FETCH_STATUS.ERROR))
|
|
81
81
|
return [
|
|
82
82
|
3,
|
|
83
83
|
4
|
|
84
84
|
];
|
|
85
|
+
logger.log("fetch data from server, fetchDataPromise: ", fetchDataPromise);
|
|
85
86
|
targetPromise = fetchDataPromise[0];
|
|
86
87
|
wrappedPromise = wrapSetTimeout(targetPromise, 2e4, dataFetchId);
|
|
87
88
|
if (!wrappedPromise)
|
|
@@ -146,7 +147,7 @@ var middleware = function() {
|
|
|
146
147
|
if (!dataFetchItem)
|
|
147
148
|
return [
|
|
148
149
|
3,
|
|
149
|
-
|
|
150
|
+
6
|
|
150
151
|
];
|
|
151
152
|
callFetchDataPromise = fetchData(dataFetchId, _object_spread_props(_object_spread({}, params), {
|
|
152
153
|
isDowngrade: true
|
|
@@ -168,11 +169,6 @@ var middleware = function() {
|
|
|
168
169
|
ctx.json(res1)
|
|
169
170
|
];
|
|
170
171
|
case 6:
|
|
171
|
-
return [
|
|
172
|
-
2,
|
|
173
|
-
next()
|
|
174
|
-
];
|
|
175
|
-
case 7:
|
|
176
172
|
remoteId = dataFetchId.split(SEPARATOR)[0];
|
|
177
173
|
hostInstance1 = globalThis.__FEDERATION__.__INSTANCES__[0];
|
|
178
174
|
if (!hostInstance1) {
|
|
@@ -182,7 +178,7 @@ var middleware = function() {
|
|
|
182
178
|
4,
|
|
183
179
|
loadDataFetchModule(hostInstance1, remoteId)
|
|
184
180
|
];
|
|
185
|
-
case
|
|
181
|
+
case 7:
|
|
186
182
|
dataFetchFn = _state.sent();
|
|
187
183
|
return [
|
|
188
184
|
4,
|
|
@@ -190,13 +186,13 @@ var middleware = function() {
|
|
|
190
186
|
isDowngrade: !remoteInfo
|
|
191
187
|
}))
|
|
192
188
|
];
|
|
193
|
-
case
|
|
189
|
+
case 8:
|
|
194
190
|
data = _state.sent();
|
|
195
191
|
return [
|
|
196
192
|
2,
|
|
197
193
|
ctx.json(data)
|
|
198
194
|
];
|
|
199
|
-
case
|
|
195
|
+
case 9:
|
|
200
196
|
e = _state.sent();
|
|
201
197
|
console.log("server plugin data fetch error: ");
|
|
202
198
|
console.error(e);
|
|
@@ -205,7 +201,7 @@ var middleware = function() {
|
|
|
205
201
|
2,
|
|
206
202
|
ctx.text("failed to fetch ".concat(remoteInfo.name, " data, error:\n ").concat(e))
|
|
207
203
|
];
|
|
208
|
-
case
|
|
204
|
+
case 10:
|
|
209
205
|
return [
|
|
210
206
|
2
|
|
211
207
|
];
|
|
@@ -33,7 +33,7 @@ function _callDowngrade() {
|
|
|
33
33
|
];
|
|
34
34
|
}
|
|
35
35
|
mfDataFetch = dataFetchMap[id];
|
|
36
|
-
if (!(mfDataFetch[2] === MF_DATA_FETCH_STATUS.AWAIT))
|
|
36
|
+
if (!((mfDataFetch === null || mfDataFetch === void 0 ? void 0 : mfDataFetch[2]) === MF_DATA_FETCH_STATUS.AWAIT))
|
|
37
37
|
return [
|
|
38
38
|
3,
|
|
39
39
|
6
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DATA_FETCH_QUERY } from "../../constant";
|
|
1
|
+
import { DATA_FETCH_QUERY, MF_DATA_FETCH_STATUS } from "../../constant";
|
|
2
2
|
import logger from "../../logger";
|
|
3
3
|
import { getDataFetchMap } from "../../utils";
|
|
4
4
|
import { fetchData, initDataFetchMap, loadDataFetchModule } from "../../utils/dataFetch";
|
|
@@ -51,15 +51,16 @@ const middleware = async (ctx, next) => {
|
|
|
51
51
|
if (!dataFetchId) {
|
|
52
52
|
return next();
|
|
53
53
|
}
|
|
54
|
-
logger.
|
|
54
|
+
logger.log("fetch data from server, dataFetchId: ", dataFetchId);
|
|
55
55
|
try {
|
|
56
|
-
var _dataFetchMap_dataFetchId;
|
|
56
|
+
var _dataFetchMap_dataFetchId, _dataFetchMap_dataFetchId1;
|
|
57
57
|
const dataFetchMap = getDataFetchMap();
|
|
58
58
|
if (!dataFetchMap) {
|
|
59
59
|
initDataFetchMap();
|
|
60
60
|
}
|
|
61
61
|
const fetchDataPromise = (_dataFetchMap_dataFetchId = dataFetchMap[dataFetchId]) === null || _dataFetchMap_dataFetchId === void 0 ? void 0 : _dataFetchMap_dataFetchId[1];
|
|
62
|
-
if (fetchDataPromise) {
|
|
62
|
+
if (fetchDataPromise && ((_dataFetchMap_dataFetchId1 = dataFetchMap[dataFetchId]) === null || _dataFetchMap_dataFetchId1 === void 0 ? void 0 : _dataFetchMap_dataFetchId1[2]) !== MF_DATA_FETCH_STATUS.ERROR) {
|
|
63
|
+
logger.log("fetch data from server, fetchDataPromise: ", fetchDataPromise);
|
|
63
64
|
const targetPromise = fetchDataPromise[0];
|
|
64
65
|
const wrappedPromise = wrapSetTimeout(targetPromise, 2e4, dataFetchId);
|
|
65
66
|
if (wrappedPromise) {
|
|
@@ -114,7 +115,6 @@ const middleware = async (ctx, next) => {
|
|
|
114
115
|
const res = await wrappedPromise;
|
|
115
116
|
return ctx.json(res);
|
|
116
117
|
}
|
|
117
|
-
return next();
|
|
118
118
|
}
|
|
119
119
|
const remoteId = dataFetchId.split(SEPARATOR)[0];
|
|
120
120
|
const hostInstance = globalThis.__FEDERATION__.__INSTANCES__[0];
|
|
@@ -19,7 +19,7 @@ async function callDowngrade(id, params, remoteInfo) {
|
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
const mfDataFetch = dataFetchMap[id];
|
|
22
|
-
if (mfDataFetch[2] === MF_DATA_FETCH_STATUS.AWAIT) {
|
|
22
|
+
if ((mfDataFetch === null || mfDataFetch === void 0 ? void 0 : mfDataFetch[2]) === MF_DATA_FETCH_STATUS.AWAIT) {
|
|
23
23
|
mfDataFetch[2] = MF_DATA_FETCH_STATUS.LOADING;
|
|
24
24
|
let promise, res, rej;
|
|
25
25
|
if (mfDataFetch[1]) {
|
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-20250523110447",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -111,12 +111,12 @@
|
|
|
111
111
|
"@swc/helpers": "0.5.13",
|
|
112
112
|
"node-fetch": "~3.3.0",
|
|
113
113
|
"react-error-boundary": "4.1.2",
|
|
114
|
-
"@module-federation/rsbuild-plugin": "0.0.0-next-
|
|
115
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
116
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
117
|
-
"@module-federation/node": "0.0.0-next-
|
|
118
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
119
|
-
"@module-federation/cli": "0.0.0-next-
|
|
114
|
+
"@module-federation/rsbuild-plugin": "0.0.0-next-20250523110447",
|
|
115
|
+
"@module-federation/enhanced": "0.0.0-next-20250523110447",
|
|
116
|
+
"@module-federation/runtime": "0.0.0-next-20250523110447",
|
|
117
|
+
"@module-federation/node": "0.0.0-next-20250523110447",
|
|
118
|
+
"@module-federation/sdk": "0.0.0-next-20250523110447",
|
|
119
|
+
"@module-federation/cli": "0.0.0-next-20250523110447"
|
|
120
120
|
},
|
|
121
121
|
"devDependencies": {
|
|
122
122
|
"@rsbuild/core": "1.2.8",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"@modern-js/runtime": "2.67.5",
|
|
127
127
|
"@modern-js/tsconfig": "2.67.5",
|
|
128
128
|
"@modern-js/server-runtime": "2.67.5",
|
|
129
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
129
|
+
"@module-federation/manifest": "0.0.0-next-20250523110447"
|
|
130
130
|
},
|
|
131
131
|
"peerDependencies": {
|
|
132
132
|
"react": ">=17",
|