@module-federation/modern-js 0.0.0-next-20250522130707 → 0.0.0-next-20250523061743
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 +3 -3
- package/dist/cjs/cli/mfRuntimePlugins/auto-fetch-data.js +1 -1
- package/dist/cjs/utils/dataFetch.js +5 -0
- package/dist/esm/cli/configPlugin.js +3 -4
- package/dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js +2 -2
- package/dist/esm/utils/dataFetch.js +5 -1
- package/dist/esm-node/cli/configPlugin.js +3 -3
- package/dist/esm-node/cli/mfRuntimePlugins/auto-fetch-data.js +2 -2
- package/dist/esm-node/utils/dataFetch.js +5 -1
- package/dist/types/cli/configPlugin.d.ts +1 -1
- package/dist/types/utils/dataFetch.d.ts +1 -0
- package/package.json +8 -8
|
@@ -134,9 +134,9 @@ const patchDTSConfig = (mfConfig, isServer) => {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
-
const patchMFConfig = (mfConfig, isServer,
|
|
137
|
+
const patchMFConfig = (mfConfig, isServer, remoteIpStrategy) => {
|
|
138
138
|
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
139
|
-
(0, import_utils2.addDataFetchExposes)(mfConfig.exposes, isServer
|
|
139
|
+
(0, import_utils2.addDataFetchExposes)(mfConfig.exposes, isServer);
|
|
140
140
|
if (mfConfig.remoteType === void 0) {
|
|
141
141
|
mfConfig.remoteType = "script";
|
|
142
142
|
}
|
|
@@ -301,7 +301,7 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
301
301
|
const isWeb = (0, import_utils.isWebTarget)(target);
|
|
302
302
|
addMyTypes2Ignored(chain, !isWeb ? ssrConfig : csrConfig);
|
|
303
303
|
const targetMFConfig = !isWeb ? ssrConfig : csrConfig;
|
|
304
|
-
patchMFConfig(targetMFConfig, !isWeb,
|
|
304
|
+
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4");
|
|
305
305
|
patchBundlerConfig({
|
|
306
306
|
// @ts-expect-error chain type is not correct
|
|
307
307
|
chain,
|
|
@@ -44,7 +44,7 @@ const autoFetchData = () => ({
|
|
|
44
44
|
},
|
|
45
45
|
afterLoadSnapshot(args) {
|
|
46
46
|
const { id, moduleInfo, remoteSnapshot, host } = args;
|
|
47
|
-
if (typeof id === "string" &&
|
|
47
|
+
if (typeof id === "string" && (0, import_dataFetch.isDataLoaderExpose)(id)) {
|
|
48
48
|
return args;
|
|
49
49
|
}
|
|
50
50
|
if (!remoteSnapshot || !id || !("modules" in remoteSnapshot)) {
|
|
@@ -36,6 +36,7 @@ __export(dataFetch_exports, {
|
|
|
36
36
|
getDataFetchMap: () => getDataFetchMap,
|
|
37
37
|
getDataFetchMapKey: () => getDataFetchMapKey,
|
|
38
38
|
initDataFetchMap: () => initDataFetchMap,
|
|
39
|
+
isDataLoaderExpose: () => isDataLoaderExpose,
|
|
39
40
|
loadDataFetchModule: () => loadDataFetchModule,
|
|
40
41
|
setDataFetchItemLoadedStatus: () => setDataFetchItemLoadedStatus,
|
|
41
42
|
wrapDataFetchId: () => wrapDataFetchId
|
|
@@ -184,6 +185,9 @@ async function loadDataFetchModule(instance, id) {
|
|
|
184
185
|
throw new Error(`fetchData not found in remote ${id}, ${JSON.stringify(m)}`);
|
|
185
186
|
});
|
|
186
187
|
}
|
|
188
|
+
function isDataLoaderExpose(exposeKey) {
|
|
189
|
+
return exposeKey.endsWith(import_constant2.DATA_FETCH_IDENTIFIER) || exposeKey.endsWith(import_constant2.DATA_FETCH_CLIENT_SUFFIX);
|
|
190
|
+
}
|
|
187
191
|
// Annotate the CommonJS export names for ESM import in node:
|
|
188
192
|
0 && (module.exports = {
|
|
189
193
|
fetchData,
|
|
@@ -194,6 +198,7 @@ async function loadDataFetchModule(instance, id) {
|
|
|
194
198
|
getDataFetchMap,
|
|
195
199
|
getDataFetchMapKey,
|
|
196
200
|
initDataFetchMap,
|
|
201
|
+
isDataLoaderExpose,
|
|
197
202
|
loadDataFetchModule,
|
|
198
203
|
setDataFetchItemLoadedStatus,
|
|
199
204
|
wrapDataFetchId
|
|
@@ -126,10 +126,9 @@ var patchDTSConfig = function(mfConfig, isServer) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
|
-
var patchMFConfig = function(mfConfig, isServer) {
|
|
130
|
-
var enableSSR = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false, remoteIpStrategy = arguments.length > 3 ? arguments[3] : void 0;
|
|
129
|
+
var patchMFConfig = function(mfConfig, isServer, remoteIpStrategy) {
|
|
131
130
|
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
132
|
-
addDataFetchExposes(mfConfig.exposes, isServer
|
|
131
|
+
addDataFetchExposes(mfConfig.exposes, isServer);
|
|
133
132
|
if (mfConfig.remoteType === void 0) {
|
|
134
133
|
mfConfig.remoteType = "script";
|
|
135
134
|
}
|
|
@@ -299,7 +298,7 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
299
298
|
var isWeb = isWebTarget(target);
|
|
300
299
|
addMyTypes2Ignored(chain, !isWeb ? ssrConfig : csrConfig);
|
|
301
300
|
var targetMFConfig = !isWeb ? ssrConfig : csrConfig;
|
|
302
|
-
patchMFConfig(targetMFConfig, !isWeb,
|
|
301
|
+
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4");
|
|
303
302
|
patchBundlerConfig({
|
|
304
303
|
// @ts-expect-error chain type is not correct
|
|
305
304
|
chain,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getDataFetchInfo, initDataFetchMap, getDataFetchItem, getDataFetchMap, isCSROnly } from "../../utils";
|
|
2
2
|
import logger from "../../logger";
|
|
3
|
-
import { getDataFetchMapKey, loadDataFetchModule } from "../../utils/dataFetch";
|
|
3
|
+
import { getDataFetchMapKey, isDataLoaderExpose, loadDataFetchModule } from "../../utils/dataFetch";
|
|
4
4
|
import { MF_DATA_FETCH_TYPE, MF_DATA_FETCH_STATUS } from "../../constant";
|
|
5
5
|
import { DATA_FETCH_CLIENT_SUFFIX } from "@module-federation/rsbuild-plugin/constant";
|
|
6
6
|
var autoFetchData = function() {
|
|
@@ -12,7 +12,7 @@ var autoFetchData = function() {
|
|
|
12
12
|
},
|
|
13
13
|
afterLoadSnapshot: function afterLoadSnapshot(args) {
|
|
14
14
|
var id = args.id, moduleInfo = args.moduleInfo, remoteSnapshot = args.remoteSnapshot, host = args.host;
|
|
15
|
-
if (typeof id === "string" && id
|
|
15
|
+
if (typeof id === "string" && isDataLoaderExpose(id)) {
|
|
16
16
|
return args;
|
|
17
17
|
}
|
|
18
18
|
if (!remoteSnapshot || !id || !("modules" in remoteSnapshot)) {
|
|
@@ -7,7 +7,7 @@ import { isCSROnly } from "../utils";
|
|
|
7
7
|
import logger from "../logger";
|
|
8
8
|
import { callDowngrade, getDowngradeTag } from "../ssr-runtime/downgrade";
|
|
9
9
|
import { DOWNGRADE_KEY, MF_DATA_FETCH_STATUS, WRAP_DATA_FETCH_ID_IDENTIFIER } from "../constant";
|
|
10
|
-
import { DATA_FETCH_IDENTIFIER } from "@module-federation/rsbuild-plugin/constant";
|
|
10
|
+
import { DATA_FETCH_CLIENT_SUFFIX, DATA_FETCH_IDENTIFIER } from "@module-federation/rsbuild-plugin/constant";
|
|
11
11
|
var getDataFetchInfo = function(param) {
|
|
12
12
|
var name = param.name, alias = param.alias, id = param.id, remoteSnapshot = param.remoteSnapshot;
|
|
13
13
|
if (!remoteSnapshot) {
|
|
@@ -212,6 +212,9 @@ function _loadDataFetchModule() {
|
|
|
212
212
|
});
|
|
213
213
|
return _loadDataFetchModule.apply(this, arguments);
|
|
214
214
|
}
|
|
215
|
+
function isDataLoaderExpose(exposeKey) {
|
|
216
|
+
return exposeKey.endsWith(DATA_FETCH_IDENTIFIER) || exposeKey.endsWith(DATA_FETCH_CLIENT_SUFFIX);
|
|
217
|
+
}
|
|
215
218
|
export {
|
|
216
219
|
fetchData,
|
|
217
220
|
flushDataFetch,
|
|
@@ -221,6 +224,7 @@ export {
|
|
|
221
224
|
getDataFetchMap,
|
|
222
225
|
getDataFetchMapKey,
|
|
223
226
|
initDataFetchMap,
|
|
227
|
+
isDataLoaderExpose,
|
|
224
228
|
loadDataFetchModule,
|
|
225
229
|
setDataFetchItemLoadedStatus,
|
|
226
230
|
wrapDataFetchId
|
|
@@ -93,9 +93,9 @@ const patchDTSConfig = (mfConfig, isServer) => {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
const patchMFConfig = (mfConfig, isServer,
|
|
96
|
+
const patchMFConfig = (mfConfig, isServer, remoteIpStrategy) => {
|
|
97
97
|
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
98
|
-
addDataFetchExposes(mfConfig.exposes, isServer
|
|
98
|
+
addDataFetchExposes(mfConfig.exposes, isServer);
|
|
99
99
|
if (mfConfig.remoteType === void 0) {
|
|
100
100
|
mfConfig.remoteType = "script";
|
|
101
101
|
}
|
|
@@ -260,7 +260,7 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
260
260
|
const isWeb = isWebTarget(target);
|
|
261
261
|
addMyTypes2Ignored(chain, !isWeb ? ssrConfig : csrConfig);
|
|
262
262
|
const targetMFConfig = !isWeb ? ssrConfig : csrConfig;
|
|
263
|
-
patchMFConfig(targetMFConfig, !isWeb,
|
|
263
|
+
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4");
|
|
264
264
|
patchBundlerConfig({
|
|
265
265
|
// @ts-expect-error chain type is not correct
|
|
266
266
|
chain,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getDataFetchInfo, initDataFetchMap, getDataFetchItem, getDataFetchMap, isCSROnly } from "../../utils";
|
|
2
2
|
import logger from "../../logger";
|
|
3
|
-
import { getDataFetchMapKey, loadDataFetchModule } from "../../utils/dataFetch";
|
|
3
|
+
import { getDataFetchMapKey, isDataLoaderExpose, loadDataFetchModule } from "../../utils/dataFetch";
|
|
4
4
|
import { MF_DATA_FETCH_TYPE, MF_DATA_FETCH_STATUS } from "../../constant";
|
|
5
5
|
import { DATA_FETCH_CLIENT_SUFFIX } from "@module-federation/rsbuild-plugin/constant";
|
|
6
6
|
const autoFetchData = () => ({
|
|
@@ -11,7 +11,7 @@ const autoFetchData = () => ({
|
|
|
11
11
|
},
|
|
12
12
|
afterLoadSnapshot(args) {
|
|
13
13
|
const { id, moduleInfo, remoteSnapshot, host } = args;
|
|
14
|
-
if (typeof id === "string" && id
|
|
14
|
+
if (typeof id === "string" && isDataLoaderExpose(id)) {
|
|
15
15
|
return args;
|
|
16
16
|
}
|
|
17
17
|
if (!remoteSnapshot || !id || !("modules" in remoteSnapshot)) {
|
|
@@ -3,7 +3,7 @@ import { isCSROnly } from "../utils";
|
|
|
3
3
|
import logger from "../logger";
|
|
4
4
|
import { callDowngrade, getDowngradeTag } from "../ssr-runtime/downgrade";
|
|
5
5
|
import { DOWNGRADE_KEY, MF_DATA_FETCH_STATUS, WRAP_DATA_FETCH_ID_IDENTIFIER } from "../constant";
|
|
6
|
-
import { DATA_FETCH_IDENTIFIER } from "@module-federation/rsbuild-plugin/constant";
|
|
6
|
+
import { DATA_FETCH_CLIENT_SUFFIX, DATA_FETCH_IDENTIFIER } from "@module-federation/rsbuild-plugin/constant";
|
|
7
7
|
const getDataFetchInfo = ({ name, alias, id, remoteSnapshot }) => {
|
|
8
8
|
if (!remoteSnapshot) {
|
|
9
9
|
return;
|
|
@@ -141,6 +141,9 @@ async function loadDataFetchModule(instance, id) {
|
|
|
141
141
|
throw new Error(`fetchData not found in remote ${id}, ${JSON.stringify(m)}`);
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
+
function isDataLoaderExpose(exposeKey) {
|
|
145
|
+
return exposeKey.endsWith(DATA_FETCH_IDENTIFIER) || exposeKey.endsWith(DATA_FETCH_CLIENT_SUFFIX);
|
|
146
|
+
}
|
|
144
147
|
export {
|
|
145
148
|
fetchData,
|
|
146
149
|
flushDataFetch,
|
|
@@ -150,6 +153,7 @@ export {
|
|
|
150
153
|
getDataFetchMap,
|
|
151
154
|
getDataFetchMapKey,
|
|
152
155
|
initDataFetchMap,
|
|
156
|
+
isDataLoaderExpose,
|
|
153
157
|
loadDataFetchModule,
|
|
154
158
|
setDataFetchItemLoadedStatus,
|
|
155
159
|
wrapDataFetchId
|
|
@@ -7,7 +7,7 @@ import type { BundlerChainConfig } from '../interfaces/bundler';
|
|
|
7
7
|
export type ConfigType<T> = T extends 'webpack' ? webpack.Configuration : T extends 'rspack' ? Rspack.Configuration : never;
|
|
8
8
|
export declare function setEnv(enableSSR: boolean): void;
|
|
9
9
|
export declare const getMFConfig: (userConfig: PluginOptions) => Promise<moduleFederationPlugin.ModuleFederationPluginOptions>;
|
|
10
|
-
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean,
|
|
10
|
+
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean, remoteIpStrategy?: "ipv4" | "inherit") => moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
11
11
|
export declare function addMyTypes2Ignored(chain: BundlerChainConfig, mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions): void;
|
|
12
12
|
export declare function patchBundlerConfig(options: {
|
|
13
13
|
chain: BundlerChainConfig;
|
|
@@ -23,3 +23,4 @@ export declare function getDataFetchMapKey(dataFetchInfo?: ReturnType<typeof get
|
|
|
23
23
|
version?: string;
|
|
24
24
|
}): string | undefined;
|
|
25
25
|
export declare function loadDataFetchModule(instance: FederationHost, id: string): Promise<(params: DataFetchParams) => Promise<unknown>>;
|
|
26
|
+
export declare function isDataLoaderExpose(exposeKey: string): boolean;
|
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-20250523061743",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -108,12 +108,12 @@
|
|
|
108
108
|
"@swc/helpers": "0.5.13",
|
|
109
109
|
"node-fetch": "~3.3.0",
|
|
110
110
|
"react-error-boundary": "4.1.2",
|
|
111
|
-
"@module-federation/rsbuild-plugin": "0.0.0-next-
|
|
112
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
113
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
114
|
-
"@module-federation/node": "0.0.0-next-
|
|
115
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
116
|
-
"@module-federation/cli": "0.0.0-next-
|
|
111
|
+
"@module-federation/rsbuild-plugin": "0.0.0-next-20250523061743",
|
|
112
|
+
"@module-federation/enhanced": "0.0.0-next-20250523061743",
|
|
113
|
+
"@module-federation/runtime": "0.0.0-next-20250523061743",
|
|
114
|
+
"@module-federation/node": "0.0.0-next-20250523061743",
|
|
115
|
+
"@module-federation/sdk": "0.0.0-next-20250523061743",
|
|
116
|
+
"@module-federation/cli": "0.0.0-next-20250523061743"
|
|
117
117
|
},
|
|
118
118
|
"devDependencies": {
|
|
119
119
|
"@rsbuild/core": "1.2.8",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"@modern-js/runtime": "2.67.5",
|
|
124
124
|
"@modern-js/tsconfig": "2.67.5",
|
|
125
125
|
"@modern-js/server-runtime": "2.67.5",
|
|
126
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
126
|
+
"@module-federation/manifest": "0.0.0-next-20250523061743"
|
|
127
127
|
},
|
|
128
128
|
"peerDependencies": {
|
|
129
129
|
"react": ">=17",
|