@module-federation/modern-js 0.0.0-release-v0-21-5-20251120103315 → 0.0.0-release-v0-23-0-20260123023720
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 +341 -377
- package/dist/cjs/cli/index.js +103 -93
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +51 -41
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +73 -75
- package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +50 -40
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +55 -44
- package/dist/cjs/cli/ssrPlugin.js +266 -298
- package/dist/cjs/cli/utils.js +84 -81
- package/dist/cjs/constant.js +37 -28
- package/dist/cjs/interfaces/bundler.js +17 -15
- package/dist/cjs/logger.js +37 -25
- package/dist/cjs/react/index.js +55 -19
- package/dist/cjs/react/plugin.js +62 -37
- package/dist/cjs/react/v18.js +55 -19
- package/dist/cjs/react/v19.js +55 -19
- package/dist/cjs/runtime/index.js +55 -19
- package/dist/cjs/server/fileCache.js +76 -76
- package/dist/cjs/server/index.js +65 -57
- package/dist/cjs/server/staticMiddleware.js +84 -84
- package/dist/cjs/ssr-runtime/SSRLiveReload.js +40 -34
- package/dist/cjs/ssr-runtime/devPlugin.js +63 -67
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +44 -36
- package/dist/cjs/types/index.js +17 -15
- package/dist/esm/cli/configPlugin.mjs +320 -0
- package/dist/esm/cli/index.mjs +83 -0
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs +12 -0
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +58 -0
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs +21 -0
- package/dist/esm/cli/server/data-fetch-server-plugin.mjs +17 -0
- package/dist/esm/cli/ssrPlugin.mjs +254 -0
- package/dist/esm/cli/utils.mjs +40 -0
- package/dist/esm/constant.mjs +3 -0
- package/dist/esm/logger.mjs +5 -0
- package/dist/esm/react/plugin.mjs +3 -0
- package/dist/esm/server/fileCache.mjs +90 -0
- package/dist/esm/server/index.mjs +36 -0
- package/dist/esm/server/staticMiddleware.mjs +87 -0
- package/dist/esm/ssr-runtime/SSRLiveReload.mjs +22 -0
- package/dist/esm/ssr-runtime/devPlugin.mjs +70 -0
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.mjs +34 -0
- package/dist/esm-node/cli/configPlugin.mjs +283 -0
- package/dist/esm-node/cli/index.mjs +67 -0
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.mjs +10 -0
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +46 -0
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.mjs +19 -0
- package/dist/esm-node/cli/server/data-fetch-server-plugin.mjs +15 -0
- package/dist/esm-node/cli/ssrPlugin.mjs +228 -0
- package/dist/esm-node/cli/utils.mjs +40 -0
- package/dist/esm-node/constant.mjs +3 -0
- package/dist/esm-node/logger.mjs +5 -0
- package/dist/esm-node/react/plugin.mjs +3 -0
- package/dist/esm-node/server/fileCache.mjs +37 -0
- package/dist/esm-node/server/index.mjs +34 -0
- package/dist/esm-node/server/staticMiddleware.mjs +42 -0
- package/dist/esm-node/ssr-runtime/SSRLiveReload.mjs +15 -0
- package/dist/esm-node/ssr-runtime/devPlugin.mjs +33 -0
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.mjs +14 -0
- package/package.json +32 -31
- package/dist/cjs/cli/configPlugin.spec.js +0 -112
- package/dist/cjs/server/fileCache.spec.js +0 -28
- package/dist/cjs/server/staticMiddleware.spec.js +0 -185
- package/dist/esm/cli/configPlugin.js +0 -395
- package/dist/esm/cli/configPlugin.spec.js +0 -108
- package/dist/esm/cli/index.js +0 -92
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js +0 -16
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js +0 -74
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.js +0 -25
- package/dist/esm/cli/server/data-fetch-server-plugin.js +0 -20
- package/dist/esm/cli/ssrPlugin.js +0 -305
- package/dist/esm/cli/utils.js +0 -53
- package/dist/esm/constant.js +0 -6
- package/dist/esm/logger.js +0 -7
- package/dist/esm/react/plugin.js +0 -5
- package/dist/esm/server/fileCache.js +0 -98
- package/dist/esm/server/fileCache.spec.js +0 -50
- package/dist/esm/server/index.js +0 -41
- package/dist/esm/server/staticMiddleware.js +0 -104
- package/dist/esm/server/staticMiddleware.spec.js +0 -328
- package/dist/esm/ssr-runtime/SSRLiveReload.js +0 -26
- package/dist/esm/ssr-runtime/devPlugin.js +0 -73
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js +0 -34
- package/dist/esm-node/cli/configPlugin.js +0 -347
- package/dist/esm-node/cli/configPlugin.spec.js +0 -89
- package/dist/esm-node/cli/index.js +0 -72
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.js +0 -14
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.js +0 -62
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.js +0 -23
- package/dist/esm-node/cli/server/data-fetch-server-plugin.js +0 -18
- package/dist/esm-node/cli/ssrPlugin.js +0 -280
- package/dist/esm-node/cli/utils.js +0 -53
- package/dist/esm-node/constant.js +0 -6
- package/dist/esm-node/logger.js +0 -7
- package/dist/esm-node/react/plugin.js +0 -5
- package/dist/esm-node/server/fileCache.js +0 -49
- package/dist/esm-node/server/fileCache.spec.js +0 -27
- package/dist/esm-node/server/index.js +0 -39
- package/dist/esm-node/server/staticMiddleware.js +0 -55
- package/dist/esm-node/server/staticMiddleware.spec.js +0 -162
- package/dist/esm-node/ssr-runtime/SSRLiveReload.js +0 -19
- package/dist/esm-node/ssr-runtime/devPlugin.js +0 -37
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.js +0 -16
- /package/dist/esm/interfaces/{bundler.js → bundler.mjs} +0 -0
- /package/dist/esm/react/{index.js → index.mjs} +0 -0
- /package/dist/esm/react/{v18.js → v18.mjs} +0 -0
- /package/dist/esm/react/{v19.js → v19.mjs} +0 -0
- /package/dist/esm/runtime/{index.js → index.mjs} +0 -0
- /package/dist/esm/types/{index.js → index.mjs} +0 -0
- /package/dist/esm-node/interfaces/{bundler.js → bundler.mjs} +0 -0
- /package/dist/esm-node/react/{index.js → index.mjs} +0 -0
- /package/dist/esm-node/react/{v18.js → v18.mjs} +0 -0
- /package/dist/esm-node/react/{v19.js → v19.mjs} +0 -0
- /package/dist/esm-node/runtime/{index.js → index.mjs} +0 -0
- /package/dist/esm-node/types/{index.js → index.mjs} +0 -0
|
@@ -1,388 +1,352 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var configPlugin_exports = {};
|
|
30
|
-
__export(configPlugin_exports, {
|
|
31
|
-
addMyTypes2Ignored: () => addMyTypes2Ignored,
|
|
32
|
-
default: () => configPlugin_default,
|
|
33
|
-
getMFConfig: () => getMFConfig,
|
|
34
|
-
isWebTarget: () => import_utils.isWebTarget,
|
|
35
|
-
moduleFederationConfigPlugin: () => moduleFederationConfigPlugin,
|
|
36
|
-
patchBundlerConfig: () => patchBundlerConfig,
|
|
37
|
-
patchMFConfig: () => patchMFConfig,
|
|
38
|
-
setEnv: () => setEnv,
|
|
39
|
-
skipByTarget: () => import_utils.skipByTarget
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(configPlugin_exports);
|
|
42
|
-
var import_path = __toESM(require("path"));
|
|
43
|
-
var import_utils = require("./utils");
|
|
44
|
-
var import_sdk = require("@module-federation/sdk");
|
|
45
|
-
var import_node_bundle_require = require("@modern-js/node-bundle-require");
|
|
46
|
-
var import_constant = require("../constant");
|
|
47
|
-
var import_utils2 = require("@module-federation/rsbuild-plugin/utils");
|
|
48
|
-
var import_logger = __toESM(require("../logger"));
|
|
49
|
-
var import_utils3 = require("./utils");
|
|
50
|
-
const defaultPath = import_path.default.resolve(process.cwd(), "module-federation.config.ts");
|
|
51
|
-
function setEnv(enableSSR) {
|
|
52
|
-
if (enableSSR) {
|
|
53
|
-
process.env["MF_SSR_PRJ"] = "true";
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const getMFConfig = async (userConfig) => {
|
|
57
|
-
const { config, configPath } = userConfig;
|
|
58
|
-
if (config) {
|
|
59
|
-
return config;
|
|
60
|
-
}
|
|
61
|
-
const mfConfigPath = configPath ? configPath : defaultPath;
|
|
62
|
-
const preBundlePath = await (0, import_node_bundle_require.bundle)(mfConfigPath);
|
|
63
|
-
const mfConfig = (await Promise.resolve().then(() => __toESM(require(preBundlePath)))).default;
|
|
64
|
-
return mfConfig;
|
|
65
|
-
};
|
|
66
|
-
const injectRuntimePlugins = (runtimePlugin, runtimePlugins) => {
|
|
67
|
-
const pluginName = typeof runtimePlugin === "string" ? runtimePlugin : runtimePlugin[0];
|
|
68
|
-
const hasPlugin = runtimePlugins.some((existingPlugin) => {
|
|
69
|
-
if (typeof existingPlugin === "string") {
|
|
70
|
-
return existingPlugin === pluginName;
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
jiti (module) {
|
|
4
|
+
module.exports = require("jiti");
|
|
71
5
|
}
|
|
72
|
-
return existingPlugin[0] === pluginName;
|
|
73
|
-
});
|
|
74
|
-
if (!hasPlugin) {
|
|
75
|
-
runtimePlugins.push(runtimePlugin);
|
|
76
|
-
}
|
|
77
6
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
7
|
+
var __webpack_module_cache__ = {};
|
|
8
|
+
function __webpack_require__(moduleId) {
|
|
9
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
+
exports: {}
|
|
13
|
+
};
|
|
14
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
+
return module.exports;
|
|
16
|
+
}
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.n = (module)=>{
|
|
19
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
20
|
+
__webpack_require__.d(getter, {
|
|
21
|
+
a: getter
|
|
22
|
+
});
|
|
23
|
+
return getter;
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
28
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: definition[key]
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
(()=>{
|
|
35
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
36
|
+
})();
|
|
37
|
+
(()=>{
|
|
38
|
+
__webpack_require__.r = (exports1)=>{
|
|
39
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
40
|
+
value: 'Module'
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
43
|
+
value: true
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __webpack_exports__ = {};
|
|
48
|
+
(()=>{
|
|
49
|
+
__webpack_require__.r(__webpack_exports__);
|
|
50
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
51
|
+
patchMFConfig: ()=>patchMFConfig,
|
|
52
|
+
default: ()=>configPlugin,
|
|
53
|
+
getMFConfig: ()=>getMFConfig,
|
|
54
|
+
isWebTarget: ()=>external_utils_js_namespaceObject.isWebTarget,
|
|
55
|
+
moduleFederationConfigPlugin: ()=>moduleFederationConfigPlugin,
|
|
56
|
+
addMyTypes2Ignored: ()=>addMyTypes2Ignored,
|
|
57
|
+
skipByTarget: ()=>external_utils_js_namespaceObject.skipByTarget,
|
|
58
|
+
setEnv: ()=>setEnv,
|
|
59
|
+
patchBundlerConfig: ()=>patchBundlerConfig
|
|
106
60
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
61
|
+
const external_path_namespaceObject = require("path");
|
|
62
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
63
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
64
|
+
const sdk_namespaceObject = require("@module-federation/sdk");
|
|
65
|
+
const external_constant_js_namespaceObject = require("../constant.js");
|
|
66
|
+
const utils_namespaceObject = require("@module-federation/rsbuild-plugin/utils");
|
|
67
|
+
const external_logger_js_namespaceObject = require("../logger.js");
|
|
68
|
+
var external_logger_js_default = /*#__PURE__*/ __webpack_require__.n(external_logger_js_namespaceObject);
|
|
69
|
+
const defaultPath = external_path_default().resolve(process.cwd(), 'module-federation.config.ts');
|
|
70
|
+
function setEnv(enableSSR) {
|
|
71
|
+
if (enableSSR) process.env['MF_SSR_PRJ'] = 'true';
|
|
72
|
+
}
|
|
73
|
+
const getMFConfig = async (userConfig)=>{
|
|
74
|
+
const { config, configPath } = userConfig;
|
|
75
|
+
if (config) return config;
|
|
76
|
+
const mfConfigPath = configPath ? configPath : defaultPath;
|
|
77
|
+
const { createJiti } = __webpack_require__("jiti");
|
|
78
|
+
const jit = createJiti(__filename, {
|
|
79
|
+
interopDefault: true,
|
|
80
|
+
esmResolve: true
|
|
81
|
+
});
|
|
82
|
+
const configModule = await jit(mfConfigPath);
|
|
83
|
+
const resolvedConfig = configModule && 'object' == typeof configModule && 'default' in configModule ? configModule.default : configModule;
|
|
84
|
+
return resolvedConfig;
|
|
85
|
+
};
|
|
86
|
+
const injectRuntimePlugins = (runtimePlugin, runtimePlugins)=>{
|
|
87
|
+
const pluginName = 'string' == typeof runtimePlugin ? runtimePlugin : runtimePlugin[0];
|
|
88
|
+
const hasPlugin = runtimePlugins.some((existingPlugin)=>{
|
|
89
|
+
if ('string' == typeof existingPlugin) return existingPlugin === pluginName;
|
|
90
|
+
return existingPlugin[0] === pluginName;
|
|
91
|
+
});
|
|
92
|
+
if (!hasPlugin) runtimePlugins.push(runtimePlugin);
|
|
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
|
+
});
|
|
133
105
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
+
const patchDTSConfig = (mfConfig, isServer)=>{
|
|
113
|
+
if (isServer) return;
|
|
114
|
+
const ModernJSRuntime = '@module-federation/modern-js/runtime';
|
|
115
|
+
if (false !== mfConfig.dts) {
|
|
116
|
+
var _mfConfig_dts, _mfConfig_dts1;
|
|
117
|
+
if ('boolean' == typeof mfConfig.dts || void 0 === mfConfig.dts) mfConfig.dts = {
|
|
118
|
+
consumeTypes: {
|
|
119
|
+
runtimePkgs: [
|
|
120
|
+
ModernJSRuntime
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
else if ((null == (_mfConfig_dts = mfConfig.dts) ? void 0 : _mfConfig_dts.consumeTypes) || (null == (_mfConfig_dts1 = mfConfig.dts) ? void 0 : _mfConfig_dts1.consumeTypes) === void 0) {
|
|
125
|
+
var _mfConfig_dts2;
|
|
126
|
+
if ('boolean' == typeof mfConfig.dts.consumeTypes || (null == (_mfConfig_dts2 = mfConfig.dts) ? void 0 : _mfConfig_dts2.consumeTypes) === void 0) mfConfig.dts.consumeTypes = {
|
|
127
|
+
runtimePkgs: [
|
|
128
|
+
ModernJSRuntime
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
else {
|
|
132
|
+
mfConfig.dts.consumeTypes.runtimePkgs = mfConfig.dts.consumeTypes.runtimePkgs || [];
|
|
133
|
+
if (!mfConfig.dts.consumeTypes.runtimePkgs.includes(ModernJSRuntime)) mfConfig.dts.consumeTypes.runtimePkgs.push(ModernJSRuntime);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
138
136
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
return mfConfig;
|
|
187
|
-
}
|
|
188
|
-
mfConfig.dts = false;
|
|
189
|
-
mfConfig.dev = false;
|
|
190
|
-
return mfConfig;
|
|
191
|
-
};
|
|
192
|
-
function patchIgnoreWarning(chain) {
|
|
193
|
-
const ignoreWarnings = chain.get("ignoreWarnings") || [];
|
|
194
|
-
const ignoredMsgs = [
|
|
195
|
-
"external script",
|
|
196
|
-
"process.env.WS_NO_BUFFER_UTIL",
|
|
197
|
-
`Can't resolve 'utf-8-validate`
|
|
198
|
-
];
|
|
199
|
-
ignoreWarnings.push((warning) => {
|
|
200
|
-
if (ignoredMsgs.some((msg) => warning.message.includes(msg))) {
|
|
201
|
-
return true;
|
|
202
|
-
}
|
|
203
|
-
return false;
|
|
204
|
-
});
|
|
205
|
-
chain.ignoreWarnings(ignoreWarnings);
|
|
206
|
-
}
|
|
207
|
-
function addMyTypes2Ignored(chain, mfConfig) {
|
|
208
|
-
const watchOptions = chain.get("watchOptions");
|
|
209
|
-
if (!watchOptions || !watchOptions.ignored) {
|
|
210
|
-
chain.watchOptions({
|
|
211
|
-
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
212
|
-
});
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
const ignored = watchOptions.ignored;
|
|
216
|
-
const DEFAULT_IGNORED_GLOB = "**/@mf-types/**";
|
|
217
|
-
if (Array.isArray(ignored)) {
|
|
218
|
-
if (mfConfig.dts !== false && typeof mfConfig.dts === "object" && typeof mfConfig.dts.consumeTypes === "object" && mfConfig.dts.consumeTypes.remoteTypesFolder) {
|
|
219
|
-
chain.watchOptions({
|
|
220
|
-
...watchOptions,
|
|
221
|
-
ignored: ignored.concat(`**/${mfConfig.dts.consumeTypes.remoteTypesFolder}/**`)
|
|
222
|
-
});
|
|
223
|
-
} else {
|
|
224
|
-
chain.watchOptions({
|
|
225
|
-
...watchOptions,
|
|
226
|
-
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
227
|
-
});
|
|
137
|
+
};
|
|
138
|
+
const patchMFConfig = (mfConfig, isServer, remoteIpStrategy, enableSSR)=>{
|
|
139
|
+
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
140
|
+
(0, utils_namespaceObject.addDataFetchExposes)(mfConfig.exposes, isServer);
|
|
141
|
+
if (void 0 === mfConfig.remoteType) mfConfig.remoteType = "script";
|
|
142
|
+
if (!mfConfig.name) throw new Error(`${external_constant_js_namespaceObject.PLUGIN_IDENTIFIER} mfConfig.name can not be empty!`);
|
|
143
|
+
const runtimePlugins = [
|
|
144
|
+
...mfConfig.runtimePlugins || []
|
|
145
|
+
];
|
|
146
|
+
patchDTSConfig(mfConfig, isServer);
|
|
147
|
+
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
|
+
if (isServer) {
|
|
150
|
+
injectRuntimePlugins(require.resolve('@module-federation/node/runtimePlugin'), runtimePlugins);
|
|
151
|
+
if ((0, external_utils_js_namespaceObject.isDev)()) injectRuntimePlugins(require.resolve('@module-federation/node/record-dynamic-remote-entry-hash-plugin'), runtimePlugins);
|
|
152
|
+
injectRuntimePlugins(require.resolve('@module-federation/modern-js/inject-node-fetch'), runtimePlugins);
|
|
153
|
+
if (mfConfig.library) {
|
|
154
|
+
if (!mfConfig.library.type) mfConfig.library.type = 'commonjs-module';
|
|
155
|
+
if (!mfConfig.library.name) mfConfig.library.name = mfConfig.name;
|
|
156
|
+
} else mfConfig.library = {
|
|
157
|
+
type: 'commonjs-module',
|
|
158
|
+
name: mfConfig.name
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
mfConfig.runtimePlugins = runtimePlugins;
|
|
162
|
+
if (!isServer) {
|
|
163
|
+
var _mfConfig_library;
|
|
164
|
+
if ((null == (_mfConfig_library = mfConfig.library) ? void 0 : _mfConfig_library.type) === 'commonjs-module') mfConfig.library.type = 'global';
|
|
165
|
+
return mfConfig;
|
|
166
|
+
}
|
|
167
|
+
mfConfig.dts = false;
|
|
168
|
+
mfConfig.dev = false;
|
|
169
|
+
return mfConfig;
|
|
170
|
+
};
|
|
171
|
+
function patchIgnoreWarning(chain) {
|
|
172
|
+
const ignoreWarnings = chain.get('ignoreWarnings') || [];
|
|
173
|
+
const ignoredMsgs = [
|
|
174
|
+
"external script",
|
|
175
|
+
'process.env.WS_NO_BUFFER_UTIL',
|
|
176
|
+
"Can't resolve 'utf-8-validate"
|
|
177
|
+
];
|
|
178
|
+
ignoreWarnings.push((warning)=>{
|
|
179
|
+
if (ignoredMsgs.some((msg)=>warning.message.includes(msg))) return true;
|
|
180
|
+
return false;
|
|
181
|
+
});
|
|
182
|
+
chain.ignoreWarnings(ignoreWarnings);
|
|
228
183
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (!isServer) {
|
|
256
|
-
(0, import_utils2.autoDeleteSplitChunkCacheGroups)(mfConfig, splitChunkConfig);
|
|
257
|
-
}
|
|
258
|
-
if (!isServer && enableSSR && splitChunkConfig && typeof splitChunkConfig === "object" && splitChunkConfig.cacheGroups) {
|
|
259
|
-
splitChunkConfig.chunks = "async";
|
|
260
|
-
import_logger.default.warn(`splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"`);
|
|
261
|
-
}
|
|
262
|
-
if ((0, import_utils3.isDev)() && chain.output.get("publicPath") === "auto") {
|
|
263
|
-
var _modernjsConfig_dev, _modernjsConfig_server;
|
|
264
|
-
const port = ((_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.port) || ((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.port) || 8080;
|
|
265
|
-
const publicPath = `http://localhost:${port}/`;
|
|
266
|
-
chain.output.publicPath(publicPath);
|
|
267
|
-
}
|
|
268
|
-
if (isServer && enableSSR) {
|
|
269
|
-
const uniqueName = mfConfig.name || chain.output.get("uniqueName");
|
|
270
|
-
const chunkFileName = chain.output.get("chunkFilename");
|
|
271
|
-
if (typeof chunkFileName === "string" && uniqueName && !chunkFileName.includes(uniqueName)) {
|
|
272
|
-
const suffix = `${(0, import_sdk.encodeName)(uniqueName)}-[contenthash].js`;
|
|
273
|
-
chain.output.chunkFilename(chunkFileName.replace(".js", suffix));
|
|
184
|
+
function addMyTypes2Ignored(chain, mfConfig) {
|
|
185
|
+
const watchOptions = chain.get('watchOptions');
|
|
186
|
+
if (!watchOptions || !watchOptions.ignored) return void chain.watchOptions({
|
|
187
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
188
|
+
});
|
|
189
|
+
const ignored = watchOptions.ignored;
|
|
190
|
+
const DEFAULT_IGNORED_GLOB = '**/@mf-types/**';
|
|
191
|
+
if (Array.isArray(ignored)) {
|
|
192
|
+
if (false !== mfConfig.dts && 'object' == typeof mfConfig.dts && 'object' == typeof mfConfig.dts.consumeTypes && mfConfig.dts.consumeTypes.remoteTypesFolder) chain.watchOptions({
|
|
193
|
+
...watchOptions,
|
|
194
|
+
ignored: ignored.concat(`**/${mfConfig.dts.consumeTypes.remoteTypesFolder}/**`)
|
|
195
|
+
});
|
|
196
|
+
else chain.watchOptions({
|
|
197
|
+
...watchOptions,
|
|
198
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
199
|
+
});
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if ('string' != typeof ignored) return void chain.watchOptions({
|
|
203
|
+
...watchOptions,
|
|
204
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
205
|
+
});
|
|
206
|
+
chain.watchOptions({
|
|
207
|
+
...watchOptions,
|
|
208
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
209
|
+
});
|
|
274
210
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
],
|
|
288
|
-
post: [
|
|
289
|
-
"@modern-js/plugin-module-federation"
|
|
290
|
-
],
|
|
291
|
-
setup: async (api) => {
|
|
292
|
-
var _userConfig_userConfig, _modernjsConfig_server;
|
|
293
|
-
const modernjsConfig = api.getConfig();
|
|
294
|
-
const mfConfig = await getMFConfig(userConfig.originPluginOptions);
|
|
295
|
-
const csrConfig = userConfig.csrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
296
|
-
const ssrConfig = userConfig.ssrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
297
|
-
userConfig.ssrConfig = ssrConfig;
|
|
298
|
-
userConfig.csrConfig = csrConfig;
|
|
299
|
-
var _userConfig_userConfig_ssr;
|
|
300
|
-
const enableSSR = Boolean((_userConfig_userConfig_ssr = (_userConfig_userConfig = userConfig.userConfig) === null || _userConfig_userConfig === void 0 ? void 0 : _userConfig_userConfig.ssr) !== null && _userConfig_userConfig_ssr !== void 0 ? _userConfig_userConfig_ssr : Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr));
|
|
301
|
-
api.modifyBundlerChain((chain) => {
|
|
302
|
-
const target = chain.get("target");
|
|
303
|
-
if ((0, import_utils.skipByTarget)(target)) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
const isWeb = (0, import_utils.isWebTarget)(target);
|
|
307
|
-
addMyTypes2Ignored(chain, !isWeb ? ssrConfig : csrConfig);
|
|
308
|
-
const targetMFConfig = !isWeb ? ssrConfig : csrConfig;
|
|
309
|
-
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4", enableSSR);
|
|
310
|
-
patchBundlerConfig({
|
|
311
|
-
chain,
|
|
312
|
-
isServer: !isWeb,
|
|
313
|
-
modernjsConfig,
|
|
314
|
-
mfConfig,
|
|
315
|
-
enableSSR
|
|
316
|
-
});
|
|
317
|
-
userConfig.distOutputDir = chain.output.get("path") || import_path.default.resolve(process.cwd(), "dist");
|
|
318
|
-
});
|
|
319
|
-
api.config(() => {
|
|
320
|
-
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
321
|
-
const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
322
|
-
const ipv4 = (0, import_utils.getIPV4)();
|
|
323
|
-
if (userConfig.remoteIpStrategy === void 0) {
|
|
324
|
-
if (!enableSSR) {
|
|
325
|
-
userConfig.remoteIpStrategy = "inherit";
|
|
326
|
-
} else {
|
|
327
|
-
userConfig.remoteIpStrategy = "ipv4";
|
|
211
|
+
function patchBundlerConfig(options) {
|
|
212
|
+
var _modernjsConfig_deploy;
|
|
213
|
+
const { chain, modernjsConfig, isServer, mfConfig, enableSSR } = options;
|
|
214
|
+
chain.optimization.delete('runtimeChunk');
|
|
215
|
+
patchIgnoreWarning(chain);
|
|
216
|
+
if (!chain.output.get('chunkLoadingGlobal')) chain.output.chunkLoadingGlobal(`chunk_${mfConfig.name}`);
|
|
217
|
+
if (!chain.output.get('uniqueName')) chain.output.uniqueName(mfConfig.name);
|
|
218
|
+
const splitChunkConfig = chain.optimization.splitChunks.entries();
|
|
219
|
+
if (!isServer) (0, utils_namespaceObject.autoDeleteSplitChunkCacheGroups)(mfConfig, splitChunkConfig);
|
|
220
|
+
if (!isServer && enableSSR && splitChunkConfig && 'object' == typeof splitChunkConfig && splitChunkConfig.cacheGroups) {
|
|
221
|
+
splitChunkConfig.chunks = 'async';
|
|
222
|
+
external_logger_js_default().warn('splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"');
|
|
328
223
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (typeof devServerConfig !== "object" || !("headers" in devServerConfig)) {
|
|
335
|
-
corsWarnMsgs.unshift('Detect devServer.headers is empty, mf modern plugin will add default cors header: devServer.headers["Access-Control-Allow-Headers"] = "*". It is recommended to specify an allowlist of trusted origins instead.');
|
|
336
|
-
}
|
|
337
|
-
const exposes = (_userConfig_csrConfig = userConfig.csrConfig) === null || _userConfig_csrConfig === void 0 ? void 0 : _userConfig_csrConfig.exposes;
|
|
338
|
-
const hasExposes = exposes && Array.isArray(exposes) ? exposes.length : Object.keys(exposes !== null && exposes !== void 0 ? exposes : {}).length;
|
|
339
|
-
if (corsWarnMsgs.length > 1 && hasExposes) {
|
|
340
|
-
import_logger.default.warn(corsWarnMsgs.join("\n"));
|
|
341
|
-
}
|
|
342
|
-
const corsHeaders = hasExposes ? {
|
|
343
|
-
"Access-Control-Allow-Origin": "*",
|
|
344
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
345
|
-
"Access-Control-Allow-Headers": "*"
|
|
346
|
-
} : void 0;
|
|
347
|
-
const defineConfig = {
|
|
348
|
-
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
349
|
-
};
|
|
350
|
-
if (enableSSR && (0, import_utils3.isDev)()) {
|
|
351
|
-
defineConfig["FEDERATION_IPV4"] = JSON.stringify(ipv4);
|
|
352
|
-
}
|
|
353
|
-
var _modernjsConfig_source_enableAsyncEntry;
|
|
354
|
-
return {
|
|
355
|
-
tools: {
|
|
356
|
-
devServer: {
|
|
357
|
-
headers: corsHeaders
|
|
358
|
-
}
|
|
359
|
-
},
|
|
360
|
-
resolve: {
|
|
361
|
-
alias: {
|
|
362
|
-
// TODO: deprecated
|
|
363
|
-
"@modern-js/runtime/mf": require.resolve("@module-federation/modern-js/runtime")
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
source: {
|
|
367
|
-
define: defineConfig,
|
|
368
|
-
enableAsyncEntry: bundlerType === "rspack" ? (_modernjsConfig_source_enableAsyncEntry = (_modernjsConfig_source = modernjsConfig.source) === null || _modernjsConfig_source === void 0 ? void 0 : _modernjsConfig_source.enableAsyncEntry) !== null && _modernjsConfig_source_enableAsyncEntry !== void 0 ? _modernjsConfig_source_enableAsyncEntry : true : (_modernjsConfig_source1 = modernjsConfig.source) === null || _modernjsConfig_source1 === void 0 ? void 0 : _modernjsConfig_source1.enableAsyncEntry
|
|
369
|
-
},
|
|
370
|
-
dev: {
|
|
371
|
-
assetPrefix: (modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.assetPrefix) ? modernjsConfig.dev.assetPrefix : true
|
|
224
|
+
if ((0, external_utils_js_namespaceObject.isDev)() && 'auto' === chain.output.get('publicPath')) {
|
|
225
|
+
var _modernjsConfig_dev, _modernjsConfig_server;
|
|
226
|
+
const port = (null == (_modernjsConfig_dev = modernjsConfig.dev) ? void 0 : _modernjsConfig_dev.port) || (null == (_modernjsConfig_server = modernjsConfig.server) ? void 0 : _modernjsConfig_server.port) || 8080;
|
|
227
|
+
const publicPath = `http://localhost:${port}/`;
|
|
228
|
+
chain.output.publicPath(publicPath);
|
|
372
229
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
230
|
+
if (isServer && enableSSR) {
|
|
231
|
+
const uniqueName = mfConfig.name || chain.output.get('uniqueName');
|
|
232
|
+
const chunkFileName = chain.output.get('chunkFilename');
|
|
233
|
+
if ('string' == typeof chunkFileName && uniqueName && !chunkFileName.includes(uniqueName)) {
|
|
234
|
+
const suffix = `${(0, sdk_namespaceObject.encodeName)(uniqueName)}-[contenthash].js`;
|
|
235
|
+
chain.output.chunkFilename(chunkFileName.replace('.js', suffix));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if ((0, external_utils_js_namespaceObject.isDev)() && enableSSR && !isServer) chain.resolve.fallback.set('crypto', false).set('stream', false).set('vm', false);
|
|
239
|
+
if ((null == (_modernjsConfig_deploy = modernjsConfig.deploy) ? void 0 : _modernjsConfig_deploy.microFrontend) && Object.keys(mfConfig.exposes || {}).length) chain.optimization.usedExports(false);
|
|
240
|
+
}
|
|
241
|
+
const moduleFederationConfigPlugin = (userConfig)=>({
|
|
242
|
+
name: '@modern-js/plugin-module-federation-config',
|
|
243
|
+
pre: [
|
|
244
|
+
'@modern-js/plugin-initialize'
|
|
245
|
+
],
|
|
246
|
+
post: [
|
|
247
|
+
'@modern-js/plugin-module-federation'
|
|
248
|
+
],
|
|
249
|
+
setup: async (api)=>{
|
|
250
|
+
var _userConfig_userConfig, _modernjsConfig_server;
|
|
251
|
+
const modernjsConfig = api.getConfig();
|
|
252
|
+
const mfConfig = await getMFConfig(userConfig.originPluginOptions);
|
|
253
|
+
const csrConfig = userConfig.csrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
254
|
+
const ssrConfig = userConfig.ssrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
255
|
+
userConfig.ssrConfig = ssrConfig;
|
|
256
|
+
userConfig.csrConfig = csrConfig;
|
|
257
|
+
var _ref;
|
|
258
|
+
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
|
+
api.modifyBundlerChain((chain)=>{
|
|
260
|
+
const target = chain.get('target');
|
|
261
|
+
if ((0, external_utils_js_namespaceObject.skipByTarget)(target)) return;
|
|
262
|
+
const isWeb = (0, external_utils_js_namespaceObject.isWebTarget)(target);
|
|
263
|
+
addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
|
|
264
|
+
const targetMFConfig = isWeb ? csrConfig : ssrConfig;
|
|
265
|
+
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || 'ipv4', enableSSR);
|
|
266
|
+
patchBundlerConfig({
|
|
267
|
+
chain,
|
|
268
|
+
isServer: !isWeb,
|
|
269
|
+
modernjsConfig,
|
|
270
|
+
mfConfig,
|
|
271
|
+
enableSSR
|
|
272
|
+
});
|
|
273
|
+
if (isWeb) userConfig.distOutputDir = chain.output.get('path') || external_path_default().resolve(process.cwd(), 'dist');
|
|
274
|
+
else if (enableSSR) {
|
|
275
|
+
var _userConfig, _userConfig_userConfig;
|
|
276
|
+
(_userConfig = userConfig).userConfig || (_userConfig.userConfig = {});
|
|
277
|
+
(_userConfig_userConfig = userConfig.userConfig).ssr || (_userConfig_userConfig.ssr = {});
|
|
278
|
+
if (true === userConfig.userConfig.ssr) userConfig.userConfig.ssr = {};
|
|
279
|
+
userConfig.userConfig.ssr.distOutputDir = chain.output.get('path') || external_path_default().resolve(process.cwd(), 'dist/bundles');
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
api.config(()=>{
|
|
283
|
+
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
284
|
+
const bundlerType = 'rspack' === api.getAppContext().bundlerType ? 'rspack' : 'webpack';
|
|
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
|
+
const devServerConfig = null == (_modernjsConfig_tools = modernjsConfig.tools) ? void 0 : _modernjsConfig_tools.devServer;
|
|
289
|
+
const corsWarnMsgs = [
|
|
290
|
+
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
291
|
+
];
|
|
292
|
+
if ('object' != typeof devServerConfig || !('headers' in devServerConfig)) corsWarnMsgs.unshift('Detect devServer.headers is empty, mf modern plugin will add default cors header: devServer.headers["Access-Control-Allow-Headers"] = "*". It is recommended to specify an allowlist of trusted origins instead.');
|
|
293
|
+
const exposes = null == (_userConfig_csrConfig = userConfig.csrConfig) ? void 0 : _userConfig_csrConfig.exposes;
|
|
294
|
+
const hasExposes = exposes && Array.isArray(exposes) ? exposes.length : Object.keys(null != exposes ? exposes : {}).length;
|
|
295
|
+
if (corsWarnMsgs.length > 1 && hasExposes) external_logger_js_default().warn(corsWarnMsgs.join('\n'));
|
|
296
|
+
const corsHeaders = hasExposes ? {
|
|
297
|
+
'Access-Control-Allow-Origin': '*',
|
|
298
|
+
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
299
|
+
'Access-Control-Allow-Headers': '*'
|
|
300
|
+
} : 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
|
+
var _ref;
|
|
306
|
+
return {
|
|
307
|
+
tools: {
|
|
308
|
+
devServer: {
|
|
309
|
+
headers: corsHeaders
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
resolve: {
|
|
313
|
+
alias: {
|
|
314
|
+
'@modern-js/runtime/mf': require.resolve('@module-federation/modern-js/runtime')
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
source: {
|
|
318
|
+
define: defineConfig,
|
|
319
|
+
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
|
+
},
|
|
321
|
+
dev: {
|
|
322
|
+
assetPrefix: (null == modernjsConfig ? void 0 : null == (_modernjsConfig_dev = modernjsConfig.dev) ? void 0 : _modernjsConfig_dev.assetPrefix) ? modernjsConfig.dev.assetPrefix : true
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
const configPlugin = moduleFederationConfigPlugin;
|
|
329
|
+
})();
|
|
330
|
+
exports.addMyTypes2Ignored = __webpack_exports__.addMyTypes2Ignored;
|
|
331
|
+
exports["default"] = __webpack_exports__["default"];
|
|
332
|
+
exports.getMFConfig = __webpack_exports__.getMFConfig;
|
|
333
|
+
exports.isWebTarget = __webpack_exports__.isWebTarget;
|
|
334
|
+
exports.moduleFederationConfigPlugin = __webpack_exports__.moduleFederationConfigPlugin;
|
|
335
|
+
exports.patchBundlerConfig = __webpack_exports__.patchBundlerConfig;
|
|
336
|
+
exports.patchMFConfig = __webpack_exports__.patchMFConfig;
|
|
337
|
+
exports.setEnv = __webpack_exports__.setEnv;
|
|
338
|
+
exports.skipByTarget = __webpack_exports__.skipByTarget;
|
|
339
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
340
|
+
"addMyTypes2Ignored",
|
|
341
|
+
"default",
|
|
342
|
+
"getMFConfig",
|
|
343
|
+
"isWebTarget",
|
|
344
|
+
"moduleFederationConfigPlugin",
|
|
345
|
+
"patchBundlerConfig",
|
|
346
|
+
"patchMFConfig",
|
|
347
|
+
"setEnv",
|
|
348
|
+
"skipByTarget"
|
|
349
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
350
|
+
Object.defineProperty(exports, '__esModule', {
|
|
351
|
+
value: true
|
|
388
352
|
});
|