@module-federation/modern-js-v3 2.0.1 → 2.2.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 +29 -36
- package/dist/cjs/cli/index.js +0 -1
- package/dist/esm/cli/configPlugin.mjs +38 -38
- package/dist/esm/cli/index.mjs +0 -1
- package/dist/esm-node/cli/configPlugin.mjs +30 -38
- package/dist/esm-node/cli/index.mjs +0 -1
- package/dist/types/cli/configPlugin.d.ts +8 -1
- package/dist/types/types/index.d.ts +0 -2
- package/package.json +15 -18
- package/dist/LICENSE +0 -21
- 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
|
@@ -58,6 +58,8 @@ var __webpack_exports__ = {};
|
|
|
58
58
|
setEnv: ()=>setEnv,
|
|
59
59
|
patchBundlerConfig: ()=>patchBundlerConfig
|
|
60
60
|
});
|
|
61
|
+
const external_fs_namespaceObject = require("fs");
|
|
62
|
+
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
61
63
|
const external_path_namespaceObject = require("path");
|
|
62
64
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
63
65
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
@@ -67,6 +69,20 @@ var __webpack_exports__ = {};
|
|
|
67
69
|
const external_logger_js_namespaceObject = require("../logger.js");
|
|
68
70
|
var external_logger_js_default = /*#__PURE__*/ __webpack_require__.n(external_logger_js_namespaceObject);
|
|
69
71
|
const defaultPath = external_path_default().resolve(process.cwd(), 'module-federation.config.ts');
|
|
72
|
+
const resolvePackageFile = (packageName, esmRelativePath, cjsRelativePath)=>{
|
|
73
|
+
const packageEntry = require.resolve(packageName);
|
|
74
|
+
let packageRoot = external_path_default().dirname(packageEntry);
|
|
75
|
+
while(!external_fs_default().existsSync(external_path_default().join(packageRoot, 'package.json'))){
|
|
76
|
+
const parentDir = external_path_default().dirname(packageRoot);
|
|
77
|
+
if (parentDir === packageRoot) throw new Error(`Unable to resolve package root for ${packageName} from ${packageEntry}`);
|
|
78
|
+
packageRoot = parentDir;
|
|
79
|
+
}
|
|
80
|
+
return require.resolve(external_path_default().join(packageRoot, 'true' === process.env.IS_ESM_BUILD ? esmRelativePath : cjsRelativePath));
|
|
81
|
+
};
|
|
82
|
+
const resolveSharedStrategyPlugin = ()=>resolvePackageFile('@module-federation/modern-js-v3', 'dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs', 'dist/cjs/cli/mfRuntimePlugins/shared-strategy.js');
|
|
83
|
+
const resolveInjectNodeFetchPlugin = ()=>resolvePackageFile('@module-federation/modern-js-v3', 'dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs', 'dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js');
|
|
84
|
+
const resolveNodeRuntimePlugin = ()=>resolvePackageFile('@module-federation/node', 'dist/src/runtimePlugin.mjs', 'dist/src/runtimePlugin.js');
|
|
85
|
+
const resolveNodeRecordRemoteHashPlugin = ()=>resolvePackageFile('@module-federation/node', 'dist/src/recordDynamicRemoteEntryHashPlugin.mjs', 'dist/src/recordDynamicRemoteEntryHashPlugin.js');
|
|
70
86
|
function setEnv(enableSSR) {
|
|
71
87
|
if (enableSSR) process.env['MF_SSR_PRJ'] = 'true';
|
|
72
88
|
}
|
|
@@ -76,8 +92,7 @@ var __webpack_exports__ = {};
|
|
|
76
92
|
const mfConfigPath = configPath ? configPath : defaultPath;
|
|
77
93
|
const { createJiti } = __webpack_require__("jiti");
|
|
78
94
|
const jit = createJiti(__filename, {
|
|
79
|
-
interopDefault: true
|
|
80
|
-
esmResolve: true
|
|
95
|
+
interopDefault: true
|
|
81
96
|
});
|
|
82
97
|
const configModule = await jit(mfConfigPath);
|
|
83
98
|
const resolvedConfig = configModule && 'object' == typeof configModule && 'default' in configModule ? configModule.default : configModule;
|
|
@@ -91,24 +106,6 @@ var __webpack_exports__ = {};
|
|
|
91
106
|
});
|
|
92
107
|
if (!hasPlugin) runtimePlugins.push(runtimePlugin);
|
|
93
108
|
};
|
|
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
109
|
const patchDTSConfig = (mfConfig, isServer)=>{
|
|
113
110
|
if (isServer) return;
|
|
114
111
|
const ModernJSRuntime = '@module-federation/modern-js-v3/runtime';
|
|
@@ -135,8 +132,7 @@ var __webpack_exports__ = {};
|
|
|
135
132
|
}
|
|
136
133
|
}
|
|
137
134
|
};
|
|
138
|
-
const patchMFConfig = (mfConfig, isServer
|
|
139
|
-
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
135
|
+
const patchMFConfig = (mfConfig, isServer)=>{
|
|
140
136
|
(0, utils_namespaceObject.addDataFetchExposes)(mfConfig.exposes, isServer);
|
|
141
137
|
if (void 0 === mfConfig.remoteType) mfConfig.remoteType = "script";
|
|
142
138
|
if (!mfConfig.name) throw new Error(`${external_constant_js_namespaceObject.PLUGIN_IDENTIFIER} mfConfig.name can not be empty!`);
|
|
@@ -144,12 +140,11 @@ var __webpack_exports__ = {};
|
|
|
144
140
|
...mfConfig.runtimePlugins || []
|
|
145
141
|
];
|
|
146
142
|
patchDTSConfig(mfConfig, isServer);
|
|
147
|
-
injectRuntimePlugins(
|
|
148
|
-
if (enableSSR && (0, external_utils_js_namespaceObject.isDev)()) injectRuntimePlugins(require.resolve('@module-federation/modern-js-v3/resolve-entry-ipv4'), runtimePlugins);
|
|
143
|
+
injectRuntimePlugins(resolveSharedStrategyPlugin(), runtimePlugins);
|
|
149
144
|
if (isServer) {
|
|
150
|
-
injectRuntimePlugins(
|
|
151
|
-
if ((0, external_utils_js_namespaceObject.isDev)()) injectRuntimePlugins(
|
|
152
|
-
injectRuntimePlugins(
|
|
145
|
+
injectRuntimePlugins(resolveNodeRuntimePlugin(), runtimePlugins);
|
|
146
|
+
if ((0, external_utils_js_namespaceObject.isDev)()) injectRuntimePlugins(resolveNodeRecordRemoteHashPlugin(), runtimePlugins);
|
|
147
|
+
injectRuntimePlugins(resolveInjectNodeFetchPlugin(), runtimePlugins);
|
|
153
148
|
if (mfConfig.library) {
|
|
154
149
|
if (!mfConfig.library.type) mfConfig.library.type = 'commonjs-module';
|
|
155
150
|
if (!mfConfig.library.name) mfConfig.library.name = mfConfig.name;
|
|
@@ -257,12 +252,18 @@ var __webpack_exports__ = {};
|
|
|
257
252
|
userConfig.csrConfig = csrConfig;
|
|
258
253
|
const enableSSR = Boolean(null != (_ref = null == (_userConfig_userConfig = userConfig.userConfig) ? void 0 : _userConfig_userConfig.ssr) ? _ref : Boolean(null == modernjsConfig ? void 0 : null == (_modernjsConfig_server = modernjsConfig.server) ? void 0 : _modernjsConfig_server.ssr));
|
|
259
254
|
api.modifyBundlerChain((chain)=>{
|
|
255
|
+
var _modernjsConfig_source, _targetMFConfig_experiments;
|
|
260
256
|
const target = chain.get('target');
|
|
261
257
|
if ((0, external_utils_js_namespaceObject.skipByTarget)(target)) return;
|
|
262
258
|
const isWeb = (0, external_utils_js_namespaceObject.isWebTarget)(target);
|
|
263
259
|
addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
|
|
264
260
|
const targetMFConfig = isWeb ? csrConfig : ssrConfig;
|
|
265
|
-
patchMFConfig(targetMFConfig, !isWeb
|
|
261
|
+
patchMFConfig(targetMFConfig, !isWeb);
|
|
262
|
+
if ((null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) !== true && (null == (_targetMFConfig_experiments = targetMFConfig.experiments) ? void 0 : _targetMFConfig_experiments.asyncStartup) !== false) {
|
|
263
|
+
var _targetMFConfig;
|
|
264
|
+
(_targetMFConfig = targetMFConfig).experiments || (_targetMFConfig.experiments = {});
|
|
265
|
+
targetMFConfig.experiments.asyncStartup = true;
|
|
266
|
+
}
|
|
266
267
|
patchBundlerConfig({
|
|
267
268
|
chain,
|
|
268
269
|
isServer: !isWeb,
|
|
@@ -282,9 +283,6 @@ var __webpack_exports__ = {};
|
|
|
282
283
|
api.config(()=>{
|
|
283
284
|
var _ref;
|
|
284
285
|
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_dev;
|
|
285
|
-
const ipv4 = (0, external_utils_js_namespaceObject.getIPV4)();
|
|
286
|
-
if (void 0 === userConfig.remoteIpStrategy) if (enableSSR) userConfig.remoteIpStrategy = 'ipv4';
|
|
287
|
-
else userConfig.remoteIpStrategy = 'inherit';
|
|
288
286
|
const devServerConfig = null == (_modernjsConfig_tools = modernjsConfig.tools) ? void 0 : _modernjsConfig_tools.devServer;
|
|
289
287
|
const corsWarnMsgs = [
|
|
290
288
|
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
@@ -298,10 +296,6 @@ var __webpack_exports__ = {};
|
|
|
298
296
|
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
299
297
|
'Access-Control-Allow-Headers': '*'
|
|
300
298
|
} : void 0;
|
|
301
|
-
const defineConfig = {
|
|
302
|
-
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
303
|
-
};
|
|
304
|
-
if (enableSSR && (0, external_utils_js_namespaceObject.isDev)()) defineConfig['FEDERATION_IPV4'] = JSON.stringify(ipv4);
|
|
305
299
|
return {
|
|
306
300
|
tools: {
|
|
307
301
|
devServer: {
|
|
@@ -314,7 +308,6 @@ var __webpack_exports__ = {};
|
|
|
314
308
|
}
|
|
315
309
|
},
|
|
316
310
|
source: {
|
|
317
|
-
define: defineConfig,
|
|
318
311
|
enableAsyncEntry: null != (_ref = null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) ? _ref : true
|
|
319
312
|
},
|
|
320
313
|
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,
|
|
@@ -5,10 +5,11 @@ import { _ as _object_spread_props__ } from "@swc/helpers/_/_object_spread_props
|
|
|
5
5
|
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
|
+
import fs from "fs";
|
|
8
9
|
import path from "path";
|
|
9
|
-
import {
|
|
10
|
+
import { isDev, isWebTarget, skipByTarget } from "./utils.mjs";
|
|
10
11
|
import { encodeName } from "@module-federation/sdk";
|
|
11
|
-
import {
|
|
12
|
+
import { PLUGIN_IDENTIFIER } from "../constant.mjs";
|
|
12
13
|
import { addDataFetchExposes, autoDeleteSplitChunkCacheGroups } from "@module-federation/rsbuild-plugin/utils";
|
|
13
14
|
import logger from "../logger.mjs";
|
|
14
15
|
var __webpack_modules__ = {
|
|
@@ -27,6 +28,28 @@ function __webpack_require__(moduleId) {
|
|
|
27
28
|
return module.exports;
|
|
28
29
|
}
|
|
29
30
|
var defaultPath = path.resolve(process.cwd(), 'module-federation.config.ts');
|
|
31
|
+
var resolvePackageFile = function(packageName, esmRelativePath, cjsRelativePath) {
|
|
32
|
+
var packageEntry = require.resolve(packageName);
|
|
33
|
+
var packageRoot = path.dirname(packageEntry);
|
|
34
|
+
while(!fs.existsSync(path.join(packageRoot, 'package.json'))){
|
|
35
|
+
var parentDir = path.dirname(packageRoot);
|
|
36
|
+
if (parentDir === packageRoot) throw new Error("Unable to resolve package root for ".concat(packageName, " from ").concat(packageEntry));
|
|
37
|
+
packageRoot = parentDir;
|
|
38
|
+
}
|
|
39
|
+
return require.resolve(path.join(packageRoot, 'true' === process.env.IS_ESM_BUILD ? esmRelativePath : cjsRelativePath));
|
|
40
|
+
};
|
|
41
|
+
var resolveSharedStrategyPlugin = function() {
|
|
42
|
+
return resolvePackageFile('@module-federation/modern-js-v3', 'dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs', 'dist/cjs/cli/mfRuntimePlugins/shared-strategy.js');
|
|
43
|
+
};
|
|
44
|
+
var resolveInjectNodeFetchPlugin = function() {
|
|
45
|
+
return resolvePackageFile('@module-federation/modern-js-v3', 'dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs', 'dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js');
|
|
46
|
+
};
|
|
47
|
+
var resolveNodeRuntimePlugin = function() {
|
|
48
|
+
return resolvePackageFile('@module-federation/node', 'dist/src/runtimePlugin.mjs', 'dist/src/runtimePlugin.js');
|
|
49
|
+
};
|
|
50
|
+
var resolveNodeRecordRemoteHashPlugin = function() {
|
|
51
|
+
return resolvePackageFile('@module-federation/node', 'dist/src/recordDynamicRemoteEntryHashPlugin.mjs', 'dist/src/recordDynamicRemoteEntryHashPlugin.js');
|
|
52
|
+
};
|
|
30
53
|
function setEnv(enableSSR) {
|
|
31
54
|
if (enableSSR) process.env['MF_SSR_PRJ'] = 'true';
|
|
32
55
|
}
|
|
@@ -44,8 +67,7 @@ var getMFConfig = function(userConfig) {
|
|
|
44
67
|
mfConfigPath = configPath ? configPath : defaultPath;
|
|
45
68
|
createJiti = __webpack_require__("jiti").createJiti;
|
|
46
69
|
jit = createJiti(__filename, {
|
|
47
|
-
interopDefault: true
|
|
48
|
-
esmResolve: true
|
|
70
|
+
interopDefault: true
|
|
49
71
|
});
|
|
50
72
|
return [
|
|
51
73
|
4,
|
|
@@ -70,24 +92,6 @@ var injectRuntimePlugins = function(runtimePlugin, runtimePlugins) {
|
|
|
70
92
|
});
|
|
71
93
|
if (!hasPlugin) runtimePlugins.push(runtimePlugin);
|
|
72
94
|
};
|
|
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
95
|
var patchDTSConfig = function(mfConfig, isServer) {
|
|
92
96
|
if (isServer) return;
|
|
93
97
|
var ModernJSRuntime = '@module-federation/modern-js-v3/runtime';
|
|
@@ -114,19 +118,17 @@ var patchDTSConfig = function(mfConfig, isServer) {
|
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
};
|
|
117
|
-
var patchMFConfig = function(mfConfig, isServer
|
|
118
|
-
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
121
|
+
var patchMFConfig = function(mfConfig, isServer) {
|
|
119
122
|
addDataFetchExposes(mfConfig.exposes, isServer);
|
|
120
123
|
if (void 0 === mfConfig.remoteType) mfConfig.remoteType = "script";
|
|
121
124
|
if (!mfConfig.name) throw new Error("".concat(PLUGIN_IDENTIFIER, " mfConfig.name can not be empty!"));
|
|
122
125
|
var runtimePlugins = _to_consumable_array__(mfConfig.runtimePlugins || []);
|
|
123
126
|
patchDTSConfig(mfConfig, isServer);
|
|
124
|
-
injectRuntimePlugins(
|
|
125
|
-
if (enableSSR && isDev()) injectRuntimePlugins(require.resolve('@module-federation/modern-js-v3/resolve-entry-ipv4'), runtimePlugins);
|
|
127
|
+
injectRuntimePlugins(resolveSharedStrategyPlugin(), runtimePlugins);
|
|
126
128
|
if (isServer) {
|
|
127
|
-
injectRuntimePlugins(
|
|
128
|
-
if (isDev()) injectRuntimePlugins(
|
|
129
|
-
injectRuntimePlugins(
|
|
129
|
+
injectRuntimePlugins(resolveNodeRuntimePlugin(), runtimePlugins);
|
|
130
|
+
if (isDev()) injectRuntimePlugins(resolveNodeRecordRemoteHashPlugin(), runtimePlugins);
|
|
131
|
+
injectRuntimePlugins(resolveInjectNodeFetchPlugin(), runtimePlugins);
|
|
130
132
|
if (mfConfig.library) {
|
|
131
133
|
if (!mfConfig.library.type) mfConfig.library.type = 'commonjs-module';
|
|
132
134
|
if (!mfConfig.library.name) mfConfig.library.name = mfConfig.name;
|
|
@@ -241,12 +243,18 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
241
243
|
userConfig.csrConfig = csrConfig;
|
|
242
244
|
enableSSR = Boolean(null != (_ref = null == (_userConfig_userConfig = userConfig.userConfig) ? void 0 : _userConfig_userConfig.ssr) ? _ref : Boolean(null == modernjsConfig ? void 0 : null == (_modernjsConfig_server = modernjsConfig.server) ? void 0 : _modernjsConfig_server.ssr));
|
|
243
245
|
api.modifyBundlerChain(function(chain) {
|
|
246
|
+
var _modernjsConfig_source, _targetMFConfig_experiments;
|
|
244
247
|
var target = chain.get('target');
|
|
245
248
|
if (skipByTarget(target)) return;
|
|
246
249
|
var isWeb = isWebTarget(target);
|
|
247
250
|
addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
|
|
248
251
|
var targetMFConfig = isWeb ? csrConfig : ssrConfig;
|
|
249
|
-
patchMFConfig(targetMFConfig, !isWeb
|
|
252
|
+
patchMFConfig(targetMFConfig, !isWeb);
|
|
253
|
+
if ((null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) !== true && (null == (_targetMFConfig_experiments = targetMFConfig.experiments) ? void 0 : _targetMFConfig_experiments.asyncStartup) !== false) {
|
|
254
|
+
var _targetMFConfig;
|
|
255
|
+
(_targetMFConfig = targetMFConfig).experiments || (_targetMFConfig.experiments = {});
|
|
256
|
+
targetMFConfig.experiments.asyncStartup = true;
|
|
257
|
+
}
|
|
250
258
|
patchBundlerConfig({
|
|
251
259
|
chain: chain,
|
|
252
260
|
isServer: !isWeb,
|
|
@@ -266,9 +274,6 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
266
274
|
api.config(function() {
|
|
267
275
|
var _ref;
|
|
268
276
|
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_dev;
|
|
269
|
-
var ipv4 = getIPV4();
|
|
270
|
-
if (void 0 === userConfig.remoteIpStrategy) if (enableSSR) userConfig.remoteIpStrategy = 'ipv4';
|
|
271
|
-
else userConfig.remoteIpStrategy = 'inherit';
|
|
272
277
|
var devServerConfig = null == (_modernjsConfig_tools = modernjsConfig.tools) ? void 0 : _modernjsConfig_tools.devServer;
|
|
273
278
|
var corsWarnMsgs = [
|
|
274
279
|
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
@@ -282,10 +287,6 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
282
287
|
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
283
288
|
'Access-Control-Allow-Headers': '*'
|
|
284
289
|
} : void 0;
|
|
285
|
-
var defineConfig = {
|
|
286
|
-
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
287
|
-
};
|
|
288
|
-
if (enableSSR && isDev()) defineConfig['FEDERATION_IPV4'] = JSON.stringify(ipv4);
|
|
289
290
|
return {
|
|
290
291
|
tools: {
|
|
291
292
|
devServer: {
|
|
@@ -298,7 +299,6 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
298
299
|
}
|
|
299
300
|
},
|
|
300
301
|
source: {
|
|
301
|
-
define: defineConfig,
|
|
302
302
|
enableAsyncEntry: null != (_ref = null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) ? _ref : true
|
|
303
303
|
},
|
|
304
304
|
dev: {
|
package/dist/esm/cli/index.mjs
CHANGED
|
@@ -17,7 +17,6 @@ var moduleFederationPlugin = function() {
|
|
|
17
17
|
assetResources: {},
|
|
18
18
|
distOutputDir: '',
|
|
19
19
|
originPluginOptions: _object_spread__({}, userConfig),
|
|
20
|
-
remoteIpStrategy: null == userConfig ? void 0 : userConfig.remoteIpStrategy,
|
|
21
20
|
userConfig: userConfig || {},
|
|
22
21
|
assetFileNames: {},
|
|
23
22
|
fetchServerQuery: null != (_userConfig_fetchServerQuery = userConfig.fetchServerQuery) ? _userConfig_fetchServerQuery : void 0,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as __rspack_external_jiti from "jiti";
|
|
2
|
+
import fs from "fs";
|
|
2
3
|
import path from "path";
|
|
3
|
-
import {
|
|
4
|
+
import { isDev, isWebTarget, skipByTarget } from "./utils.mjs";
|
|
4
5
|
import { encodeName } from "@module-federation/sdk";
|
|
5
|
-
import {
|
|
6
|
+
import { PLUGIN_IDENTIFIER } from "../constant.mjs";
|
|
6
7
|
import { addDataFetchExposes, autoDeleteSplitChunkCacheGroups } from "@module-federation/rsbuild-plugin/utils";
|
|
7
8
|
import logger from "../logger.mjs";
|
|
8
9
|
var __webpack_modules__ = {
|
|
@@ -21,6 +22,20 @@ function __webpack_require__(moduleId) {
|
|
|
21
22
|
return module.exports;
|
|
22
23
|
}
|
|
23
24
|
const defaultPath = path.resolve(process.cwd(), 'module-federation.config.ts');
|
|
25
|
+
const resolvePackageFile = (packageName, esmRelativePath, cjsRelativePath)=>{
|
|
26
|
+
const packageEntry = require.resolve(packageName);
|
|
27
|
+
let packageRoot = path.dirname(packageEntry);
|
|
28
|
+
while(!fs.existsSync(path.join(packageRoot, 'package.json'))){
|
|
29
|
+
const parentDir = path.dirname(packageRoot);
|
|
30
|
+
if (parentDir === packageRoot) throw new Error(`Unable to resolve package root for ${packageName} from ${packageEntry}`);
|
|
31
|
+
packageRoot = parentDir;
|
|
32
|
+
}
|
|
33
|
+
return require.resolve(path.join(packageRoot, 'true' === process.env.IS_ESM_BUILD ? esmRelativePath : cjsRelativePath));
|
|
34
|
+
};
|
|
35
|
+
const resolveSharedStrategyPlugin = ()=>resolvePackageFile('@module-federation/modern-js-v3', 'dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs', 'dist/cjs/cli/mfRuntimePlugins/shared-strategy.js');
|
|
36
|
+
const resolveInjectNodeFetchPlugin = ()=>resolvePackageFile('@module-federation/modern-js-v3', 'dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs', 'dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js');
|
|
37
|
+
const resolveNodeRuntimePlugin = ()=>resolvePackageFile('@module-federation/node', 'dist/src/runtimePlugin.mjs', 'dist/src/runtimePlugin.js');
|
|
38
|
+
const resolveNodeRecordRemoteHashPlugin = ()=>resolvePackageFile('@module-federation/node', 'dist/src/recordDynamicRemoteEntryHashPlugin.mjs', 'dist/src/recordDynamicRemoteEntryHashPlugin.js');
|
|
24
39
|
function setEnv(enableSSR) {
|
|
25
40
|
if (enableSSR) process.env['MF_SSR_PRJ'] = 'true';
|
|
26
41
|
}
|
|
@@ -30,8 +45,7 @@ const getMFConfig = async (userConfig)=>{
|
|
|
30
45
|
const mfConfigPath = configPath ? configPath : defaultPath;
|
|
31
46
|
const { createJiti } = __webpack_require__("jiti");
|
|
32
47
|
const jit = createJiti(__filename, {
|
|
33
|
-
interopDefault: true
|
|
34
|
-
esmResolve: true
|
|
48
|
+
interopDefault: true
|
|
35
49
|
});
|
|
36
50
|
const configModule = await jit(mfConfigPath);
|
|
37
51
|
const resolvedConfig = configModule && 'object' == typeof configModule && 'default' in configModule ? configModule.default : configModule;
|
|
@@ -45,24 +59,6 @@ const injectRuntimePlugins = (runtimePlugin, runtimePlugins)=>{
|
|
|
45
59
|
});
|
|
46
60
|
if (!hasPlugin) runtimePlugins.push(runtimePlugin);
|
|
47
61
|
};
|
|
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
62
|
const patchDTSConfig = (mfConfig, isServer)=>{
|
|
67
63
|
if (isServer) return;
|
|
68
64
|
const ModernJSRuntime = '@module-federation/modern-js-v3/runtime';
|
|
@@ -89,8 +85,7 @@ const patchDTSConfig = (mfConfig, isServer)=>{
|
|
|
89
85
|
}
|
|
90
86
|
}
|
|
91
87
|
};
|
|
92
|
-
const patchMFConfig = (mfConfig, isServer
|
|
93
|
-
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
88
|
+
const patchMFConfig = (mfConfig, isServer)=>{
|
|
94
89
|
addDataFetchExposes(mfConfig.exposes, isServer);
|
|
95
90
|
if (void 0 === mfConfig.remoteType) mfConfig.remoteType = "script";
|
|
96
91
|
if (!mfConfig.name) throw new Error(`${PLUGIN_IDENTIFIER} mfConfig.name can not be empty!`);
|
|
@@ -98,12 +93,11 @@ const patchMFConfig = (mfConfig, isServer, remoteIpStrategy, enableSSR)=>{
|
|
|
98
93
|
...mfConfig.runtimePlugins || []
|
|
99
94
|
];
|
|
100
95
|
patchDTSConfig(mfConfig, isServer);
|
|
101
|
-
injectRuntimePlugins(
|
|
102
|
-
if (enableSSR && isDev()) injectRuntimePlugins(require.resolve('@module-federation/modern-js-v3/resolve-entry-ipv4'), runtimePlugins);
|
|
96
|
+
injectRuntimePlugins(resolveSharedStrategyPlugin(), runtimePlugins);
|
|
103
97
|
if (isServer) {
|
|
104
|
-
injectRuntimePlugins(
|
|
105
|
-
if (isDev()) injectRuntimePlugins(
|
|
106
|
-
injectRuntimePlugins(
|
|
98
|
+
injectRuntimePlugins(resolveNodeRuntimePlugin(), runtimePlugins);
|
|
99
|
+
if (isDev()) injectRuntimePlugins(resolveNodeRecordRemoteHashPlugin(), runtimePlugins);
|
|
100
|
+
injectRuntimePlugins(resolveInjectNodeFetchPlugin(), runtimePlugins);
|
|
107
101
|
if (mfConfig.library) {
|
|
108
102
|
if (!mfConfig.library.type) mfConfig.library.type = 'commonjs-module';
|
|
109
103
|
if (!mfConfig.library.name) mfConfig.library.name = mfConfig.name;
|
|
@@ -211,12 +205,18 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
211
205
|
userConfig.csrConfig = csrConfig;
|
|
212
206
|
const enableSSR = Boolean(null != (_ref = null == (_userConfig_userConfig = userConfig.userConfig) ? void 0 : _userConfig_userConfig.ssr) ? _ref : Boolean(null == modernjsConfig ? void 0 : null == (_modernjsConfig_server = modernjsConfig.server) ? void 0 : _modernjsConfig_server.ssr));
|
|
213
207
|
api.modifyBundlerChain((chain)=>{
|
|
208
|
+
var _modernjsConfig_source, _targetMFConfig_experiments;
|
|
214
209
|
const target = chain.get('target');
|
|
215
210
|
if (skipByTarget(target)) return;
|
|
216
211
|
const isWeb = isWebTarget(target);
|
|
217
212
|
addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
|
|
218
213
|
const targetMFConfig = isWeb ? csrConfig : ssrConfig;
|
|
219
|
-
patchMFConfig(targetMFConfig, !isWeb
|
|
214
|
+
patchMFConfig(targetMFConfig, !isWeb);
|
|
215
|
+
if ((null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) !== true && (null == (_targetMFConfig_experiments = targetMFConfig.experiments) ? void 0 : _targetMFConfig_experiments.asyncStartup) !== false) {
|
|
216
|
+
var _targetMFConfig;
|
|
217
|
+
(_targetMFConfig = targetMFConfig).experiments || (_targetMFConfig.experiments = {});
|
|
218
|
+
targetMFConfig.experiments.asyncStartup = true;
|
|
219
|
+
}
|
|
220
220
|
patchBundlerConfig({
|
|
221
221
|
chain,
|
|
222
222
|
isServer: !isWeb,
|
|
@@ -236,9 +236,6 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
236
236
|
api.config(()=>{
|
|
237
237
|
var _ref;
|
|
238
238
|
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_dev;
|
|
239
|
-
const ipv4 = getIPV4();
|
|
240
|
-
if (void 0 === userConfig.remoteIpStrategy) if (enableSSR) userConfig.remoteIpStrategy = 'ipv4';
|
|
241
|
-
else userConfig.remoteIpStrategy = 'inherit';
|
|
242
239
|
const devServerConfig = null == (_modernjsConfig_tools = modernjsConfig.tools) ? void 0 : _modernjsConfig_tools.devServer;
|
|
243
240
|
const corsWarnMsgs = [
|
|
244
241
|
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
@@ -252,10 +249,6 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
252
249
|
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
253
250
|
'Access-Control-Allow-Headers': '*'
|
|
254
251
|
} : void 0;
|
|
255
|
-
const defineConfig = {
|
|
256
|
-
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
257
|
-
};
|
|
258
|
-
if (enableSSR && isDev()) defineConfig['FEDERATION_IPV4'] = JSON.stringify(ipv4);
|
|
259
252
|
return {
|
|
260
253
|
tools: {
|
|
261
254
|
devServer: {
|
|
@@ -268,7 +261,6 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
268
261
|
}
|
|
269
262
|
},
|
|
270
263
|
source: {
|
|
271
|
-
define: defineConfig,
|
|
272
264
|
enableAsyncEntry: null != (_ref = null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) ? _ref : true
|
|
273
265
|
},
|
|
274
266
|
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,
|
|
@@ -4,10 +4,17 @@ import { PluginOptions } from '../types';
|
|
|
4
4
|
import type { InternalModernPluginOptions } from '../types';
|
|
5
5
|
import type { AppTools, Rspack, AppUserConfig, CliPlugin } from '@modern-js/app-tools';
|
|
6
6
|
import type { BundlerChainConfig } from '../interfaces/bundler';
|
|
7
|
+
declare global {
|
|
8
|
+
namespace NodeJS {
|
|
9
|
+
interface ProcessEnv {
|
|
10
|
+
IS_ESM_BUILD?: string;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
7
14
|
export type ConfigType = Rspack.Configuration;
|
|
8
15
|
export declare function setEnv(enableSSR: boolean): void;
|
|
9
16
|
export declare const getMFConfig: (userConfig: PluginOptions) => Promise<moduleFederationPlugin.ModuleFederationPluginOptions>;
|
|
10
|
-
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean
|
|
17
|
+
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean) => moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
11
18
|
export declare function addMyTypes2Ignored(chain: BundlerChainConfig, mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions): void;
|
|
12
19
|
export declare function patchBundlerConfig(options: {
|
|
13
20
|
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-v3",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.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
|
],
|
|
@@ -139,13 +131,13 @@
|
|
|
139
131
|
"node-fetch": "~3.3.0",
|
|
140
132
|
"jiti": "2.4.2",
|
|
141
133
|
"react-error-boundary": "4.1.2",
|
|
142
|
-
"@module-federation/rsbuild-plugin": "2.0
|
|
143
|
-
"@module-federation/bridge-react": "2.0
|
|
144
|
-
"@module-federation/enhanced": "2.0
|
|
145
|
-
"@module-federation/
|
|
146
|
-
"@module-federation/
|
|
147
|
-
"@module-federation/
|
|
148
|
-
"@module-federation/
|
|
134
|
+
"@module-federation/rsbuild-plugin": "2.2.0",
|
|
135
|
+
"@module-federation/bridge-react": "2.2.0",
|
|
136
|
+
"@module-federation/enhanced": "2.2.0",
|
|
137
|
+
"@module-federation/node": "2.7.34",
|
|
138
|
+
"@module-federation/cli": "2.2.0",
|
|
139
|
+
"@module-federation/sdk": "2.2.0",
|
|
140
|
+
"@module-federation/runtime": "2.2.0"
|
|
149
141
|
},
|
|
150
142
|
"devDependencies": {
|
|
151
143
|
"@rsbuild/plugin-react": "1.4.5",
|
|
@@ -158,7 +150,9 @@
|
|
|
158
150
|
"@modern-js/tsconfig": "3.0.1",
|
|
159
151
|
"@types/react": "^18.3.11",
|
|
160
152
|
"@types/react-dom": "^18.3.0",
|
|
161
|
-
"
|
|
153
|
+
"react": "~18.3.1",
|
|
154
|
+
"react-dom": "~18.3.1",
|
|
155
|
+
"@module-federation/manifest": "2.2.0"
|
|
162
156
|
},
|
|
163
157
|
"peerDependencies": {
|
|
164
158
|
"react": ">=17",
|
|
@@ -183,6 +177,9 @@
|
|
|
183
177
|
}
|
|
184
178
|
},
|
|
185
179
|
"scripts": {
|
|
186
|
-
"build": "rslib build"
|
|
180
|
+
"build": "rslib build",
|
|
181
|
+
"lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\"",
|
|
182
|
+
"test": "pnpm exec vitest run --passWithNoTests --config vite.config.mts",
|
|
183
|
+
"pre-release": "pnpm run test && pnpm run build"
|
|
187
184
|
}
|
|
188
185
|
}
|
package/dist/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-present zhanghang(2heal1)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -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 };
|