@module-federation/modern-js 0.0.0-next-20250603082728 → 0.0.0-next-20250603084223
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 +11 -7
- package/dist/cjs/cli/manifest.js +75 -0
- package/dist/cjs/cli/ssrPlugin.js +1 -1
- package/dist/esm/cli/configPlugin.js +11 -7
- package/dist/esm/cli/manifest.js +41 -0
- package/dist/esm/cli/ssrPlugin.js +1 -1
- package/dist/esm-node/cli/configPlugin.js +11 -7
- package/dist/esm-node/cli/manifest.js +41 -0
- package/dist/esm-node/cli/ssrPlugin.js +1 -1
- package/dist/types/cli/configPlugin.d.ts +1 -1
- package/dist/types/cli/manifest.d.ts +2 -0
- package/package.json +8 -8
|
@@ -134,7 +134,7 @@ const patchDTSConfig = (mfConfig, isServer) => {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
-
const patchMFConfig = (mfConfig, isServer, remoteIpStrategy) => {
|
|
137
|
+
const patchMFConfig = (mfConfig, isServer, remoteIpStrategy, enableSSR) => {
|
|
138
138
|
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
139
139
|
if (mfConfig.remoteType === void 0) {
|
|
140
140
|
mfConfig.remoteType = "script";
|
|
@@ -147,7 +147,7 @@ const patchMFConfig = (mfConfig, isServer, remoteIpStrategy) => {
|
|
|
147
147
|
];
|
|
148
148
|
patchDTSConfig(mfConfig, isServer);
|
|
149
149
|
injectRuntimePlugins(require.resolve("@module-federation/modern-js/shared-strategy"), runtimePlugins);
|
|
150
|
-
if (isDev) {
|
|
150
|
+
if (enableSSR && isDev) {
|
|
151
151
|
injectRuntimePlugins(require.resolve("@module-federation/modern-js/resolve-entry-ipv4"), runtimePlugins);
|
|
152
152
|
}
|
|
153
153
|
if (isServer) {
|
|
@@ -299,8 +299,9 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
299
299
|
const isWeb = (0, import_utils.isWebTarget)(target);
|
|
300
300
|
addMyTypes2Ignored(chain, !isWeb ? ssrConfig : csrConfig);
|
|
301
301
|
const targetMFConfig = !isWeb ? ssrConfig : csrConfig;
|
|
302
|
-
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4");
|
|
302
|
+
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4", enableSSR);
|
|
303
303
|
patchBundlerConfig({
|
|
304
|
+
// @ts-expect-error chain type is not correct
|
|
304
305
|
chain,
|
|
305
306
|
isServer: !isWeb,
|
|
306
307
|
modernjsConfig,
|
|
@@ -337,6 +338,12 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
337
338
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
338
339
|
"Access-Control-Allow-Headers": "*"
|
|
339
340
|
} : void 0;
|
|
341
|
+
const defineConfig = {
|
|
342
|
+
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
343
|
+
};
|
|
344
|
+
if (enableSSR && isDev) {
|
|
345
|
+
defineConfig["FEDERATION_IPV4"] = JSON.stringify(ipv4);
|
|
346
|
+
}
|
|
340
347
|
var _modernjsConfig_source_enableAsyncEntry;
|
|
341
348
|
return {
|
|
342
349
|
tools: {
|
|
@@ -349,10 +356,7 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
349
356
|
// TODO: deprecated
|
|
350
357
|
"@modern-js/runtime/mf": require.resolve("@module-federation/modern-js/runtime")
|
|
351
358
|
},
|
|
352
|
-
define:
|
|
353
|
-
FEDERATION_IPV4: JSON.stringify(ipv4),
|
|
354
|
-
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
355
|
-
},
|
|
359
|
+
define: defineConfig,
|
|
356
360
|
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
|
|
357
361
|
},
|
|
358
362
|
dev: {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
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 manifest_exports = {};
|
|
30
|
+
__export(manifest_exports, {
|
|
31
|
+
updateStatsAndManifest: () => updateStatsAndManifest
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(manifest_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
36
|
+
function mergeStats(browserStats, nodeStats) {
|
|
37
|
+
const ssrRemoteEntry = nodeStats.metaData.remoteEntry;
|
|
38
|
+
browserStats.metaData.ssrRemoteEntry = ssrRemoteEntry;
|
|
39
|
+
if ("publicPath" in browserStats.metaData) {
|
|
40
|
+
browserStats.metaData.ssrPublicPath = nodeStats.metaData.publicPath;
|
|
41
|
+
}
|
|
42
|
+
return browserStats;
|
|
43
|
+
}
|
|
44
|
+
function mergeManifest(browserManifest, nodeManifest) {
|
|
45
|
+
const ssrRemoteEntry = nodeManifest.metaData.remoteEntry;
|
|
46
|
+
browserManifest.metaData.ssrRemoteEntry = ssrRemoteEntry;
|
|
47
|
+
if ("publicPath" in browserManifest.metaData) {
|
|
48
|
+
browserManifest.metaData.ssrPublicPath = nodeManifest.metaData.publicPath;
|
|
49
|
+
}
|
|
50
|
+
return browserManifest;
|
|
51
|
+
}
|
|
52
|
+
function mergeStatsAndManifest(nodePlugin, browserPlugin) {
|
|
53
|
+
const nodeResourceInfo = nodePlugin.statsResourceInfo;
|
|
54
|
+
const browserResourceInfo = browserPlugin.statsResourceInfo;
|
|
55
|
+
if (!browserResourceInfo || !nodeResourceInfo || !browserResourceInfo.stats || !nodeResourceInfo.stats || !browserResourceInfo.manifest || !nodeResourceInfo.manifest) {
|
|
56
|
+
throw new Error("can not get browserResourceInfo or nodeResourceInfo");
|
|
57
|
+
}
|
|
58
|
+
const mergedStats = mergeStats(browserResourceInfo.stats.stats, nodeResourceInfo.stats.stats);
|
|
59
|
+
const mergedManifest = mergeManifest(browserResourceInfo.manifest.manifest, nodeResourceInfo.manifest.manifest);
|
|
60
|
+
return {
|
|
61
|
+
mergedStats,
|
|
62
|
+
mergedStatsFilePath: browserResourceInfo.stats.filename,
|
|
63
|
+
mergedManifest,
|
|
64
|
+
mergedManifestFilePath: browserResourceInfo.manifest.filename
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function updateStatsAndManifest(nodePlugin, browserPlugin, outputDir) {
|
|
68
|
+
const { mergedStats, mergedStatsFilePath, mergedManifest, mergedManifestFilePath } = mergeStatsAndManifest(nodePlugin, browserPlugin);
|
|
69
|
+
import_fs_extra.default.writeFileSync(import_path.default.resolve(outputDir, mergedStatsFilePath), JSON.stringify(mergedStats, null, 2));
|
|
70
|
+
import_fs_extra.default.writeFileSync(import_path.default.resolve(outputDir, mergedManifestFilePath), JSON.stringify(mergedManifest, null, 2));
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
updateStatsAndManifest
|
|
75
|
+
});
|
|
@@ -39,7 +39,7 @@ var import_fs_extra = __toESM(require("fs-extra"));
|
|
|
39
39
|
var import_webpack = require("@module-federation/enhanced/webpack");
|
|
40
40
|
var import_rspack = require("@module-federation/enhanced/rspack");
|
|
41
41
|
var import_universe_entry_chunk_tracker_plugin = __toESM(require("@module-federation/node/universe-entry-chunk-tracker-plugin"));
|
|
42
|
-
var import_manifest = require("
|
|
42
|
+
var import_manifest = require("./manifest");
|
|
43
43
|
var import_constant = require("./constant");
|
|
44
44
|
var import_logger = __toESM(require("./logger"));
|
|
45
45
|
var import_utils = require("./utils");
|
|
@@ -126,7 +126,7 @@ var patchDTSConfig = function(mfConfig, isServer) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
|
-
var patchMFConfig = function(mfConfig, isServer, remoteIpStrategy) {
|
|
129
|
+
var patchMFConfig = function(mfConfig, isServer, remoteIpStrategy, enableSSR) {
|
|
130
130
|
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
131
131
|
if (mfConfig.remoteType === void 0) {
|
|
132
132
|
mfConfig.remoteType = "script";
|
|
@@ -137,7 +137,7 @@ var patchMFConfig = function(mfConfig, isServer, remoteIpStrategy) {
|
|
|
137
137
|
var runtimePlugins = _to_consumable_array(mfConfig.runtimePlugins || []);
|
|
138
138
|
patchDTSConfig(mfConfig, isServer);
|
|
139
139
|
injectRuntimePlugins(require.resolve("@module-federation/modern-js/shared-strategy"), runtimePlugins);
|
|
140
|
-
if (isDev) {
|
|
140
|
+
if (enableSSR && isDev) {
|
|
141
141
|
injectRuntimePlugins(require.resolve("@module-federation/modern-js/resolve-entry-ipv4"), runtimePlugins);
|
|
142
142
|
}
|
|
143
143
|
if (isServer) {
|
|
@@ -296,8 +296,9 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
296
296
|
var isWeb = isWebTarget(target);
|
|
297
297
|
addMyTypes2Ignored(chain, !isWeb ? ssrConfig : csrConfig);
|
|
298
298
|
var targetMFConfig = !isWeb ? ssrConfig : csrConfig;
|
|
299
|
-
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4");
|
|
299
|
+
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4", enableSSR);
|
|
300
300
|
patchBundlerConfig({
|
|
301
|
+
// @ts-expect-error chain type is not correct
|
|
301
302
|
chain,
|
|
302
303
|
isServer: !isWeb,
|
|
303
304
|
modernjsConfig,
|
|
@@ -334,6 +335,12 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
334
335
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
335
336
|
"Access-Control-Allow-Headers": "*"
|
|
336
337
|
} : void 0;
|
|
338
|
+
var defineConfig = {
|
|
339
|
+
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
340
|
+
};
|
|
341
|
+
if (enableSSR && isDev) {
|
|
342
|
+
defineConfig["FEDERATION_IPV4"] = JSON.stringify(ipv4);
|
|
343
|
+
}
|
|
337
344
|
var _modernjsConfig_source_enableAsyncEntry;
|
|
338
345
|
return {
|
|
339
346
|
tools: {
|
|
@@ -346,10 +353,7 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
346
353
|
// TODO: deprecated
|
|
347
354
|
"@modern-js/runtime/mf": require.resolve("@module-federation/modern-js/runtime")
|
|
348
355
|
},
|
|
349
|
-
define:
|
|
350
|
-
FEDERATION_IPV4: JSON.stringify(ipv4),
|
|
351
|
-
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
352
|
-
},
|
|
356
|
+
define: defineConfig,
|
|
353
357
|
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
|
|
354
358
|
},
|
|
355
359
|
dev: {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
function mergeStats(browserStats, nodeStats) {
|
|
4
|
+
var ssrRemoteEntry = nodeStats.metaData.remoteEntry;
|
|
5
|
+
browserStats.metaData.ssrRemoteEntry = ssrRemoteEntry;
|
|
6
|
+
if ("publicPath" in browserStats.metaData) {
|
|
7
|
+
browserStats.metaData.ssrPublicPath = nodeStats.metaData.publicPath;
|
|
8
|
+
}
|
|
9
|
+
return browserStats;
|
|
10
|
+
}
|
|
11
|
+
function mergeManifest(browserManifest, nodeManifest) {
|
|
12
|
+
var ssrRemoteEntry = nodeManifest.metaData.remoteEntry;
|
|
13
|
+
browserManifest.metaData.ssrRemoteEntry = ssrRemoteEntry;
|
|
14
|
+
if ("publicPath" in browserManifest.metaData) {
|
|
15
|
+
browserManifest.metaData.ssrPublicPath = nodeManifest.metaData.publicPath;
|
|
16
|
+
}
|
|
17
|
+
return browserManifest;
|
|
18
|
+
}
|
|
19
|
+
function mergeStatsAndManifest(nodePlugin, browserPlugin) {
|
|
20
|
+
var nodeResourceInfo = nodePlugin.statsResourceInfo;
|
|
21
|
+
var browserResourceInfo = browserPlugin.statsResourceInfo;
|
|
22
|
+
if (!browserResourceInfo || !nodeResourceInfo || !browserResourceInfo.stats || !nodeResourceInfo.stats || !browserResourceInfo.manifest || !nodeResourceInfo.manifest) {
|
|
23
|
+
throw new Error("can not get browserResourceInfo or nodeResourceInfo");
|
|
24
|
+
}
|
|
25
|
+
var mergedStats = mergeStats(browserResourceInfo.stats.stats, nodeResourceInfo.stats.stats);
|
|
26
|
+
var mergedManifest = mergeManifest(browserResourceInfo.manifest.manifest, nodeResourceInfo.manifest.manifest);
|
|
27
|
+
return {
|
|
28
|
+
mergedStats,
|
|
29
|
+
mergedStatsFilePath: browserResourceInfo.stats.filename,
|
|
30
|
+
mergedManifest,
|
|
31
|
+
mergedManifestFilePath: browserResourceInfo.manifest.filename
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function updateStatsAndManifest(nodePlugin, browserPlugin, outputDir) {
|
|
35
|
+
var _mergeStatsAndManifest = mergeStatsAndManifest(nodePlugin, browserPlugin), mergedStats = _mergeStatsAndManifest.mergedStats, mergedStatsFilePath = _mergeStatsAndManifest.mergedStatsFilePath, mergedManifest = _mergeStatsAndManifest.mergedManifest, mergedManifestFilePath = _mergeStatsAndManifest.mergedManifestFilePath;
|
|
36
|
+
fs.writeFileSync(path.resolve(outputDir, mergedStatsFilePath), JSON.stringify(mergedStats, null, 2));
|
|
37
|
+
fs.writeFileSync(path.resolve(outputDir, mergedManifestFilePath), JSON.stringify(mergedManifest, null, 2));
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
updateStatsAndManifest
|
|
41
|
+
};
|
|
@@ -6,7 +6,7 @@ import fs from "fs-extra";
|
|
|
6
6
|
import { ModuleFederationPlugin } from "@module-federation/enhanced/webpack";
|
|
7
7
|
import { ModuleFederationPlugin as RspackModuleFederationPlugin } from "@module-federation/enhanced/rspack";
|
|
8
8
|
import UniverseEntryChunkTrackerPlugin from "@module-federation/node/universe-entry-chunk-tracker-plugin";
|
|
9
|
-
import { updateStatsAndManifest } from "
|
|
9
|
+
import { updateStatsAndManifest } from "./manifest";
|
|
10
10
|
import { isDev } from "./constant";
|
|
11
11
|
import logger from "./logger";
|
|
12
12
|
import { isWebTarget, skipByTarget } from "./utils";
|
|
@@ -93,7 +93,7 @@ const patchDTSConfig = (mfConfig, isServer) => {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
const patchMFConfig = (mfConfig, isServer, remoteIpStrategy) => {
|
|
96
|
+
const patchMFConfig = (mfConfig, isServer, remoteIpStrategy, enableSSR) => {
|
|
97
97
|
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
98
98
|
if (mfConfig.remoteType === void 0) {
|
|
99
99
|
mfConfig.remoteType = "script";
|
|
@@ -106,7 +106,7 @@ const patchMFConfig = (mfConfig, isServer, remoteIpStrategy) => {
|
|
|
106
106
|
];
|
|
107
107
|
patchDTSConfig(mfConfig, isServer);
|
|
108
108
|
injectRuntimePlugins(require.resolve("@module-federation/modern-js/shared-strategy"), runtimePlugins);
|
|
109
|
-
if (isDev) {
|
|
109
|
+
if (enableSSR && isDev) {
|
|
110
110
|
injectRuntimePlugins(require.resolve("@module-federation/modern-js/resolve-entry-ipv4"), runtimePlugins);
|
|
111
111
|
}
|
|
112
112
|
if (isServer) {
|
|
@@ -258,8 +258,9 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
258
258
|
const isWeb = isWebTarget(target);
|
|
259
259
|
addMyTypes2Ignored(chain, !isWeb ? ssrConfig : csrConfig);
|
|
260
260
|
const targetMFConfig = !isWeb ? ssrConfig : csrConfig;
|
|
261
|
-
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4");
|
|
261
|
+
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4", enableSSR);
|
|
262
262
|
patchBundlerConfig({
|
|
263
|
+
// @ts-expect-error chain type is not correct
|
|
263
264
|
chain,
|
|
264
265
|
isServer: !isWeb,
|
|
265
266
|
modernjsConfig,
|
|
@@ -296,6 +297,12 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
296
297
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
297
298
|
"Access-Control-Allow-Headers": "*"
|
|
298
299
|
} : void 0;
|
|
300
|
+
const defineConfig = {
|
|
301
|
+
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
302
|
+
};
|
|
303
|
+
if (enableSSR && isDev) {
|
|
304
|
+
defineConfig["FEDERATION_IPV4"] = JSON.stringify(ipv4);
|
|
305
|
+
}
|
|
299
306
|
var _modernjsConfig_source_enableAsyncEntry;
|
|
300
307
|
return {
|
|
301
308
|
tools: {
|
|
@@ -308,10 +315,7 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
308
315
|
// TODO: deprecated
|
|
309
316
|
"@modern-js/runtime/mf": require.resolve("@module-federation/modern-js/runtime")
|
|
310
317
|
},
|
|
311
|
-
define:
|
|
312
|
-
FEDERATION_IPV4: JSON.stringify(ipv4),
|
|
313
|
-
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
314
|
-
},
|
|
318
|
+
define: defineConfig,
|
|
315
319
|
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
|
|
316
320
|
},
|
|
317
321
|
dev: {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
function mergeStats(browserStats, nodeStats) {
|
|
4
|
+
const ssrRemoteEntry = nodeStats.metaData.remoteEntry;
|
|
5
|
+
browserStats.metaData.ssrRemoteEntry = ssrRemoteEntry;
|
|
6
|
+
if ("publicPath" in browserStats.metaData) {
|
|
7
|
+
browserStats.metaData.ssrPublicPath = nodeStats.metaData.publicPath;
|
|
8
|
+
}
|
|
9
|
+
return browserStats;
|
|
10
|
+
}
|
|
11
|
+
function mergeManifest(browserManifest, nodeManifest) {
|
|
12
|
+
const ssrRemoteEntry = nodeManifest.metaData.remoteEntry;
|
|
13
|
+
browserManifest.metaData.ssrRemoteEntry = ssrRemoteEntry;
|
|
14
|
+
if ("publicPath" in browserManifest.metaData) {
|
|
15
|
+
browserManifest.metaData.ssrPublicPath = nodeManifest.metaData.publicPath;
|
|
16
|
+
}
|
|
17
|
+
return browserManifest;
|
|
18
|
+
}
|
|
19
|
+
function mergeStatsAndManifest(nodePlugin, browserPlugin) {
|
|
20
|
+
const nodeResourceInfo = nodePlugin.statsResourceInfo;
|
|
21
|
+
const browserResourceInfo = browserPlugin.statsResourceInfo;
|
|
22
|
+
if (!browserResourceInfo || !nodeResourceInfo || !browserResourceInfo.stats || !nodeResourceInfo.stats || !browserResourceInfo.manifest || !nodeResourceInfo.manifest) {
|
|
23
|
+
throw new Error("can not get browserResourceInfo or nodeResourceInfo");
|
|
24
|
+
}
|
|
25
|
+
const mergedStats = mergeStats(browserResourceInfo.stats.stats, nodeResourceInfo.stats.stats);
|
|
26
|
+
const mergedManifest = mergeManifest(browserResourceInfo.manifest.manifest, nodeResourceInfo.manifest.manifest);
|
|
27
|
+
return {
|
|
28
|
+
mergedStats,
|
|
29
|
+
mergedStatsFilePath: browserResourceInfo.stats.filename,
|
|
30
|
+
mergedManifest,
|
|
31
|
+
mergedManifestFilePath: browserResourceInfo.manifest.filename
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function updateStatsAndManifest(nodePlugin, browserPlugin, outputDir) {
|
|
35
|
+
const { mergedStats, mergedStatsFilePath, mergedManifest, mergedManifestFilePath } = mergeStatsAndManifest(nodePlugin, browserPlugin);
|
|
36
|
+
fs.writeFileSync(path.resolve(outputDir, mergedStatsFilePath), JSON.stringify(mergedStats, null, 2));
|
|
37
|
+
fs.writeFileSync(path.resolve(outputDir, mergedManifestFilePath), JSON.stringify(mergedManifest, null, 2));
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
updateStatsAndManifest
|
|
41
|
+
};
|
|
@@ -3,7 +3,7 @@ import fs from "fs-extra";
|
|
|
3
3
|
import { ModuleFederationPlugin } from "@module-federation/enhanced/webpack";
|
|
4
4
|
import { ModuleFederationPlugin as RspackModuleFederationPlugin } from "@module-federation/enhanced/rspack";
|
|
5
5
|
import UniverseEntryChunkTrackerPlugin from "@module-federation/node/universe-entry-chunk-tracker-plugin";
|
|
6
|
-
import { updateStatsAndManifest } from "
|
|
6
|
+
import { updateStatsAndManifest } from "./manifest";
|
|
7
7
|
import { isDev } from "./constant";
|
|
8
8
|
import logger from "./logger";
|
|
9
9
|
import { isWebTarget, skipByTarget } from "./utils";
|
|
@@ -7,7 +7,7 @@ import type { BundlerChainConfig } from '../interfaces/bundler';
|
|
|
7
7
|
export type ConfigType<T> = T extends 'webpack' ? webpack.Configuration : T extends 'rspack' ? Rspack.Configuration : never;
|
|
8
8
|
export declare function setEnv(enableSSR: boolean): void;
|
|
9
9
|
export declare const getMFConfig: (userConfig: PluginOptions) => Promise<moduleFederationPlugin.ModuleFederationPluginOptions>;
|
|
10
|
-
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean, remoteIpStrategy?: "ipv4" | "inherit") => moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
10
|
+
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean, remoteIpStrategy?: "ipv4" | "inherit", enableSSR?: boolean) => moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
11
11
|
export declare function addMyTypes2Ignored(chain: BundlerChainConfig, mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions): void;
|
|
12
12
|
export declare function patchBundlerConfig(options: {
|
|
13
13
|
chain: BundlerChainConfig;
|
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-20250603084223",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -97,20 +97,20 @@
|
|
|
97
97
|
"@swc/helpers": "0.5.13",
|
|
98
98
|
"node-fetch": "~3.3.0",
|
|
99
99
|
"react-error-boundary": "4.1.2",
|
|
100
|
-
"@module-federation/rsbuild-plugin": "0.0.0-next-
|
|
101
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
102
|
-
"@module-federation/node": "0.0.0-next-
|
|
103
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
104
|
-
"@module-federation/cli": "0.0.0-next-
|
|
100
|
+
"@module-federation/rsbuild-plugin": "0.0.0-next-20250603084223",
|
|
101
|
+
"@module-federation/enhanced": "0.0.0-next-20250603084223",
|
|
102
|
+
"@module-federation/node": "0.0.0-next-20250603084223",
|
|
103
|
+
"@module-federation/sdk": "0.0.0-next-20250603084223",
|
|
104
|
+
"@module-federation/cli": "0.0.0-next-20250603084223"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@rsbuild/core": "1.
|
|
107
|
+
"@rsbuild/core": "1.2.8",
|
|
108
108
|
"@modern-js/app-tools": "2.67.6",
|
|
109
109
|
"@modern-js/server-runtime": "2.67.6",
|
|
110
110
|
"@modern-js/module-tools": "2.67.6",
|
|
111
111
|
"@modern-js/runtime": "2.67.6",
|
|
112
112
|
"@modern-js/tsconfig": "2.67.6",
|
|
113
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
113
|
+
"@module-federation/manifest": "0.0.0-next-20250603084223"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"react": ">=17",
|