@module-federation/modern-js 0.0.0-release-v0-22-0-20251218063649 → 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 +281 -254
- package/dist/cjs/cli/index.js +6 -4
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +3 -3
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +5 -5
- package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +5 -5
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +3 -3
- package/dist/cjs/cli/ssrPlugin.js +6 -9
- package/dist/cjs/cli/utils.js +3 -3
- package/dist/cjs/constant.js +3 -3
- package/dist/cjs/interfaces/bundler.js +2 -2
- package/dist/cjs/logger.js +3 -3
- package/dist/cjs/react/index.js +7 -9
- package/dist/cjs/react/plugin.js +10 -12
- package/dist/cjs/react/v18.js +7 -9
- package/dist/cjs/react/v19.js +7 -9
- package/dist/cjs/runtime/index.js +7 -9
- package/dist/cjs/server/fileCache.js +3 -3
- package/dist/cjs/server/index.js +3 -3
- package/dist/cjs/server/staticMiddleware.js +3 -3
- package/dist/cjs/ssr-runtime/SSRLiveReload.js +5 -4
- package/dist/cjs/ssr-runtime/devPlugin.js +13 -5
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +3 -3
- package/dist/cjs/types/index.js +2 -2
- package/dist/esm/cli/configPlugin.mjs +38 -16
- package/dist/esm/cli/index.mjs +2 -1
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +2 -2
- package/dist/esm/cli/ssrPlugin.mjs +3 -6
- package/dist/esm/ssr-runtime/SSRLiveReload.mjs +2 -1
- package/dist/esm/ssr-runtime/devPlugin.mjs +9 -2
- package/dist/esm-node/cli/configPlugin.mjs +36 -9
- package/dist/esm-node/cli/index.mjs +3 -1
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +2 -2
- package/dist/esm-node/cli/ssrPlugin.mjs +3 -6
- package/dist/esm-node/ssr-runtime/SSRLiveReload.mjs +2 -1
- package/dist/esm-node/ssr-runtime/devPlugin.mjs +10 -2
- package/package.json +18 -18
|
@@ -13,7 +13,7 @@ var __webpack_require__ = {};
|
|
|
13
13
|
})();
|
|
14
14
|
(()=>{
|
|
15
15
|
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if (
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
17
|
value: 'Module'
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -40,9 +40,9 @@ const injectDataFetchFunctionPlugin = ({ fetchServerQuery })=>({
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
exports.injectDataFetchFunctionPlugin = __webpack_exports__.injectDataFetchFunctionPlugin;
|
|
43
|
-
for(var
|
|
43
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
44
44
|
"injectDataFetchFunctionPlugin"
|
|
45
|
-
].indexOf(
|
|
45
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
46
46
|
Object.defineProperty(exports, '__esModule', {
|
|
47
47
|
value: true
|
|
48
48
|
});
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
4
|
__webpack_require__.r = (exports1)=>{
|
|
5
|
-
if (
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
6
|
value: 'Module'
|
|
7
7
|
});
|
|
8
8
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -12,7 +12,7 @@ var __webpack_require__ = {};
|
|
|
12
12
|
})();
|
|
13
13
|
var __webpack_exports__ = {};
|
|
14
14
|
__webpack_require__.r(__webpack_exports__);
|
|
15
|
-
for(var
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
16
|
Object.defineProperty(exports, '__esModule', {
|
|
17
17
|
value: true
|
|
18
18
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as __rspack_external_jiti from "jiti";
|
|
1
2
|
import { _ } from "@swc/helpers/_/_async_to_generator";
|
|
2
3
|
import { _ as _object_spread__ } from "@swc/helpers/_/_object_spread";
|
|
3
4
|
import { _ as _object_spread_props__ } from "@swc/helpers/_/_object_spread_props";
|
|
@@ -7,17 +8,31 @@ import { _ as _ts_generator__ } from "@swc/helpers/_/_ts_generator";
|
|
|
7
8
|
import path from "path";
|
|
8
9
|
import { getIPV4, isDev, isWebTarget, skipByTarget } from "./utils.mjs";
|
|
9
10
|
import { encodeName } from "@module-federation/sdk";
|
|
10
|
-
import { bundle } from "@modern-js/node-bundle-require";
|
|
11
11
|
import { LOCALHOST, PLUGIN_IDENTIFIER } from "../constant.mjs";
|
|
12
12
|
import { addDataFetchExposes, autoDeleteSplitChunkCacheGroups } from "@module-federation/rsbuild-plugin/utils";
|
|
13
13
|
import logger from "../logger.mjs";
|
|
14
|
+
var __webpack_modules__ = {
|
|
15
|
+
jiti: function(module) {
|
|
16
|
+
module.exports = __rspack_external_jiti;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var __webpack_module_cache__ = {};
|
|
20
|
+
function __webpack_require__(moduleId) {
|
|
21
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
22
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
23
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
24
|
+
exports: {}
|
|
25
|
+
};
|
|
26
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
27
|
+
return module.exports;
|
|
28
|
+
}
|
|
14
29
|
var defaultPath = path.resolve(process.cwd(), 'module-federation.config.ts');
|
|
15
30
|
function setEnv(enableSSR) {
|
|
16
31
|
if (enableSSR) process.env['MF_SSR_PRJ'] = 'true';
|
|
17
32
|
}
|
|
18
33
|
var getMFConfig = function(userConfig) {
|
|
19
34
|
return _(function() {
|
|
20
|
-
var config, configPath, mfConfigPath,
|
|
35
|
+
var config, configPath, mfConfigPath, createJiti, jit, configModule, resolvedConfig;
|
|
21
36
|
return _ts_generator__(this, function(_state) {
|
|
22
37
|
switch(_state.label){
|
|
23
38
|
case 0:
|
|
@@ -27,21 +42,21 @@ var getMFConfig = function(userConfig) {
|
|
|
27
42
|
config
|
|
28
43
|
];
|
|
29
44
|
mfConfigPath = configPath ? configPath : defaultPath;
|
|
45
|
+
createJiti = __webpack_require__("jiti").createJiti;
|
|
46
|
+
jit = createJiti(__filename, {
|
|
47
|
+
interopDefault: true,
|
|
48
|
+
esmResolve: true
|
|
49
|
+
});
|
|
30
50
|
return [
|
|
31
51
|
4,
|
|
32
|
-
|
|
52
|
+
jit(mfConfigPath)
|
|
33
53
|
];
|
|
34
54
|
case 1:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
4,
|
|
38
|
-
import(preBundlePath)
|
|
39
|
-
];
|
|
40
|
-
case 2:
|
|
41
|
-
mfConfig = _state.sent().default;
|
|
55
|
+
configModule = _state.sent();
|
|
56
|
+
resolvedConfig = configModule && (void 0 === configModule ? "undefined" : _type_of__(configModule)) === 'object' && 'default' in configModule ? configModule.default : configModule;
|
|
42
57
|
return [
|
|
43
58
|
2,
|
|
44
|
-
|
|
59
|
+
resolvedConfig
|
|
45
60
|
];
|
|
46
61
|
}
|
|
47
62
|
});
|
|
@@ -209,7 +224,7 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
209
224
|
],
|
|
210
225
|
setup: function(api) {
|
|
211
226
|
return _(function() {
|
|
212
|
-
var _userConfig_userConfig, _modernjsConfig_server, modernjsConfig, mfConfig, csrConfig, ssrConfig,
|
|
227
|
+
var _userConfig_userConfig, _modernjsConfig_server, modernjsConfig, mfConfig, csrConfig, ssrConfig, _ref, enableSSR;
|
|
213
228
|
return _ts_generator__(this, function(_state) {
|
|
214
229
|
switch(_state.label){
|
|
215
230
|
case 0:
|
|
@@ -224,7 +239,7 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
224
239
|
ssrConfig = userConfig.ssrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
225
240
|
userConfig.ssrConfig = ssrConfig;
|
|
226
241
|
userConfig.csrConfig = csrConfig;
|
|
227
|
-
enableSSR = Boolean(null != (
|
|
242
|
+
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));
|
|
228
243
|
api.modifyBundlerChain(function(chain) {
|
|
229
244
|
var target = chain.get('target');
|
|
230
245
|
if (skipByTarget(target)) return;
|
|
@@ -239,7 +254,14 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
239
254
|
mfConfig: mfConfig,
|
|
240
255
|
enableSSR: enableSSR
|
|
241
256
|
});
|
|
242
|
-
userConfig.distOutputDir = chain.output.get('path') || path.resolve(process.cwd(), 'dist');
|
|
257
|
+
if (isWeb) userConfig.distOutputDir = chain.output.get('path') || path.resolve(process.cwd(), 'dist');
|
|
258
|
+
else if (enableSSR) {
|
|
259
|
+
var _userConfig, _userConfig_userConfig;
|
|
260
|
+
(_userConfig = userConfig).userConfig || (_userConfig.userConfig = {});
|
|
261
|
+
(_userConfig_userConfig = userConfig.userConfig).ssr || (_userConfig_userConfig.ssr = {});
|
|
262
|
+
if (true === userConfig.userConfig.ssr) userConfig.userConfig.ssr = {};
|
|
263
|
+
userConfig.userConfig.ssr.distOutputDir = chain.output.get('path') || path.resolve(process.cwd(), 'dist/bundles');
|
|
264
|
+
}
|
|
243
265
|
});
|
|
244
266
|
api.config(function() {
|
|
245
267
|
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
@@ -264,7 +286,7 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
264
286
|
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
265
287
|
};
|
|
266
288
|
if (enableSSR && isDev()) defineConfig['FEDERATION_IPV4'] = JSON.stringify(ipv4);
|
|
267
|
-
var
|
|
289
|
+
var _ref;
|
|
268
290
|
return {
|
|
269
291
|
tools: {
|
|
270
292
|
devServer: {
|
|
@@ -278,7 +300,7 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
278
300
|
},
|
|
279
301
|
source: {
|
|
280
302
|
define: defineConfig,
|
|
281
|
-
enableAsyncEntry: 'rspack' === bundlerType ? null != (
|
|
303
|
+
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
|
|
282
304
|
},
|
|
283
305
|
dev: {
|
|
284
306
|
assetPrefix: (null == modernjsConfig ? void 0 : null == (_modernjsConfig_dev = modernjsConfig.dev) ? void 0 : _modernjsConfig_dev.assetPrefix) ? modernjsConfig.dev.assetPrefix : true
|
package/dist/esm/cli/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { _ } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _object_spread__ } from "@swc/helpers/_/_object_spread";
|
|
2
3
|
import { _ as _type_of__ } from "@swc/helpers/_/_type_of";
|
|
3
4
|
import { _ as _ts_generator__ } from "@swc/helpers/_/_ts_generator";
|
|
4
5
|
import { AsyncBoundaryPlugin, ModuleFederationPlugin, createModuleFederationConfig } from "@module-federation/enhanced";
|
|
@@ -16,7 +17,7 @@ var moduleFederationPlugin = function() {
|
|
|
16
17
|
nodePlugin: void 0,
|
|
17
18
|
assetResources: {},
|
|
18
19
|
distOutputDir: '',
|
|
19
|
-
originPluginOptions: userConfig,
|
|
20
|
+
originPluginOptions: _object_spread__({}, userConfig),
|
|
20
21
|
remoteIpStrategy: null == userConfig ? void 0 : userConfig.remoteIpStrategy,
|
|
21
22
|
userConfig: userConfig || {},
|
|
22
23
|
assetFileNames: {},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { _ } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator__ } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import { LOCALHOST } from "../../constant.mjs";
|
|
4
|
-
var ipv4 =
|
|
5
|
-
var remoteIpStrategy =
|
|
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
6
|
function replaceObjectLocalhost(key, obj) {
|
|
7
7
|
if ('ipv4' !== remoteIpStrategy) return;
|
|
8
8
|
if (!(key in obj)) return;
|
|
@@ -92,7 +92,7 @@ var mfSSRRsbuildPlugin = function(pluginOptions) {
|
|
|
92
92
|
var modifySSRPublicPath = function(config, utils) {
|
|
93
93
|
if (ssrEnv !== utils.environment.name) return config;
|
|
94
94
|
var userSSRConfig = pluginOptions.userConfig.ssr ? 'object' === _type_of__(pluginOptions.userConfig.ssr) ? pluginOptions.userConfig.ssr : {} : {};
|
|
95
|
-
if (userSSRConfig.distOutputDir) return;
|
|
95
|
+
if (!userSSRConfig.distOutputDir) return;
|
|
96
96
|
config.output.publicPath = "".concat(config.output.publicPath).concat(path.relative(csrOutputPath, ssrOutputPath), "/");
|
|
97
97
|
return config;
|
|
98
98
|
};
|
|
@@ -131,10 +131,10 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
|
|
|
131
131
|
],
|
|
132
132
|
setup: function(api) {
|
|
133
133
|
return _(function() {
|
|
134
|
-
var _pluginOptions_userConfig, _modernjsConfig_server, modernjsConfig,
|
|
134
|
+
var _pluginOptions_userConfig, _modernjsConfig_server, modernjsConfig, _ref, enableSSR, writeMergedManifest;
|
|
135
135
|
return _ts_generator__(this, function(_state) {
|
|
136
136
|
modernjsConfig = api.getConfig();
|
|
137
|
-
enableSSR = null != (
|
|
137
|
+
enableSSR = null != (_ref = null == (_pluginOptions_userConfig = pluginOptions.userConfig) ? void 0 : _pluginOptions_userConfig.ssr) ? _ref : Boolean(null == modernjsConfig ? void 0 : null == (_modernjsConfig_server = modernjsConfig.server) ? void 0 : _modernjsConfig_server.ssr);
|
|
138
138
|
if (!enableSSR) return [
|
|
139
139
|
2
|
|
140
140
|
];
|
|
@@ -190,9 +190,6 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
|
|
|
190
190
|
if (!isWeb) {
|
|
191
191
|
chain.target('async-node');
|
|
192
192
|
if (isDev()) chain.plugin('UniverseEntryChunkTrackerPlugin').use(universe_entry_chunk_tracker_plugin);
|
|
193
|
-
var userSSRConfig = pluginOptions.userConfig.ssr ? 'object' === _type_of__(pluginOptions.userConfig.ssr) ? pluginOptions.userConfig.ssr : {} : {};
|
|
194
|
-
var publicPath = chain.output.get('publicPath');
|
|
195
|
-
if (userSSRConfig.distOutputDir && publicPath) chain.output.publicPath("".concat(publicPath).concat(userSSRConfig.distOutputDir, "/"));
|
|
196
193
|
}
|
|
197
194
|
if (isDev() && isWeb) chain.externals({
|
|
198
195
|
'@module-federation/node/utils': 'NOT_USED_IN_BROWSER'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { _ } from "@swc/helpers/_/_tagged_template_literal";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
3
|
function SSRLiveReload_templateObject() {
|
|
3
4
|
var data = _([
|
|
4
5
|
"\n if(",
|
|
@@ -11,7 +12,7 @@ function SSRLiveReload_templateObject() {
|
|
|
11
12
|
}
|
|
12
13
|
function SSRLiveReload() {
|
|
13
14
|
if ('development' !== process.env.NODE_ENV) return null;
|
|
14
|
-
return /*#__PURE__*/
|
|
15
|
+
return /*#__PURE__*/ jsx("script", {
|
|
15
16
|
suppressHydrationWarning: true,
|
|
16
17
|
dangerouslySetInnerHTML: {
|
|
17
18
|
__html: String.raw(SSRLiveReload_templateObject(), globalThis.shouldUpdate)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { _ } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _object_spread__ } from "@swc/helpers/_/_object_spread";
|
|
2
3
|
import { _ as _ts_generator__ } from "@swc/helpers/_/_ts_generator";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
5
|
import { SSRLiveReload } from "./SSRLiveReload.mjs";
|
|
4
6
|
import { flushDataFetch } from "@module-federation/bridge-react/lazy-utils";
|
|
5
7
|
var mfSSRDevPlugin = function() {
|
|
@@ -12,7 +14,7 @@ var mfSSRDevPlugin = function() {
|
|
|
12
14
|
return _ts_generator__(this, function(_state) {
|
|
13
15
|
switch(_state.label){
|
|
14
16
|
case 0:
|
|
15
|
-
if (
|
|
17
|
+
if ("u" > typeof window) return [
|
|
16
18
|
2
|
|
17
19
|
];
|
|
18
20
|
globalThis.shouldUpdate = false;
|
|
@@ -53,7 +55,12 @@ var mfSSRDevPlugin = function() {
|
|
|
53
55
|
});
|
|
54
56
|
api.wrapRoot(function(App) {
|
|
55
57
|
var AppWrapper = function(props) {
|
|
56
|
-
return /*#__PURE__*/
|
|
58
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
59
|
+
children: [
|
|
60
|
+
/*#__PURE__*/ jsx(SSRLiveReload, {}),
|
|
61
|
+
/*#__PURE__*/ jsx(App, _object_spread__({}, props))
|
|
62
|
+
]
|
|
63
|
+
});
|
|
57
64
|
};
|
|
58
65
|
return AppWrapper;
|
|
59
66
|
});
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
import * as __rspack_external_jiti from "jiti";
|
|
1
2
|
import path from "path";
|
|
2
3
|
import { getIPV4, isDev, isWebTarget, skipByTarget } from "./utils.mjs";
|
|
3
4
|
import { encodeName } from "@module-federation/sdk";
|
|
4
|
-
import { bundle } from "@modern-js/node-bundle-require";
|
|
5
5
|
import { LOCALHOST, PLUGIN_IDENTIFIER } from "../constant.mjs";
|
|
6
6
|
import { addDataFetchExposes, autoDeleteSplitChunkCacheGroups } from "@module-federation/rsbuild-plugin/utils";
|
|
7
7
|
import logger from "../logger.mjs";
|
|
8
|
+
var __webpack_modules__ = {
|
|
9
|
+
jiti (module) {
|
|
10
|
+
module.exports = __rspack_external_jiti;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var __webpack_module_cache__ = {};
|
|
14
|
+
function __webpack_require__(moduleId) {
|
|
15
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
16
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
17
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
18
|
+
exports: {}
|
|
19
|
+
};
|
|
20
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
21
|
+
return module.exports;
|
|
22
|
+
}
|
|
8
23
|
const defaultPath = path.resolve(process.cwd(), 'module-federation.config.ts');
|
|
9
24
|
function setEnv(enableSSR) {
|
|
10
25
|
if (enableSSR) process.env['MF_SSR_PRJ'] = 'true';
|
|
@@ -13,9 +28,14 @@ const getMFConfig = async (userConfig)=>{
|
|
|
13
28
|
const { config, configPath } = userConfig;
|
|
14
29
|
if (config) return config;
|
|
15
30
|
const mfConfigPath = configPath ? configPath : defaultPath;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
31
|
+
const { createJiti } = __webpack_require__("jiti");
|
|
32
|
+
const jit = createJiti(__filename, {
|
|
33
|
+
interopDefault: true,
|
|
34
|
+
esmResolve: true
|
|
35
|
+
});
|
|
36
|
+
const configModule = await jit(mfConfigPath);
|
|
37
|
+
const resolvedConfig = configModule && 'object' == typeof configModule && 'default' in configModule ? configModule.default : configModule;
|
|
38
|
+
return resolvedConfig;
|
|
19
39
|
};
|
|
20
40
|
const injectRuntimePlugins = (runtimePlugin, runtimePlugins)=>{
|
|
21
41
|
const pluginName = 'string' == typeof runtimePlugin ? runtimePlugin : runtimePlugin[0];
|
|
@@ -188,8 +208,8 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
188
208
|
const ssrConfig = userConfig.ssrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
189
209
|
userConfig.ssrConfig = ssrConfig;
|
|
190
210
|
userConfig.csrConfig = csrConfig;
|
|
191
|
-
var
|
|
192
|
-
const enableSSR = Boolean(null != (
|
|
211
|
+
var _ref;
|
|
212
|
+
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));
|
|
193
213
|
api.modifyBundlerChain((chain)=>{
|
|
194
214
|
const target = chain.get('target');
|
|
195
215
|
if (skipByTarget(target)) return;
|
|
@@ -204,7 +224,14 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
204
224
|
mfConfig,
|
|
205
225
|
enableSSR
|
|
206
226
|
});
|
|
207
|
-
userConfig.distOutputDir = chain.output.get('path') || path.resolve(process.cwd(), 'dist');
|
|
227
|
+
if (isWeb) userConfig.distOutputDir = chain.output.get('path') || path.resolve(process.cwd(), 'dist');
|
|
228
|
+
else if (enableSSR) {
|
|
229
|
+
var _userConfig, _userConfig_userConfig;
|
|
230
|
+
(_userConfig = userConfig).userConfig || (_userConfig.userConfig = {});
|
|
231
|
+
(_userConfig_userConfig = userConfig.userConfig).ssr || (_userConfig_userConfig.ssr = {});
|
|
232
|
+
if (true === userConfig.userConfig.ssr) userConfig.userConfig.ssr = {};
|
|
233
|
+
userConfig.userConfig.ssr.distOutputDir = chain.output.get('path') || path.resolve(process.cwd(), 'dist/bundles');
|
|
234
|
+
}
|
|
208
235
|
});
|
|
209
236
|
api.config(()=>{
|
|
210
237
|
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
@@ -229,7 +256,7 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
229
256
|
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
230
257
|
};
|
|
231
258
|
if (enableSSR && isDev()) defineConfig['FEDERATION_IPV4'] = JSON.stringify(ipv4);
|
|
232
|
-
var
|
|
259
|
+
var _ref;
|
|
233
260
|
return {
|
|
234
261
|
tools: {
|
|
235
262
|
devServer: {
|
|
@@ -243,7 +270,7 @@ const moduleFederationConfigPlugin = (userConfig)=>({
|
|
|
243
270
|
},
|
|
244
271
|
source: {
|
|
245
272
|
define: defineConfig,
|
|
246
|
-
enableAsyncEntry: 'rspack' === bundlerType ? null != (
|
|
273
|
+
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
|
|
247
274
|
},
|
|
248
275
|
dev: {
|
|
249
276
|
assetPrefix: (null == modernjsConfig ? void 0 : null == (_modernjsConfig_dev = modernjsConfig.dev) ? void 0 : _modernjsConfig_dev.assetPrefix) ? modernjsConfig.dev.assetPrefix : true
|
|
@@ -12,7 +12,9 @@ const moduleFederationPlugin = (userConfig = {})=>{
|
|
|
12
12
|
nodePlugin: void 0,
|
|
13
13
|
assetResources: {},
|
|
14
14
|
distOutputDir: '',
|
|
15
|
-
originPluginOptions:
|
|
15
|
+
originPluginOptions: {
|
|
16
|
+
...userConfig
|
|
17
|
+
},
|
|
16
18
|
remoteIpStrategy: null == userConfig ? void 0 : userConfig.remoteIpStrategy,
|
|
17
19
|
userConfig: userConfig || {},
|
|
18
20
|
assetFileNames: {},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LOCALHOST } from "../../constant.mjs";
|
|
2
|
-
const ipv4 =
|
|
3
|
-
const remoteIpStrategy =
|
|
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
4
|
function replaceObjectLocalhost(key, obj) {
|
|
5
5
|
if ('ipv4' !== remoteIpStrategy) return;
|
|
6
6
|
if (!(key in obj)) return;
|
|
@@ -82,7 +82,7 @@ const mfSSRRsbuildPlugin = (pluginOptions)=>({
|
|
|
82
82
|
const modifySSRPublicPath = (config, utils)=>{
|
|
83
83
|
if (ssrEnv !== utils.environment.name) return config;
|
|
84
84
|
const userSSRConfig = pluginOptions.userConfig.ssr ? 'object' == typeof pluginOptions.userConfig.ssr ? pluginOptions.userConfig.ssr : {} : {};
|
|
85
|
-
if (userSSRConfig.distOutputDir) return;
|
|
85
|
+
if (!userSSRConfig.distOutputDir) return;
|
|
86
86
|
config.output.publicPath = `${config.output.publicPath}${path.relative(csrOutputPath, ssrOutputPath)}/`;
|
|
87
87
|
return config;
|
|
88
88
|
};
|
|
@@ -119,8 +119,8 @@ const moduleFederationSSRPlugin = (pluginOptions)=>({
|
|
|
119
119
|
setup: async (api)=>{
|
|
120
120
|
var _pluginOptions_userConfig, _modernjsConfig_server;
|
|
121
121
|
const modernjsConfig = api.getConfig();
|
|
122
|
-
var
|
|
123
|
-
const enableSSR = null != (
|
|
122
|
+
var _ref;
|
|
123
|
+
const enableSSR = null != (_ref = null == (_pluginOptions_userConfig = pluginOptions.userConfig) ? void 0 : _pluginOptions_userConfig.ssr) ? _ref : Boolean(null == modernjsConfig ? void 0 : null == (_modernjsConfig_server = modernjsConfig.server) ? void 0 : _modernjsConfig_server.ssr);
|
|
124
124
|
if (!enableSSR) return;
|
|
125
125
|
setEnv();
|
|
126
126
|
api._internalRuntimePlugins(({ entrypoint, plugins })=>{
|
|
@@ -172,9 +172,6 @@ const moduleFederationSSRPlugin = (pluginOptions)=>({
|
|
|
172
172
|
if (!isWeb) {
|
|
173
173
|
chain.target('async-node');
|
|
174
174
|
if (isDev()) chain.plugin('UniverseEntryChunkTrackerPlugin').use(universe_entry_chunk_tracker_plugin);
|
|
175
|
-
const userSSRConfig = pluginOptions.userConfig.ssr ? 'object' == typeof pluginOptions.userConfig.ssr ? pluginOptions.userConfig.ssr : {} : {};
|
|
176
|
-
const publicPath = chain.output.get('publicPath');
|
|
177
|
-
if (userSSRConfig.distOutputDir && publicPath) chain.output.publicPath(`${publicPath}${userSSRConfig.distOutputDir}/`);
|
|
178
175
|
}
|
|
179
176
|
if (isDev() && isWeb) chain.externals({
|
|
180
177
|
'@module-federation/node/utils': 'NOT_USED_IN_BROWSER'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
function SSRLiveReload() {
|
|
2
3
|
if ('development' !== process.env.NODE_ENV) return null;
|
|
3
|
-
return /*#__PURE__*/
|
|
4
|
+
return /*#__PURE__*/ jsx("script", {
|
|
4
5
|
suppressHydrationWarning: true,
|
|
5
6
|
dangerouslySetInnerHTML: {
|
|
6
7
|
__html: String.raw`
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
1
2
|
import { SSRLiveReload } from "./SSRLiveReload.mjs";
|
|
2
3
|
import { flushDataFetch } from "@module-federation/bridge-react/lazy-utils";
|
|
3
4
|
const mfSSRDevPlugin = ()=>({
|
|
4
5
|
name: '@module-federation/modern-js',
|
|
5
6
|
setup: (api)=>{
|
|
6
7
|
api.onBeforeRender(async ()=>{
|
|
7
|
-
if (
|
|
8
|
+
if ("u" > typeof window) return;
|
|
8
9
|
globalThis.shouldUpdate = false;
|
|
9
10
|
const nodeUtils = await import("@module-federation/node/utils");
|
|
10
11
|
const shouldUpdate = await nodeUtils.revalidate();
|
|
@@ -17,7 +18,14 @@ const mfSSRDevPlugin = ()=>({
|
|
|
17
18
|
}
|
|
18
19
|
});
|
|
19
20
|
api.wrapRoot((App)=>{
|
|
20
|
-
const AppWrapper = (props)=>/*#__PURE__*/
|
|
21
|
+
const AppWrapper = (props)=>/*#__PURE__*/ jsxs(Fragment, {
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ jsx(SSRLiveReload, {}),
|
|
24
|
+
/*#__PURE__*/ jsx(App, {
|
|
25
|
+
...props
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
});
|
|
21
29
|
return AppWrapper;
|
|
22
30
|
});
|
|
23
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/modern-js",
|
|
3
|
-
"version": "0.0.0-release-v0-
|
|
3
|
+
"version": "0.0.0-release-v0-23-0-20260123023720",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -133,33 +133,33 @@
|
|
|
133
133
|
"author": "hanric <hanric.zhang@gmail.com>",
|
|
134
134
|
"license": "MIT",
|
|
135
135
|
"dependencies": {
|
|
136
|
-
"@modern-js/utils": "2.
|
|
137
|
-
"@modern-js/node-bundle-require": "2.69.3",
|
|
136
|
+
"@modern-js/utils": "2.70.2",
|
|
138
137
|
"fs-extra": "11.3.0",
|
|
139
138
|
"lru-cache": "10.4.3",
|
|
140
139
|
"@swc/helpers": "^0.5.17",
|
|
141
140
|
"node-fetch": "~3.3.0",
|
|
141
|
+
"jiti": "2.4.2",
|
|
142
142
|
"react-error-boundary": "4.1.2",
|
|
143
|
-
"@module-federation/rsbuild-plugin": "0.0.0-release-v0-
|
|
144
|
-
"@module-federation/
|
|
145
|
-
"@module-federation/
|
|
146
|
-
"@module-federation/
|
|
147
|
-
"@module-federation/
|
|
148
|
-
"@module-federation/sdk": "0.0.0-release-v0-
|
|
149
|
-
"@module-federation/
|
|
143
|
+
"@module-federation/rsbuild-plugin": "0.0.0-release-v0-23-0-20260123023720",
|
|
144
|
+
"@module-federation/enhanced": "0.0.0-release-v0-23-0-20260123023720",
|
|
145
|
+
"@module-federation/runtime": "0.0.0-release-v0-23-0-20260123023720",
|
|
146
|
+
"@module-federation/node": "0.0.0-release-v0-23-0-20260123023720",
|
|
147
|
+
"@module-federation/cli": "0.0.0-release-v0-23-0-20260123023720",
|
|
148
|
+
"@module-federation/sdk": "0.0.0-release-v0-23-0-20260123023720",
|
|
149
|
+
"@module-federation/bridge-react": "0.0.0-release-v0-23-0-20260123023720"
|
|
150
150
|
},
|
|
151
151
|
"devDependencies": {
|
|
152
|
-
"@
|
|
153
|
-
"@
|
|
152
|
+
"@rsbuild/plugin-react": "1.4.2",
|
|
153
|
+
"@rslib/core": "0.18.5",
|
|
154
154
|
"@rsbuild/core": "1.3.21",
|
|
155
|
-
"@modern-js/app-tools": "2.
|
|
156
|
-
"@modern-js/server-runtime": "2.
|
|
157
|
-
"@modern-js/module-tools": "2.
|
|
158
|
-
"@modern-js/runtime": "2.
|
|
159
|
-
"@modern-js/tsconfig": "2.
|
|
155
|
+
"@modern-js/app-tools": "2.70.2",
|
|
156
|
+
"@modern-js/server-runtime": "2.70.2",
|
|
157
|
+
"@modern-js/module-tools": "2.70.2",
|
|
158
|
+
"@modern-js/runtime": "2.70.2",
|
|
159
|
+
"@modern-js/tsconfig": "2.70.2",
|
|
160
160
|
"@types/react": "^18.3.11",
|
|
161
161
|
"@types/react-dom": "^18.3.0",
|
|
162
|
-
"@module-federation/manifest": "0.0.0-release-v0-
|
|
162
|
+
"@module-federation/manifest": "0.0.0-release-v0-23-0-20260123023720"
|
|
163
163
|
},
|
|
164
164
|
"peerDependencies": {
|
|
165
165
|
"react": ">=17",
|