@module-federation/modern-js 0.0.0-next-20250218110948 → 0.0.0-next-20250219082408
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 +0 -1
- package/dist/cjs/cli/index.js +3 -1
- package/dist/cjs/cli/ssrPlugin.js +21 -18
- package/dist/cjs/cli/utils.js +0 -23
- package/dist/esm/cli/configPlugin.js +0 -1
- package/dist/esm/cli/index.js +3 -1
- package/dist/esm/cli/ssrPlugin.js +20 -19
- package/dist/esm/cli/utils.js +0 -23
- package/dist/esm-node/cli/configPlugin.js +0 -1
- package/dist/esm-node/cli/index.js +3 -1
- package/dist/esm-node/cli/ssrPlugin.js +20 -18
- package/dist/esm-node/cli/utils.js +0 -23
- package/dist/types/cli/ssrPlugin.d.ts +1 -0
- package/package.json +13 -13
|
@@ -57,7 +57,6 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
57
57
|
userConfig.ssrConfig = ssrConfig;
|
|
58
58
|
userConfig.csrConfig = csrConfig;
|
|
59
59
|
api.modifyBundlerChain((chain, { isProd, isServer }) => {
|
|
60
|
-
const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
61
60
|
(0, import_utils.addMyTypes2Ignored)(chain, isServer ? ssrConfig : csrConfig);
|
|
62
61
|
const targetMFConfig = isServer ? ssrConfig : csrConfig;
|
|
63
62
|
(0, import_utils.patchMFConfig)(targetMFConfig, isServer, userConfig.remoteIpStrategy || "ipv4");
|
package/dist/cjs/cli/index.js
CHANGED
|
@@ -43,8 +43,10 @@ const moduleFederationPlugin = (userConfig = {}) => {
|
|
|
43
43
|
name: "@modern-js/plugin-module-federation",
|
|
44
44
|
setup: async (api) => {
|
|
45
45
|
const modernjsConfig = api.getConfig();
|
|
46
|
-
api.modifyBundlerChain((chain, {
|
|
46
|
+
api.modifyBundlerChain((chain, { isServer }) => {
|
|
47
47
|
const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
48
|
+
console.log("index bundlerType", bundlerType);
|
|
49
|
+
console.log("index isServer", isServer);
|
|
48
50
|
const browserPluginOptions = internalModernPluginOptions.csrConfig;
|
|
49
51
|
const MFPlugin = bundlerType === "webpack" ? import_enhanced.ModuleFederationPlugin : import_rspack.ModuleFederationPlugin;
|
|
50
52
|
if (!isServer) {
|
|
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var ssrPlugin_exports = {};
|
|
30
30
|
__export(ssrPlugin_exports, {
|
|
31
|
+
CHAIN_MF_PLUGIN_ID: () => CHAIN_MF_PLUGIN_ID,
|
|
31
32
|
default: () => ssrPlugin_default,
|
|
32
33
|
moduleFederationSSRPlugin: () => moduleFederationSSRPlugin,
|
|
33
34
|
setEnv: () => setEnv
|
|
@@ -45,6 +46,7 @@ function setEnv() {
|
|
|
45
46
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
46
47
|
process.env["MF_SSR_PRJ"] = "true";
|
|
47
48
|
}
|
|
49
|
+
const CHAIN_MF_PLUGIN_ID = "plugin-module-federation-server";
|
|
48
50
|
const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
49
51
|
name: "@modern-js/plugin-module-federation-ssr",
|
|
50
52
|
pre: [
|
|
@@ -55,6 +57,8 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
|
55
57
|
var _pluginOptions_userConfig, _modernjsConfig_server;
|
|
56
58
|
const modernjsConfig = api.getConfig();
|
|
57
59
|
const enableSSR = ((_pluginOptions_userConfig = pluginOptions.userConfig) === null || _pluginOptions_userConfig === void 0 ? void 0 : _pluginOptions_userConfig.ssr) === false ? false : Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
60
|
+
console.log("enableSSR: ", enableSSR);
|
|
61
|
+
console.log("isDev: ", import_constant.isDev);
|
|
58
62
|
if (!enableSSR) {
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
@@ -76,20 +80,31 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
|
76
80
|
plugins
|
|
77
81
|
};
|
|
78
82
|
});
|
|
79
|
-
api.modifyBundlerChain((chain, {
|
|
83
|
+
api.modifyBundlerChain((chain, { isServer }) => {
|
|
80
84
|
const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
85
|
+
console.log("ssrPlugin bundlerType: ", bundlerType);
|
|
86
|
+
console.log("ssrPlugin isServer: ", isServer);
|
|
81
87
|
const MFPlugin = bundlerType === "webpack" ? import_webpack.ModuleFederationPlugin : import_rspack.ModuleFederationPlugin;
|
|
82
88
|
if (isServer) {
|
|
83
|
-
if (!
|
|
84
|
-
chain.plugin(
|
|
89
|
+
if (!chain.plugins.has(CHAIN_MF_PLUGIN_ID)) {
|
|
90
|
+
chain.plugin(CHAIN_MF_PLUGIN_ID).use(MFPlugin, [
|
|
85
91
|
pluginOptions.ssrConfig
|
|
86
92
|
]).init((Plugin, args) => {
|
|
87
93
|
pluginOptions.nodePlugin = new Plugin(args[0]);
|
|
88
94
|
return pluginOptions.nodePlugin;
|
|
89
95
|
});
|
|
90
96
|
}
|
|
91
|
-
}
|
|
92
|
-
|
|
97
|
+
}
|
|
98
|
+
if (isServer) {
|
|
99
|
+
chain.target("async-node");
|
|
100
|
+
if (import_constant.isDev) {
|
|
101
|
+
chain.plugin("UniverseEntryChunkTrackerPlugin").use(import_universe_entry_chunk_tracker_plugin.default);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (import_constant.isDev && !isServer) {
|
|
105
|
+
chain.externals({
|
|
106
|
+
"@module-federation/node/utils": "NOT_USED_IN_BROWSER"
|
|
107
|
+
});
|
|
93
108
|
}
|
|
94
109
|
});
|
|
95
110
|
api.config(() => {
|
|
@@ -120,19 +135,6 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
|
120
135
|
}
|
|
121
136
|
}
|
|
122
137
|
]
|
|
123
|
-
},
|
|
124
|
-
bundlerChain(chain, { isServer }) {
|
|
125
|
-
if (isServer) {
|
|
126
|
-
chain.target("async-node");
|
|
127
|
-
if (import_constant.isDev) {
|
|
128
|
-
chain.plugin("UniverseEntryChunkTrackerPlugin").use(import_universe_entry_chunk_tracker_plugin.default);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (import_constant.isDev && !isServer) {
|
|
132
|
-
chain.externals({
|
|
133
|
-
"@module-federation/node/utils": "NOT_USED_IN_BROWSER"
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
};
|
|
@@ -150,6 +152,7 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
|
150
152
|
var ssrPlugin_default = moduleFederationSSRPlugin;
|
|
151
153
|
// Annotate the CommonJS export names for ESM import in node:
|
|
152
154
|
0 && (module.exports = {
|
|
155
|
+
CHAIN_MF_PLUGIN_ID,
|
|
153
156
|
moduleFederationSSRPlugin,
|
|
154
157
|
setEnv
|
|
155
158
|
});
|
package/dist/cjs/cli/utils.js
CHANGED
|
@@ -228,7 +228,6 @@ function patchBundlerConfig(options) {
|
|
|
228
228
|
const { chain, modernjsConfig, isServer, mfConfig } = options;
|
|
229
229
|
const enableSSR = Boolean((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
230
230
|
chain.optimization.runtimeChunk(false);
|
|
231
|
-
patchIgnoreWarning(chain);
|
|
232
231
|
if (!chain.output.get("chunkLoadingGlobal")) {
|
|
233
232
|
chain.output.chunkLoadingGlobal(`chunk_${mfConfig.name}`);
|
|
234
233
|
}
|
|
@@ -289,28 +288,6 @@ const getIPV4 = () => {
|
|
|
289
288
|
};
|
|
290
289
|
return ipv4Interface.address;
|
|
291
290
|
};
|
|
292
|
-
const SPLIT_CHUNK_MAP = {
|
|
293
|
-
REACT: "react",
|
|
294
|
-
ROUTER: "router",
|
|
295
|
-
LODASH: "lib-lodash",
|
|
296
|
-
ANTD: "lib-antd",
|
|
297
|
-
ARCO: "lib-arco",
|
|
298
|
-
SEMI: "lib-semi",
|
|
299
|
-
AXIOS: "lib-axios"
|
|
300
|
-
};
|
|
301
|
-
const SHARED_SPLIT_CHUNK_MAP = {
|
|
302
|
-
react: SPLIT_CHUNK_MAP.REACT,
|
|
303
|
-
"react-dom": SPLIT_CHUNK_MAP.REACT,
|
|
304
|
-
"react-router": SPLIT_CHUNK_MAP.ROUTER,
|
|
305
|
-
"react-router-dom": SPLIT_CHUNK_MAP.ROUTER,
|
|
306
|
-
"@remix-run/router": SPLIT_CHUNK_MAP.ROUTER,
|
|
307
|
-
lodash: SPLIT_CHUNK_MAP.LODASH,
|
|
308
|
-
"lodash-es": SPLIT_CHUNK_MAP.LODASH,
|
|
309
|
-
antd: SPLIT_CHUNK_MAP.ANTD,
|
|
310
|
-
"@arco-design/web-react": SPLIT_CHUNK_MAP.ARCO,
|
|
311
|
-
"@douyinfe/semi-ui": SPLIT_CHUNK_MAP.SEMI,
|
|
312
|
-
axios: SPLIT_CHUNK_MAP.AXIOS
|
|
313
|
-
};
|
|
314
291
|
// Annotate the CommonJS export names for ESM import in node:
|
|
315
292
|
0 && (module.exports = {
|
|
316
293
|
addMyTypes2Ignored,
|
|
@@ -36,7 +36,6 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
36
36
|
userConfig.csrConfig = csrConfig;
|
|
37
37
|
api.modifyBundlerChain(function(chain, param) {
|
|
38
38
|
var isProd = param.isProd, isServer = param.isServer;
|
|
39
|
-
var bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
40
39
|
addMyTypes2Ignored(chain, isServer ? ssrConfig : csrConfig);
|
|
41
40
|
var targetMFConfig = isServer ? ssrConfig : csrConfig;
|
|
42
41
|
patchMFConfig(targetMFConfig, isServer, userConfig.remoteIpStrategy || "ipv4");
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -25,8 +25,10 @@ var moduleFederationPlugin = function() {
|
|
|
25
25
|
return _ts_generator(this, function(_state) {
|
|
26
26
|
modernjsConfig = api.getConfig();
|
|
27
27
|
api.modifyBundlerChain(function(chain, param) {
|
|
28
|
-
var
|
|
28
|
+
var isServer = param.isServer;
|
|
29
29
|
var bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
30
|
+
console.log("index bundlerType", bundlerType);
|
|
31
|
+
console.log("index isServer", isServer);
|
|
30
32
|
var browserPluginOptions = internalModernPluginOptions.csrConfig;
|
|
31
33
|
var MFPlugin = bundlerType === "webpack" ? WebpackModuleFederationPlugin : RspackModuleFederationPlugin;
|
|
32
34
|
if (!isServer) {
|
|
@@ -12,6 +12,7 @@ function setEnv() {
|
|
|
12
12
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
13
13
|
process.env["MF_SSR_PRJ"] = "true";
|
|
14
14
|
}
|
|
15
|
+
var CHAIN_MF_PLUGIN_ID = "plugin-module-federation-server";
|
|
15
16
|
var moduleFederationSSRPlugin = function(pluginOptions) {
|
|
16
17
|
return {
|
|
17
18
|
name: "@modern-js/plugin-module-federation-ssr",
|
|
@@ -25,6 +26,8 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
|
|
|
25
26
|
return _ts_generator(this, function(_state) {
|
|
26
27
|
modernjsConfig = api.getConfig();
|
|
27
28
|
enableSSR = ((_pluginOptions_userConfig = pluginOptions.userConfig) === null || _pluginOptions_userConfig === void 0 ? void 0 : _pluginOptions_userConfig.ssr) === false ? false : Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
29
|
+
console.log("enableSSR: ", enableSSR);
|
|
30
|
+
console.log("isDev: ", isDev);
|
|
28
31
|
if (!enableSSR) {
|
|
29
32
|
return [
|
|
30
33
|
2
|
|
@@ -50,20 +53,31 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
|
|
|
50
53
|
};
|
|
51
54
|
});
|
|
52
55
|
api.modifyBundlerChain(function(chain, param) {
|
|
53
|
-
var
|
|
56
|
+
var isServer = param.isServer;
|
|
54
57
|
var bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
58
|
+
console.log("ssrPlugin bundlerType: ", bundlerType);
|
|
59
|
+
console.log("ssrPlugin isServer: ", isServer);
|
|
55
60
|
var MFPlugin = bundlerType === "webpack" ? ModuleFederationPlugin : RspackModuleFederationPlugin;
|
|
56
61
|
if (isServer) {
|
|
57
|
-
if (!
|
|
58
|
-
chain.plugin(
|
|
62
|
+
if (!chain.plugins.has(CHAIN_MF_PLUGIN_ID)) {
|
|
63
|
+
chain.plugin(CHAIN_MF_PLUGIN_ID).use(MFPlugin, [
|
|
59
64
|
pluginOptions.ssrConfig
|
|
60
65
|
]).init(function(Plugin, args) {
|
|
61
66
|
pluginOptions.nodePlugin = new Plugin(args[0]);
|
|
62
67
|
return pluginOptions.nodePlugin;
|
|
63
68
|
});
|
|
64
69
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
70
|
+
}
|
|
71
|
+
if (isServer) {
|
|
72
|
+
chain.target("async-node");
|
|
73
|
+
if (isDev) {
|
|
74
|
+
chain.plugin("UniverseEntryChunkTrackerPlugin").use(UniverseEntryChunkTrackerPlugin);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (isDev && !isServer) {
|
|
78
|
+
chain.externals({
|
|
79
|
+
"@module-federation/node/utils": "NOT_USED_IN_BROWSER"
|
|
80
|
+
});
|
|
67
81
|
}
|
|
68
82
|
});
|
|
69
83
|
api.config(function() {
|
|
@@ -94,20 +108,6 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
|
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
110
|
]
|
|
97
|
-
},
|
|
98
|
-
bundlerChain: function bundlerChain(chain, param) {
|
|
99
|
-
var isServer = param.isServer;
|
|
100
|
-
if (isServer) {
|
|
101
|
-
chain.target("async-node");
|
|
102
|
-
if (isDev) {
|
|
103
|
-
chain.plugin("UniverseEntryChunkTrackerPlugin").use(UniverseEntryChunkTrackerPlugin);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (isDev && !isServer) {
|
|
107
|
-
chain.externals({
|
|
108
|
-
"@module-federation/node/utils": "NOT_USED_IN_BROWSER"
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
};
|
|
@@ -133,6 +133,7 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
|
|
|
133
133
|
};
|
|
134
134
|
var ssrPlugin_default = moduleFederationSSRPlugin;
|
|
135
135
|
export {
|
|
136
|
+
CHAIN_MF_PLUGIN_ID,
|
|
136
137
|
ssrPlugin_default as default,
|
|
137
138
|
moduleFederationSSRPlugin,
|
|
138
139
|
setEnv
|
package/dist/esm/cli/utils.js
CHANGED
|
@@ -220,7 +220,6 @@ function patchBundlerConfig(options) {
|
|
|
220
220
|
var chain = options.chain, modernjsConfig = options.modernjsConfig, isServer = options.isServer, mfConfig = options.mfConfig;
|
|
221
221
|
var enableSSR = Boolean((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
222
222
|
chain.optimization.runtimeChunk(false);
|
|
223
|
-
patchIgnoreWarning(chain);
|
|
224
223
|
if (!chain.output.get("chunkLoadingGlobal")) {
|
|
225
224
|
chain.output.chunkLoadingGlobal("chunk_".concat(mfConfig.name));
|
|
226
225
|
}
|
|
@@ -281,28 +280,6 @@ var getIPV4 = function() {
|
|
|
281
280
|
};
|
|
282
281
|
return ipv4Interface.address;
|
|
283
282
|
};
|
|
284
|
-
var SPLIT_CHUNK_MAP = {
|
|
285
|
-
REACT: "react",
|
|
286
|
-
ROUTER: "router",
|
|
287
|
-
LODASH: "lib-lodash",
|
|
288
|
-
ANTD: "lib-antd",
|
|
289
|
-
ARCO: "lib-arco",
|
|
290
|
-
SEMI: "lib-semi",
|
|
291
|
-
AXIOS: "lib-axios"
|
|
292
|
-
};
|
|
293
|
-
var SHARED_SPLIT_CHUNK_MAP = {
|
|
294
|
-
react: SPLIT_CHUNK_MAP.REACT,
|
|
295
|
-
"react-dom": SPLIT_CHUNK_MAP.REACT,
|
|
296
|
-
"react-router": SPLIT_CHUNK_MAP.ROUTER,
|
|
297
|
-
"react-router-dom": SPLIT_CHUNK_MAP.ROUTER,
|
|
298
|
-
"@remix-run/router": SPLIT_CHUNK_MAP.ROUTER,
|
|
299
|
-
lodash: SPLIT_CHUNK_MAP.LODASH,
|
|
300
|
-
"lodash-es": SPLIT_CHUNK_MAP.LODASH,
|
|
301
|
-
antd: SPLIT_CHUNK_MAP.ANTD,
|
|
302
|
-
"@arco-design/web-react": SPLIT_CHUNK_MAP.ARCO,
|
|
303
|
-
"@douyinfe/semi-ui": SPLIT_CHUNK_MAP.SEMI,
|
|
304
|
-
axios: SPLIT_CHUNK_MAP.AXIOS
|
|
305
|
-
};
|
|
306
283
|
export {
|
|
307
284
|
addMyTypes2Ignored,
|
|
308
285
|
getIPV4,
|
|
@@ -22,7 +22,6 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
22
22
|
userConfig.ssrConfig = ssrConfig;
|
|
23
23
|
userConfig.csrConfig = csrConfig;
|
|
24
24
|
api.modifyBundlerChain((chain, { isProd, isServer }) => {
|
|
25
|
-
const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
26
25
|
addMyTypes2Ignored(chain, isServer ? ssrConfig : csrConfig);
|
|
27
26
|
const targetMFConfig = isServer ? ssrConfig : csrConfig;
|
|
28
27
|
patchMFConfig(targetMFConfig, isServer, userConfig.remoteIpStrategy || "ipv4");
|
|
@@ -17,8 +17,10 @@ const moduleFederationPlugin = (userConfig = {}) => {
|
|
|
17
17
|
name: "@modern-js/plugin-module-federation",
|
|
18
18
|
setup: async (api) => {
|
|
19
19
|
const modernjsConfig = api.getConfig();
|
|
20
|
-
api.modifyBundlerChain((chain, {
|
|
20
|
+
api.modifyBundlerChain((chain, { isServer }) => {
|
|
21
21
|
const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
22
|
+
console.log("index bundlerType", bundlerType);
|
|
23
|
+
console.log("index isServer", isServer);
|
|
22
24
|
const browserPluginOptions = internalModernPluginOptions.csrConfig;
|
|
23
25
|
const MFPlugin = bundlerType === "webpack" ? WebpackModuleFederationPlugin : RspackModuleFederationPlugin;
|
|
24
26
|
if (!isServer) {
|
|
@@ -10,6 +10,7 @@ function setEnv() {
|
|
|
10
10
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
11
11
|
process.env["MF_SSR_PRJ"] = "true";
|
|
12
12
|
}
|
|
13
|
+
const CHAIN_MF_PLUGIN_ID = "plugin-module-federation-server";
|
|
13
14
|
const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
14
15
|
name: "@modern-js/plugin-module-federation-ssr",
|
|
15
16
|
pre: [
|
|
@@ -20,6 +21,8 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
|
20
21
|
var _pluginOptions_userConfig, _modernjsConfig_server;
|
|
21
22
|
const modernjsConfig = api.getConfig();
|
|
22
23
|
const enableSSR = ((_pluginOptions_userConfig = pluginOptions.userConfig) === null || _pluginOptions_userConfig === void 0 ? void 0 : _pluginOptions_userConfig.ssr) === false ? false : Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
24
|
+
console.log("enableSSR: ", enableSSR);
|
|
25
|
+
console.log("isDev: ", isDev);
|
|
23
26
|
if (!enableSSR) {
|
|
24
27
|
return;
|
|
25
28
|
}
|
|
@@ -41,20 +44,31 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
|
41
44
|
plugins
|
|
42
45
|
};
|
|
43
46
|
});
|
|
44
|
-
api.modifyBundlerChain((chain, {
|
|
47
|
+
api.modifyBundlerChain((chain, { isServer }) => {
|
|
45
48
|
const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
49
|
+
console.log("ssrPlugin bundlerType: ", bundlerType);
|
|
50
|
+
console.log("ssrPlugin isServer: ", isServer);
|
|
46
51
|
const MFPlugin = bundlerType === "webpack" ? ModuleFederationPlugin : RspackModuleFederationPlugin;
|
|
47
52
|
if (isServer) {
|
|
48
|
-
if (!
|
|
49
|
-
chain.plugin(
|
|
53
|
+
if (!chain.plugins.has(CHAIN_MF_PLUGIN_ID)) {
|
|
54
|
+
chain.plugin(CHAIN_MF_PLUGIN_ID).use(MFPlugin, [
|
|
50
55
|
pluginOptions.ssrConfig
|
|
51
56
|
]).init((Plugin, args) => {
|
|
52
57
|
pluginOptions.nodePlugin = new Plugin(args[0]);
|
|
53
58
|
return pluginOptions.nodePlugin;
|
|
54
59
|
});
|
|
55
60
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
61
|
+
}
|
|
62
|
+
if (isServer) {
|
|
63
|
+
chain.target("async-node");
|
|
64
|
+
if (isDev) {
|
|
65
|
+
chain.plugin("UniverseEntryChunkTrackerPlugin").use(UniverseEntryChunkTrackerPlugin);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (isDev && !isServer) {
|
|
69
|
+
chain.externals({
|
|
70
|
+
"@module-federation/node/utils": "NOT_USED_IN_BROWSER"
|
|
71
|
+
});
|
|
58
72
|
}
|
|
59
73
|
});
|
|
60
74
|
api.config(() => {
|
|
@@ -85,19 +99,6 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
|
85
99
|
}
|
|
86
100
|
}
|
|
87
101
|
]
|
|
88
|
-
},
|
|
89
|
-
bundlerChain(chain, { isServer }) {
|
|
90
|
-
if (isServer) {
|
|
91
|
-
chain.target("async-node");
|
|
92
|
-
if (isDev) {
|
|
93
|
-
chain.plugin("UniverseEntryChunkTrackerPlugin").use(UniverseEntryChunkTrackerPlugin);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (isDev && !isServer) {
|
|
97
|
-
chain.externals({
|
|
98
|
-
"@module-federation/node/utils": "NOT_USED_IN_BROWSER"
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
};
|
|
@@ -114,6 +115,7 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
|
114
115
|
});
|
|
115
116
|
var ssrPlugin_default = moduleFederationSSRPlugin;
|
|
116
117
|
export {
|
|
118
|
+
CHAIN_MF_PLUGIN_ID,
|
|
117
119
|
ssrPlugin_default as default,
|
|
118
120
|
moduleFederationSSRPlugin,
|
|
119
121
|
setEnv
|
|
@@ -191,7 +191,6 @@ function patchBundlerConfig(options) {
|
|
|
191
191
|
const { chain, modernjsConfig, isServer, mfConfig } = options;
|
|
192
192
|
const enableSSR = Boolean((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
193
193
|
chain.optimization.runtimeChunk(false);
|
|
194
|
-
patchIgnoreWarning(chain);
|
|
195
194
|
if (!chain.output.get("chunkLoadingGlobal")) {
|
|
196
195
|
chain.output.chunkLoadingGlobal(`chunk_${mfConfig.name}`);
|
|
197
196
|
}
|
|
@@ -252,28 +251,6 @@ const getIPV4 = () => {
|
|
|
252
251
|
};
|
|
253
252
|
return ipv4Interface.address;
|
|
254
253
|
};
|
|
255
|
-
const SPLIT_CHUNK_MAP = {
|
|
256
|
-
REACT: "react",
|
|
257
|
-
ROUTER: "router",
|
|
258
|
-
LODASH: "lib-lodash",
|
|
259
|
-
ANTD: "lib-antd",
|
|
260
|
-
ARCO: "lib-arco",
|
|
261
|
-
SEMI: "lib-semi",
|
|
262
|
-
AXIOS: "lib-axios"
|
|
263
|
-
};
|
|
264
|
-
const SHARED_SPLIT_CHUNK_MAP = {
|
|
265
|
-
react: SPLIT_CHUNK_MAP.REACT,
|
|
266
|
-
"react-dom": SPLIT_CHUNK_MAP.REACT,
|
|
267
|
-
"react-router": SPLIT_CHUNK_MAP.ROUTER,
|
|
268
|
-
"react-router-dom": SPLIT_CHUNK_MAP.ROUTER,
|
|
269
|
-
"@remix-run/router": SPLIT_CHUNK_MAP.ROUTER,
|
|
270
|
-
lodash: SPLIT_CHUNK_MAP.LODASH,
|
|
271
|
-
"lodash-es": SPLIT_CHUNK_MAP.LODASH,
|
|
272
|
-
antd: SPLIT_CHUNK_MAP.ANTD,
|
|
273
|
-
"@arco-design/web-react": SPLIT_CHUNK_MAP.ARCO,
|
|
274
|
-
"@douyinfe/semi-ui": SPLIT_CHUNK_MAP.SEMI,
|
|
275
|
-
axios: SPLIT_CHUNK_MAP.AXIOS
|
|
276
|
-
};
|
|
277
254
|
export {
|
|
278
255
|
addMyTypes2Ignored,
|
|
279
256
|
getIPV4,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CliPluginFuture, AppTools } from '@modern-js/app-tools';
|
|
2
2
|
import type { InternalModernPluginOptions } from '../types';
|
|
3
3
|
export declare function setEnv(): void;
|
|
4
|
+
export declare const CHAIN_MF_PLUGIN_ID = "plugin-module-federation-server";
|
|
4
5
|
export declare const moduleFederationSSRPlugin: (pluginOptions: Required<InternalModernPluginOptions>) => CliPluginFuture<AppTools>;
|
|
5
6
|
export default moduleFederationSSRPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/modern-js",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20250219082408",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -84,23 +84,23 @@
|
|
|
84
84
|
"author": "hanric <hanric.zhang@gmail.com>",
|
|
85
85
|
"license": "MIT",
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@modern-js/node-bundle-require": "2.64.
|
|
88
|
-
"@modern-js/utils": "2.64.
|
|
87
|
+
"@modern-js/node-bundle-require": "2.64.3",
|
|
88
|
+
"@modern-js/utils": "2.64.3",
|
|
89
89
|
"@swc/helpers": "0.5.13",
|
|
90
90
|
"node-fetch": "~3.3.0",
|
|
91
91
|
"react-error-boundary": "4.1.2",
|
|
92
|
-
"@module-federation/rsbuild-plugin": "0.0.0-next-
|
|
93
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
94
|
-
"@module-federation/node": "0.0.0-next-
|
|
95
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
92
|
+
"@module-federation/rsbuild-plugin": "0.0.0-next-20250219082408",
|
|
93
|
+
"@module-federation/enhanced": "0.0.0-next-20250219082408",
|
|
94
|
+
"@module-federation/node": "0.0.0-next-20250219082408",
|
|
95
|
+
"@module-federation/sdk": "0.0.0-next-20250219082408"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@modern-js/app-tools": "2.64.
|
|
99
|
-
"@modern-js/core": "2.64.
|
|
100
|
-
"@modern-js/module-tools": "2.64.
|
|
101
|
-
"@modern-js/runtime": "2.64.
|
|
102
|
-
"@modern-js/tsconfig": "2.64.
|
|
103
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
98
|
+
"@modern-js/app-tools": "2.64.3",
|
|
99
|
+
"@modern-js/core": "2.64.3",
|
|
100
|
+
"@modern-js/module-tools": "2.64.3",
|
|
101
|
+
"@modern-js/runtime": "2.64.3",
|
|
102
|
+
"@modern-js/tsconfig": "2.64.3",
|
|
103
|
+
"@module-federation/manifest": "0.0.0-next-20250219082408"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"react": ">=17",
|