@module-federation/modern-js 0.24.0 → 2.1.0
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 +2 -30
- package/dist/cjs/cli/index.js +0 -1
- package/dist/esm/cli/configPlugin.mjs +4 -32
- package/dist/esm/cli/index.mjs +0 -1
- package/dist/esm-node/cli/configPlugin.mjs +4 -32
- package/dist/esm-node/cli/index.mjs +0 -1
- package/dist/types/cli/configPlugin.d.ts +1 -1
- package/dist/types/types/index.d.ts +0 -2
- package/package.json +16 -24
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +0 -80
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +0 -58
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +0 -46
- package/dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts +0 -3
|
@@ -91,24 +91,6 @@ var __webpack_exports__ = {};
|
|
|
91
91
|
});
|
|
92
92
|
if (!hasPlugin) runtimePlugins.push(runtimePlugin);
|
|
93
93
|
};
|
|
94
|
-
const replaceRemoteUrl = (mfConfig, remoteIpStrategy)=>{
|
|
95
|
-
if (remoteIpStrategy && 'inherit' === remoteIpStrategy) return;
|
|
96
|
-
if (!mfConfig.remotes) return;
|
|
97
|
-
const ipv4 = (0, external_utils_js_namespaceObject.getIPV4)();
|
|
98
|
-
const handleRemoteObject = (remoteObject)=>{
|
|
99
|
-
Object.keys(remoteObject).forEach((remoteKey)=>{
|
|
100
|
-
const remote = remoteObject[remoteKey];
|
|
101
|
-
if (Array.isArray(remote)) return;
|
|
102
|
-
if ('string' == typeof remote && remote.includes(external_constant_js_namespaceObject.LOCALHOST)) remoteObject[remoteKey] = remote.replace(external_constant_js_namespaceObject.LOCALHOST, ipv4);
|
|
103
|
-
if ('object' == typeof remote && !Array.isArray(remote.external) && remote.external.includes(external_constant_js_namespaceObject.LOCALHOST)) remote.external = remote.external.replace(external_constant_js_namespaceObject.LOCALHOST, ipv4);
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
if (Array.isArray(mfConfig.remotes)) mfConfig.remotes.forEach((remoteObject)=>{
|
|
107
|
-
if ('string' == typeof remoteObject) return;
|
|
108
|
-
handleRemoteObject(remoteObject);
|
|
109
|
-
});
|
|
110
|
-
else if ('string' != typeof mfConfig.remotes) handleRemoteObject(mfConfig.remotes);
|
|
111
|
-
};
|
|
112
94
|
const patchDTSConfig = (mfConfig, isServer)=>{
|
|
113
95
|
if (isServer) return;
|
|
114
96
|
const ModernJSRuntime = '@module-federation/modern-js/runtime';
|
|
@@ -135,8 +117,7 @@ var __webpack_exports__ = {};
|
|
|
135
117
|
}
|
|
136
118
|
}
|
|
137
119
|
};
|
|
138
|
-
const patchMFConfig = (mfConfig, isServer
|
|
139
|
-
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
120
|
+
const patchMFConfig = (mfConfig, isServer)=>{
|
|
140
121
|
(0, utils_namespaceObject.addDataFetchExposes)(mfConfig.exposes, isServer);
|
|
141
122
|
if (void 0 === mfConfig.remoteType) mfConfig.remoteType = "script";
|
|
142
123
|
if (!mfConfig.name) throw new Error(`${external_constant_js_namespaceObject.PLUGIN_IDENTIFIER} mfConfig.name can not be empty!`);
|
|
@@ -145,7 +126,6 @@ var __webpack_exports__ = {};
|
|
|
145
126
|
];
|
|
146
127
|
patchDTSConfig(mfConfig, isServer);
|
|
147
128
|
injectRuntimePlugins(require.resolve('@module-federation/modern-js/shared-strategy'), runtimePlugins);
|
|
148
|
-
if (enableSSR && (0, external_utils_js_namespaceObject.isDev)()) injectRuntimePlugins(require.resolve('@module-federation/modern-js/resolve-entry-ipv4'), runtimePlugins);
|
|
149
129
|
if (isServer) {
|
|
150
130
|
injectRuntimePlugins(require.resolve('@module-federation/node/runtimePlugin'), runtimePlugins);
|
|
151
131
|
if ((0, external_utils_js_namespaceObject.isDev)()) injectRuntimePlugins(require.resolve('@module-federation/node/record-dynamic-remote-entry-hash-plugin'), runtimePlugins);
|
|
@@ -262,7 +242,7 @@ var __webpack_exports__ = {};
|
|
|
262
242
|
const isWeb = (0, external_utils_js_namespaceObject.isWebTarget)(target);
|
|
263
243
|
addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
|
|
264
244
|
const targetMFConfig = isWeb ? csrConfig : ssrConfig;
|
|
265
|
-
patchMFConfig(targetMFConfig, !isWeb
|
|
245
|
+
patchMFConfig(targetMFConfig, !isWeb);
|
|
266
246
|
patchBundlerConfig({
|
|
267
247
|
chain,
|
|
268
248
|
isServer: !isWeb,
|
|
@@ -283,9 +263,6 @@ var __webpack_exports__ = {};
|
|
|
283
263
|
var _ref;
|
|
284
264
|
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
285
265
|
const bundlerType = 'rspack' === api.getAppContext().bundlerType ? 'rspack' : 'webpack';
|
|
286
|
-
const ipv4 = (0, external_utils_js_namespaceObject.getIPV4)();
|
|
287
|
-
if (void 0 === userConfig.remoteIpStrategy) if (enableSSR) userConfig.remoteIpStrategy = 'ipv4';
|
|
288
|
-
else userConfig.remoteIpStrategy = 'inherit';
|
|
289
266
|
const devServerConfig = null == (_modernjsConfig_tools = modernjsConfig.tools) ? void 0 : _modernjsConfig_tools.devServer;
|
|
290
267
|
const corsWarnMsgs = [
|
|
291
268
|
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
@@ -299,10 +276,6 @@ var __webpack_exports__ = {};
|
|
|
299
276
|
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
300
277
|
'Access-Control-Allow-Headers': '*'
|
|
301
278
|
} : void 0;
|
|
302
|
-
const defineConfig = {
|
|
303
|
-
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
304
|
-
};
|
|
305
|
-
if (enableSSR && (0, external_utils_js_namespaceObject.isDev)()) defineConfig['FEDERATION_IPV4'] = JSON.stringify(ipv4);
|
|
306
279
|
return {
|
|
307
280
|
tools: {
|
|
308
281
|
devServer: {
|
|
@@ -315,7 +288,6 @@ var __webpack_exports__ = {};
|
|
|
315
288
|
}
|
|
316
289
|
},
|
|
317
290
|
source: {
|
|
318
|
-
define: defineConfig,
|
|
319
291
|
enableAsyncEntry: 'rspack' === bundlerType ? null != (_ref = null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) ? _ref : true : null == (_modernjsConfig_source1 = modernjsConfig.source) ? void 0 : _modernjsConfig_source1.enableAsyncEntry
|
|
320
292
|
},
|
|
321
293
|
dev: {
|
package/dist/cjs/cli/index.js
CHANGED
|
@@ -45,7 +45,6 @@ const moduleFederationPlugin = (userConfig = {})=>{
|
|
|
45
45
|
originPluginOptions: {
|
|
46
46
|
...userConfig
|
|
47
47
|
},
|
|
48
|
-
remoteIpStrategy: null == userConfig ? void 0 : userConfig.remoteIpStrategy,
|
|
49
48
|
userConfig: userConfig || {},
|
|
50
49
|
assetFileNames: {},
|
|
51
50
|
fetchServerQuery: null != (_userConfig_fetchServerQuery = userConfig.fetchServerQuery) ? _userConfig_fetchServerQuery : void 0,
|
|
@@ -6,9 +6,9 @@ import { _ as _to_consumable_array__ } from "@swc/helpers/_/_to_consumable_array
|
|
|
6
6
|
import { _ as _type_of__ } from "@swc/helpers/_/_type_of";
|
|
7
7
|
import { _ as _ts_generator__ } from "@swc/helpers/_/_ts_generator";
|
|
8
8
|
import path from "path";
|
|
9
|
-
import {
|
|
9
|
+
import { isDev, isWebTarget, skipByTarget } from "./utils.mjs";
|
|
10
10
|
import { encodeName } from "@module-federation/sdk";
|
|
11
|
-
import {
|
|
11
|
+
import { PLUGIN_IDENTIFIER } from "../constant.mjs";
|
|
12
12
|
import { addDataFetchExposes, autoDeleteSplitChunkCacheGroups } from "@module-federation/rsbuild-plugin/utils";
|
|
13
13
|
import logger from "../logger.mjs";
|
|
14
14
|
var __webpack_modules__ = {
|
|
@@ -70,24 +70,6 @@ var injectRuntimePlugins = function(runtimePlugin, runtimePlugins) {
|
|
|
70
70
|
});
|
|
71
71
|
if (!hasPlugin) runtimePlugins.push(runtimePlugin);
|
|
72
72
|
};
|
|
73
|
-
var replaceRemoteUrl = function(mfConfig, remoteIpStrategy) {
|
|
74
|
-
if (remoteIpStrategy && 'inherit' === remoteIpStrategy) return;
|
|
75
|
-
if (!mfConfig.remotes) return;
|
|
76
|
-
var ipv4 = getIPV4();
|
|
77
|
-
var handleRemoteObject = function(remoteObject) {
|
|
78
|
-
Object.keys(remoteObject).forEach(function(remoteKey) {
|
|
79
|
-
var remote = remoteObject[remoteKey];
|
|
80
|
-
if (Array.isArray(remote)) return;
|
|
81
|
-
if ('string' == typeof remote && remote.includes(LOCALHOST)) remoteObject[remoteKey] = remote.replace(LOCALHOST, ipv4);
|
|
82
|
-
if ((void 0 === remote ? "undefined" : _type_of__(remote)) === 'object' && !Array.isArray(remote.external) && remote.external.includes(LOCALHOST)) remote.external = remote.external.replace(LOCALHOST, ipv4);
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
if (Array.isArray(mfConfig.remotes)) mfConfig.remotes.forEach(function(remoteObject) {
|
|
86
|
-
if ('string' == typeof remoteObject) return;
|
|
87
|
-
handleRemoteObject(remoteObject);
|
|
88
|
-
});
|
|
89
|
-
else if ('string' != typeof mfConfig.remotes) handleRemoteObject(mfConfig.remotes);
|
|
90
|
-
};
|
|
91
73
|
var patchDTSConfig = function(mfConfig, isServer) {
|
|
92
74
|
if (isServer) return;
|
|
93
75
|
var ModernJSRuntime = '@module-federation/modern-js/runtime';
|
|
@@ -114,15 +96,13 @@ var patchDTSConfig = function(mfConfig, isServer) {
|
|
|
114
96
|
}
|
|
115
97
|
}
|
|
116
98
|
};
|
|
117
|
-
var patchMFConfig = function(mfConfig, isServer
|
|
118
|
-
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
99
|
+
var patchMFConfig = function(mfConfig, isServer) {
|
|
119
100
|
addDataFetchExposes(mfConfig.exposes, isServer);
|
|
120
101
|
if (void 0 === mfConfig.remoteType) mfConfig.remoteType = "script";
|
|
121
102
|
if (!mfConfig.name) throw new Error("".concat(PLUGIN_IDENTIFIER, " mfConfig.name can not be empty!"));
|
|
122
103
|
var runtimePlugins = _to_consumable_array__(mfConfig.runtimePlugins || []);
|
|
123
104
|
patchDTSConfig(mfConfig, isServer);
|
|
124
105
|
injectRuntimePlugins(require.resolve('@module-federation/modern-js/shared-strategy'), runtimePlugins);
|
|
125
|
-
if (enableSSR && isDev()) injectRuntimePlugins(require.resolve('@module-federation/modern-js/resolve-entry-ipv4'), runtimePlugins);
|
|
126
106
|
if (isServer) {
|
|
127
107
|
injectRuntimePlugins(require.resolve('@module-federation/node/runtimePlugin'), runtimePlugins);
|
|
128
108
|
if (isDev()) injectRuntimePlugins(require.resolve('@module-federation/node/record-dynamic-remote-entry-hash-plugin'), runtimePlugins);
|
|
@@ -246,7 +226,7 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
246
226
|
var isWeb = isWebTarget(target);
|
|
247
227
|
addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
|
|
248
228
|
var targetMFConfig = isWeb ? csrConfig : ssrConfig;
|
|
249
|
-
patchMFConfig(targetMFConfig, !isWeb
|
|
229
|
+
patchMFConfig(targetMFConfig, !isWeb);
|
|
250
230
|
patchBundlerConfig({
|
|
251
231
|
chain: chain,
|
|
252
232
|
isServer: !isWeb,
|
|
@@ -267,9 +247,6 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
267
247
|
var _ref;
|
|
268
248
|
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
269
249
|
var bundlerType = 'rspack' === api.getAppContext().bundlerType ? 'rspack' : 'webpack';
|
|
270
|
-
var ipv4 = getIPV4();
|
|
271
|
-
if (void 0 === userConfig.remoteIpStrategy) if (enableSSR) userConfig.remoteIpStrategy = 'ipv4';
|
|
272
|
-
else userConfig.remoteIpStrategy = 'inherit';
|
|
273
250
|
var devServerConfig = null == (_modernjsConfig_tools = modernjsConfig.tools) ? void 0 : _modernjsConfig_tools.devServer;
|
|
274
251
|
var corsWarnMsgs = [
|
|
275
252
|
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
@@ -283,10 +260,6 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
283
260
|
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
284
261
|
'Access-Control-Allow-Headers': '*'
|
|
285
262
|
} : void 0;
|
|
286
|
-
var defineConfig = {
|
|
287
|
-
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
288
|
-
};
|
|
289
|
-
if (enableSSR && isDev()) defineConfig['FEDERATION_IPV4'] = JSON.stringify(ipv4);
|
|
290
263
|
return {
|
|
291
264
|
tools: {
|
|
292
265
|
devServer: {
|
|
@@ -299,7 +272,6 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
299
272
|
}
|
|
300
273
|
},
|
|
301
274
|
source: {
|
|
302
|
-
define: defineConfig,
|
|
303
275
|
enableAsyncEntry: 'rspack' === bundlerType ? null != (_ref = null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) ? _ref : true : null == (_modernjsConfig_source1 = modernjsConfig.source) ? void 0 : _modernjsConfig_source1.enableAsyncEntry
|
|
304
276
|
},
|
|
305
277
|
dev: {
|
package/dist/esm/cli/index.mjs
CHANGED
|
@@ -18,7 +18,6 @@ var moduleFederationPlugin = function() {
|
|
|
18
18
|
assetResources: {},
|
|
19
19
|
distOutputDir: '',
|
|
20
20
|
originPluginOptions: _object_spread__({}, userConfig),
|
|
21
|
-
remoteIpStrategy: null == userConfig ? void 0 : userConfig.remoteIpStrategy,
|
|
22
21
|
userConfig: userConfig || {},
|
|
23
22
|
assetFileNames: {},
|
|
24
23
|
fetchServerQuery: null != (_userConfig_fetchServerQuery = userConfig.fetchServerQuery) ? _userConfig_fetchServerQuery : void 0,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as __rspack_external_jiti from "jiti";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import {
|
|
3
|
+
import { isDev, isWebTarget, skipByTarget } from "./utils.mjs";
|
|
4
4
|
import { encodeName } from "@module-federation/sdk";
|
|
5
|
-
import {
|
|
5
|
+
import { PLUGIN_IDENTIFIER } from "../constant.mjs";
|
|
6
6
|
import { addDataFetchExposes, autoDeleteSplitChunkCacheGroups } from "@module-federation/rsbuild-plugin/utils";
|
|
7
7
|
import logger from "../logger.mjs";
|
|
8
8
|
var __webpack_modules__ = {
|
|
@@ -45,24 +45,6 @@ const injectRuntimePlugins = (runtimePlugin, runtimePlugins)=>{
|
|
|
45
45
|
});
|
|
46
46
|
if (!hasPlugin) runtimePlugins.push(runtimePlugin);
|
|
47
47
|
};
|
|
48
|
-
const replaceRemoteUrl = (mfConfig, remoteIpStrategy)=>{
|
|
49
|
-
if (remoteIpStrategy && 'inherit' === remoteIpStrategy) return;
|
|
50
|
-
if (!mfConfig.remotes) return;
|
|
51
|
-
const ipv4 = getIPV4();
|
|
52
|
-
const handleRemoteObject = (remoteObject)=>{
|
|
53
|
-
Object.keys(remoteObject).forEach((remoteKey)=>{
|
|
54
|
-
const remote = remoteObject[remoteKey];
|
|
55
|
-
if (Array.isArray(remote)) return;
|
|
56
|
-
if ('string' == typeof remote && remote.includes(LOCALHOST)) remoteObject[remoteKey] = remote.replace(LOCALHOST, ipv4);
|
|
57
|
-
if ('object' == typeof remote && !Array.isArray(remote.external) && remote.external.includes(LOCALHOST)) remote.external = remote.external.replace(LOCALHOST, ipv4);
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
if (Array.isArray(mfConfig.remotes)) mfConfig.remotes.forEach((remoteObject)=>{
|
|
61
|
-
if ('string' == typeof remoteObject) return;
|
|
62
|
-
handleRemoteObject(remoteObject);
|
|
63
|
-
});
|
|
64
|
-
else if ('string' != typeof mfConfig.remotes) handleRemoteObject(mfConfig.remotes);
|
|
65
|
-
};
|
|
66
48
|
const patchDTSConfig = (mfConfig, isServer)=>{
|
|
67
49
|
if (isServer) return;
|
|
68
50
|
const ModernJSRuntime = '@module-federation/modern-js/runtime';
|
|
@@ -89,8 +71,7 @@ const patchDTSConfig = (mfConfig, isServer)=>{
|
|
|
89
71
|
}
|
|
90
72
|
}
|
|
91
73
|
};
|
|
92
|
-
const patchMFConfig = (mfConfig, isServer
|
|
93
|
-
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
74
|
+
const patchMFConfig = (mfConfig, isServer)=>{
|
|
94
75
|
addDataFetchExposes(mfConfig.exposes, isServer);
|
|
95
76
|
if (void 0 === mfConfig.remoteType) mfConfig.remoteType = "script";
|
|
96
77
|
if (!mfConfig.name) throw new Error(`${PLUGIN_IDENTIFIER} mfConfig.name can not be empty!`);
|
|
@@ -99,7 +80,6 @@ const patchMFConfig = (mfConfig, isServer, remoteIpStrategy, enableSSR)=>{
|
|
|
99
80
|
];
|
|
100
81
|
patchDTSConfig(mfConfig, isServer);
|
|
101
82
|
injectRuntimePlugins(require.resolve('@module-federation/modern-js/shared-strategy'), runtimePlugins);
|
|
102
|
-
if (enableSSR && isDev()) injectRuntimePlugins(require.resolve('@module-federation/modern-js/resolve-entry-ipv4'), runtimePlugins);
|
|
103
83
|
if (isServer) {
|
|
104
84
|
injectRuntimePlugins(require.resolve('@module-federation/node/runtimePlugin'), runtimePlugins);
|
|
105
85
|
if (isDev()) injectRuntimePlugins(require.resolve('@module-federation/node/record-dynamic-remote-entry-hash-plugin'), runtimePlugins);
|
|
@@ -216,7 +196,7 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
216
196
|
const isWeb = isWebTarget(target);
|
|
217
197
|
addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
|
|
218
198
|
const targetMFConfig = isWeb ? csrConfig : ssrConfig;
|
|
219
|
-
patchMFConfig(targetMFConfig, !isWeb
|
|
199
|
+
patchMFConfig(targetMFConfig, !isWeb);
|
|
220
200
|
patchBundlerConfig({
|
|
221
201
|
chain,
|
|
222
202
|
isServer: !isWeb,
|
|
@@ -237,9 +217,6 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
237
217
|
var _ref;
|
|
238
218
|
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
239
219
|
const bundlerType = 'rspack' === api.getAppContext().bundlerType ? 'rspack' : 'webpack';
|
|
240
|
-
const ipv4 = getIPV4();
|
|
241
|
-
if (void 0 === userConfig.remoteIpStrategy) if (enableSSR) userConfig.remoteIpStrategy = 'ipv4';
|
|
242
|
-
else userConfig.remoteIpStrategy = 'inherit';
|
|
243
220
|
const devServerConfig = null == (_modernjsConfig_tools = modernjsConfig.tools) ? void 0 : _modernjsConfig_tools.devServer;
|
|
244
221
|
const corsWarnMsgs = [
|
|
245
222
|
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
@@ -253,10 +230,6 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
253
230
|
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
254
231
|
'Access-Control-Allow-Headers': '*'
|
|
255
232
|
} : void 0;
|
|
256
|
-
const defineConfig = {
|
|
257
|
-
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
258
|
-
};
|
|
259
|
-
if (enableSSR && isDev()) defineConfig['FEDERATION_IPV4'] = JSON.stringify(ipv4);
|
|
260
233
|
return {
|
|
261
234
|
tools: {
|
|
262
235
|
devServer: {
|
|
@@ -269,7 +242,6 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
269
242
|
}
|
|
270
243
|
},
|
|
271
244
|
source: {
|
|
272
|
-
define: defineConfig,
|
|
273
245
|
enableAsyncEntry: 'rspack' === bundlerType ? null != (_ref = null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) ? _ref : true : null == (_modernjsConfig_source1 = modernjsConfig.source) ? void 0 : _modernjsConfig_source1.enableAsyncEntry
|
|
274
246
|
},
|
|
275
247
|
dev: {
|
|
@@ -15,7 +15,6 @@ const moduleFederationPlugin = (userConfig = {})=>{
|
|
|
15
15
|
originPluginOptions: {
|
|
16
16
|
...userConfig
|
|
17
17
|
},
|
|
18
|
-
remoteIpStrategy: null == userConfig ? void 0 : userConfig.remoteIpStrategy,
|
|
19
18
|
userConfig: userConfig || {},
|
|
20
19
|
assetFileNames: {},
|
|
21
20
|
fetchServerQuery: null != (_userConfig_fetchServerQuery = userConfig.fetchServerQuery) ? _userConfig_fetchServerQuery : void 0,
|
|
@@ -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) => 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;
|
|
@@ -6,7 +6,6 @@ export interface PluginOptions {
|
|
|
6
6
|
ssr?: {
|
|
7
7
|
distOutputDir?: string;
|
|
8
8
|
} | boolean;
|
|
9
|
-
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
10
9
|
fetchServerQuery?: Record<string, unknown>;
|
|
11
10
|
secondarySharedTreeShaking?: boolean;
|
|
12
11
|
}
|
|
@@ -29,7 +28,6 @@ export interface InternalModernPluginOptions {
|
|
|
29
28
|
browser?: StatsAssetResource;
|
|
30
29
|
node?: StatsAssetResource;
|
|
31
30
|
};
|
|
32
|
-
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
33
31
|
userConfig?: PluginOptions;
|
|
34
32
|
fetchServerQuery?: Record<string, unknown>;
|
|
35
33
|
secondarySharedTreeShaking?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/modern-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -63,11 +63,6 @@
|
|
|
63
63
|
"import": "./dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs",
|
|
64
64
|
"require": "./dist/cjs/cli/mfRuntimePlugins/shared-strategy.js"
|
|
65
65
|
},
|
|
66
|
-
"./resolve-entry-ipv4": {
|
|
67
|
-
"types": "./dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts",
|
|
68
|
-
"import": "./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs",
|
|
69
|
-
"require": "./dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js"
|
|
70
|
-
},
|
|
71
66
|
"./inject-node-fetch": {
|
|
72
67
|
"types": "./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts",
|
|
73
68
|
"import": "./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs",
|
|
@@ -111,9 +106,6 @@
|
|
|
111
106
|
"shared-strategy": [
|
|
112
107
|
"./dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts"
|
|
113
108
|
],
|
|
114
|
-
"resolve-entry-ipv4": [
|
|
115
|
-
"./dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts"
|
|
116
|
-
],
|
|
117
109
|
"inject-node-fetch": [
|
|
118
110
|
"./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts"
|
|
119
111
|
],
|
|
@@ -133,33 +125,33 @@
|
|
|
133
125
|
"author": "hanric <hanric.zhang@gmail.com>",
|
|
134
126
|
"license": "MIT",
|
|
135
127
|
"dependencies": {
|
|
136
|
-
"@modern-js/utils": "2.70.
|
|
128
|
+
"@modern-js/utils": "2.70.5",
|
|
137
129
|
"fs-extra": "11.3.0",
|
|
138
130
|
"lru-cache": "10.4.3",
|
|
139
131
|
"@swc/helpers": "^0.5.17",
|
|
140
132
|
"node-fetch": "~3.3.0",
|
|
141
133
|
"jiti": "2.4.2",
|
|
142
134
|
"react-error-boundary": "4.1.2",
|
|
143
|
-
"@module-federation/rsbuild-plugin": "
|
|
144
|
-
"@module-federation/
|
|
145
|
-
"@module-federation/
|
|
146
|
-
"@module-federation/
|
|
147
|
-
"@module-federation/
|
|
148
|
-
"@module-federation/
|
|
149
|
-
"@module-federation/
|
|
135
|
+
"@module-federation/rsbuild-plugin": "2.1.0",
|
|
136
|
+
"@module-federation/runtime": "2.1.0",
|
|
137
|
+
"@module-federation/bridge-react": "2.1.0",
|
|
138
|
+
"@module-federation/enhanced": "2.1.0",
|
|
139
|
+
"@module-federation/node": "2.7.33",
|
|
140
|
+
"@module-federation/cli": "2.1.0",
|
|
141
|
+
"@module-federation/sdk": "2.1.0"
|
|
150
142
|
},
|
|
151
143
|
"devDependencies": {
|
|
152
|
-
"@rsbuild/plugin-react": "1.4.
|
|
144
|
+
"@rsbuild/plugin-react": "1.4.5",
|
|
153
145
|
"@rslib/core": "0.18.5",
|
|
154
146
|
"@rsbuild/core": "1.3.21",
|
|
155
|
-
"@modern-js/app-tools": "2.70.
|
|
156
|
-
"@modern-js/server-runtime": "2.70.
|
|
157
|
-
"@modern-js/module-tools": "2.70.
|
|
158
|
-
"@modern-js/runtime": "2.70.
|
|
159
|
-
"@modern-js/tsconfig": "2.70.
|
|
147
|
+
"@modern-js/app-tools": "2.70.5",
|
|
148
|
+
"@modern-js/server-runtime": "2.70.5",
|
|
149
|
+
"@modern-js/module-tools": "2.70.5",
|
|
150
|
+
"@modern-js/runtime": "2.70.5",
|
|
151
|
+
"@modern-js/tsconfig": "2.70.5",
|
|
160
152
|
"@types/react": "^18.3.11",
|
|
161
153
|
"@types/react-dom": "^18.3.0",
|
|
162
|
-
"@module-federation/manifest": "
|
|
154
|
+
"@module-federation/manifest": "2.1.0"
|
|
163
155
|
},
|
|
164
156
|
"peerDependencies": {
|
|
165
157
|
"react": ">=17",
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
default: ()=>resolve_entry_ipv4
|
|
28
|
-
});
|
|
29
|
-
const external_constant_js_namespaceObject = require("../../constant.js");
|
|
30
|
-
const ipv4 = "u" > typeof FEDERATION_IPV4 ? FEDERATION_IPV4 : '127.0.0.1';
|
|
31
|
-
const remoteIpStrategy = "u" > typeof REMOTE_IP_STRATEGY ? REMOTE_IP_STRATEGY : 'inherit';
|
|
32
|
-
function replaceObjectLocalhost(key, obj) {
|
|
33
|
-
if ('ipv4' !== remoteIpStrategy) return;
|
|
34
|
-
if (!(key in obj)) return;
|
|
35
|
-
const remote = obj[key];
|
|
36
|
-
if (remote && 'string' == typeof remote && remote.includes(external_constant_js_namespaceObject.LOCALHOST)) obj[key] = replaceLocalhost(remote);
|
|
37
|
-
}
|
|
38
|
-
function replaceLocalhost(url) {
|
|
39
|
-
return url.replace(external_constant_js_namespaceObject.LOCALHOST, ipv4);
|
|
40
|
-
}
|
|
41
|
-
const resolveEntryIpv4Plugin = ()=>({
|
|
42
|
-
name: 'resolve-entry-ipv4',
|
|
43
|
-
beforeRegisterRemote (args) {
|
|
44
|
-
const { remote } = args;
|
|
45
|
-
replaceObjectLocalhost('entry', remote);
|
|
46
|
-
return args;
|
|
47
|
-
},
|
|
48
|
-
async afterResolve (args) {
|
|
49
|
-
const { remoteInfo } = args;
|
|
50
|
-
replaceObjectLocalhost('entry', remoteInfo);
|
|
51
|
-
return args;
|
|
52
|
-
},
|
|
53
|
-
beforeLoadRemoteSnapshot (args) {
|
|
54
|
-
const { moduleInfo } = args;
|
|
55
|
-
if ('entry' in moduleInfo) {
|
|
56
|
-
replaceObjectLocalhost('entry', moduleInfo);
|
|
57
|
-
return args;
|
|
58
|
-
}
|
|
59
|
-
if ('version' in moduleInfo) replaceObjectLocalhost('version', moduleInfo);
|
|
60
|
-
return args;
|
|
61
|
-
},
|
|
62
|
-
loadRemoteSnapshot (args) {
|
|
63
|
-
const { remoteSnapshot } = args;
|
|
64
|
-
if ('publicPath' in remoteSnapshot) replaceObjectLocalhost('publicPath', remoteSnapshot);
|
|
65
|
-
if ('getPublicPath' in remoteSnapshot) replaceObjectLocalhost('getPublicPath', remoteSnapshot);
|
|
66
|
-
if (remoteSnapshot.remotesInfo) Object.keys(remoteSnapshot.remotesInfo).forEach((key)=>{
|
|
67
|
-
const remoteInfo = remoteSnapshot.remotesInfo[key];
|
|
68
|
-
replaceObjectLocalhost('matchedVersion', remoteInfo);
|
|
69
|
-
});
|
|
70
|
-
return args;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
const resolve_entry_ipv4 = resolveEntryIpv4Plugin;
|
|
74
|
-
exports["default"] = __webpack_exports__["default"];
|
|
75
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
76
|
-
"default"
|
|
77
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
78
|
-
Object.defineProperty(exports, '__esModule', {
|
|
79
|
-
value: true
|
|
80
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { _ } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
-
import { _ as _ts_generator__ } from "@swc/helpers/_/_ts_generator";
|
|
3
|
-
import { LOCALHOST } from "../../constant.mjs";
|
|
4
|
-
var ipv4 = "u" > typeof FEDERATION_IPV4 ? FEDERATION_IPV4 : '127.0.0.1';
|
|
5
|
-
var remoteIpStrategy = "u" > typeof REMOTE_IP_STRATEGY ? REMOTE_IP_STRATEGY : 'inherit';
|
|
6
|
-
function replaceObjectLocalhost(key, obj) {
|
|
7
|
-
if ('ipv4' !== remoteIpStrategy) return;
|
|
8
|
-
if (!(key in obj)) return;
|
|
9
|
-
var remote = obj[key];
|
|
10
|
-
if (remote && 'string' == typeof remote && remote.includes(LOCALHOST)) obj[key] = replaceLocalhost(remote);
|
|
11
|
-
}
|
|
12
|
-
function replaceLocalhost(url) {
|
|
13
|
-
return url.replace(LOCALHOST, ipv4);
|
|
14
|
-
}
|
|
15
|
-
var resolveEntryIpv4Plugin = function() {
|
|
16
|
-
return {
|
|
17
|
-
name: 'resolve-entry-ipv4',
|
|
18
|
-
beforeRegisterRemote: function(args) {
|
|
19
|
-
var remote = args.remote;
|
|
20
|
-
replaceObjectLocalhost('entry', remote);
|
|
21
|
-
return args;
|
|
22
|
-
},
|
|
23
|
-
afterResolve: function(args) {
|
|
24
|
-
return _(function() {
|
|
25
|
-
var remoteInfo;
|
|
26
|
-
return _ts_generator__(this, function(_state) {
|
|
27
|
-
remoteInfo = args.remoteInfo;
|
|
28
|
-
replaceObjectLocalhost('entry', remoteInfo);
|
|
29
|
-
return [
|
|
30
|
-
2,
|
|
31
|
-
args
|
|
32
|
-
];
|
|
33
|
-
});
|
|
34
|
-
})();
|
|
35
|
-
},
|
|
36
|
-
beforeLoadRemoteSnapshot: function(args) {
|
|
37
|
-
var moduleInfo = args.moduleInfo;
|
|
38
|
-
if ('entry' in moduleInfo) {
|
|
39
|
-
replaceObjectLocalhost('entry', moduleInfo);
|
|
40
|
-
return args;
|
|
41
|
-
}
|
|
42
|
-
if ('version' in moduleInfo) replaceObjectLocalhost('version', moduleInfo);
|
|
43
|
-
return args;
|
|
44
|
-
},
|
|
45
|
-
loadRemoteSnapshot: function(args) {
|
|
46
|
-
var remoteSnapshot = args.remoteSnapshot;
|
|
47
|
-
if ('publicPath' in remoteSnapshot) replaceObjectLocalhost('publicPath', remoteSnapshot);
|
|
48
|
-
if ('getPublicPath' in remoteSnapshot) replaceObjectLocalhost('getPublicPath', remoteSnapshot);
|
|
49
|
-
if (remoteSnapshot.remotesInfo) Object.keys(remoteSnapshot.remotesInfo).forEach(function(key) {
|
|
50
|
-
var remoteInfo = remoteSnapshot.remotesInfo[key];
|
|
51
|
-
replaceObjectLocalhost('matchedVersion', remoteInfo);
|
|
52
|
-
});
|
|
53
|
-
return args;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
var resolve_entry_ipv4 = resolveEntryIpv4Plugin;
|
|
58
|
-
export { resolve_entry_ipv4 as default };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { LOCALHOST } from "../../constant.mjs";
|
|
2
|
-
const ipv4 = "u" > typeof FEDERATION_IPV4 ? FEDERATION_IPV4 : '127.0.0.1';
|
|
3
|
-
const remoteIpStrategy = "u" > typeof REMOTE_IP_STRATEGY ? REMOTE_IP_STRATEGY : 'inherit';
|
|
4
|
-
function replaceObjectLocalhost(key, obj) {
|
|
5
|
-
if ('ipv4' !== remoteIpStrategy) return;
|
|
6
|
-
if (!(key in obj)) return;
|
|
7
|
-
const remote = obj[key];
|
|
8
|
-
if (remote && 'string' == typeof remote && remote.includes(LOCALHOST)) obj[key] = replaceLocalhost(remote);
|
|
9
|
-
}
|
|
10
|
-
function replaceLocalhost(url) {
|
|
11
|
-
return url.replace(LOCALHOST, ipv4);
|
|
12
|
-
}
|
|
13
|
-
const resolveEntryIpv4Plugin = ()=>({
|
|
14
|
-
name: 'resolve-entry-ipv4',
|
|
15
|
-
beforeRegisterRemote (args) {
|
|
16
|
-
const { remote } = args;
|
|
17
|
-
replaceObjectLocalhost('entry', remote);
|
|
18
|
-
return args;
|
|
19
|
-
},
|
|
20
|
-
async afterResolve (args) {
|
|
21
|
-
const { remoteInfo } = args;
|
|
22
|
-
replaceObjectLocalhost('entry', remoteInfo);
|
|
23
|
-
return args;
|
|
24
|
-
},
|
|
25
|
-
beforeLoadRemoteSnapshot (args) {
|
|
26
|
-
const { moduleInfo } = args;
|
|
27
|
-
if ('entry' in moduleInfo) {
|
|
28
|
-
replaceObjectLocalhost('entry', moduleInfo);
|
|
29
|
-
return args;
|
|
30
|
-
}
|
|
31
|
-
if ('version' in moduleInfo) replaceObjectLocalhost('version', moduleInfo);
|
|
32
|
-
return args;
|
|
33
|
-
},
|
|
34
|
-
loadRemoteSnapshot (args) {
|
|
35
|
-
const { remoteSnapshot } = args;
|
|
36
|
-
if ('publicPath' in remoteSnapshot) replaceObjectLocalhost('publicPath', remoteSnapshot);
|
|
37
|
-
if ('getPublicPath' in remoteSnapshot) replaceObjectLocalhost('getPublicPath', remoteSnapshot);
|
|
38
|
-
if (remoteSnapshot.remotesInfo) Object.keys(remoteSnapshot.remotesInfo).forEach((key)=>{
|
|
39
|
-
const remoteInfo = remoteSnapshot.remotesInfo[key];
|
|
40
|
-
replaceObjectLocalhost('matchedVersion', remoteInfo);
|
|
41
|
-
});
|
|
42
|
-
return args;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
const resolve_entry_ipv4 = resolveEntryIpv4Plugin;
|
|
46
|
-
export { resolve_entry_ipv4 as default };
|