@module-federation/modern-js 0.0.0-next-20250401063000 → 0.0.0-next-20250401085244
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.
|
@@ -37,6 +37,7 @@ __export(configPlugin_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(configPlugin_exports);
|
|
38
38
|
var import_path = __toESM(require("path"));
|
|
39
39
|
var import_utils = require("./utils");
|
|
40
|
+
var import_logger = __toESM(require("./logger"));
|
|
40
41
|
function setEnv(enableSSR) {
|
|
41
42
|
if (enableSSR) {
|
|
42
43
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
@@ -81,7 +82,7 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
81
82
|
userConfig.distOutputDir = chain.output.get("path") || import_path.default.resolve(process.cwd(), "dist");
|
|
82
83
|
});
|
|
83
84
|
api.config(() => {
|
|
84
|
-
var _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
85
|
+
var _modernjsConfig_tools, _devServerConfig_headers, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
85
86
|
const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
86
87
|
const ipv4 = (0, import_utils.getIPV4)();
|
|
87
88
|
if (userConfig.remoteIpStrategy === void 0) {
|
|
@@ -91,15 +92,30 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
91
92
|
userConfig.remoteIpStrategy = "ipv4";
|
|
92
93
|
}
|
|
93
94
|
}
|
|
95
|
+
const devServerConfig = (_modernjsConfig_tools = modernjsConfig.tools) === null || _modernjsConfig_tools === void 0 ? void 0 : _modernjsConfig_tools.devServer;
|
|
96
|
+
const corsWarnMsgs = [
|
|
97
|
+
", which exposes your dev server to all origins, potentially compromising your source code security. It is recommended to specify an allowlist of trusted origins instead."
|
|
98
|
+
];
|
|
99
|
+
if (typeof devServerConfig !== "object" || !("headers" in devServerConfig)) {
|
|
100
|
+
corsWarnMsgs.unshift('Detect devServer.headers is empty, mf modern plugin will add default cors header: devServer.headers["Access-Control-Allow-Headers"] = "*"');
|
|
101
|
+
} else if (((_devServerConfig_headers = devServerConfig.headers) === null || _devServerConfig_headers === void 0 ? void 0 : _devServerConfig_headers["Access-Control-Allow-Headers"]) === "*") {
|
|
102
|
+
corsWarnMsgs.unshift('Detect devServer.headers["Access-Control-Allow-Headers"] is *');
|
|
103
|
+
}
|
|
104
|
+
const exposes = (_userConfig_csrConfig = userConfig.csrConfig) === null || _userConfig_csrConfig === void 0 ? void 0 : _userConfig_csrConfig.exposes;
|
|
105
|
+
const hasExposes = exposes && Array.isArray(exposes) ? exposes.length : Object.keys(exposes !== null && exposes !== void 0 ? exposes : {}).length;
|
|
106
|
+
if (corsWarnMsgs.length > 1 && hasExposes) {
|
|
107
|
+
import_logger.default.warn(corsWarnMsgs.join(""));
|
|
108
|
+
}
|
|
109
|
+
const corsHeaders = hasExposes ? {
|
|
110
|
+
"Access-Control-Allow-Origin": "*",
|
|
111
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
112
|
+
"Access-Control-Allow-Headers": "*"
|
|
113
|
+
} : void 0;
|
|
94
114
|
var _modernjsConfig_source_enableAsyncEntry;
|
|
95
115
|
return {
|
|
96
116
|
tools: {
|
|
97
117
|
devServer: {
|
|
98
|
-
headers:
|
|
99
|
-
"Access-Control-Allow-Origin": "*",
|
|
100
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
101
|
-
"Access-Control-Allow-Headers": "*"
|
|
102
|
-
}
|
|
118
|
+
headers: corsHeaders
|
|
103
119
|
}
|
|
104
120
|
},
|
|
105
121
|
source: {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
2
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
4
|
import path from "path";
|
|
4
5
|
import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig, addMyTypes2Ignored, isWebTarget, skipByTarget } from "./utils";
|
|
6
|
+
import logger from "./logger";
|
|
5
7
|
function setEnv(enableSSR) {
|
|
6
8
|
if (enableSSR) {
|
|
7
9
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
@@ -55,7 +57,7 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
55
57
|
userConfig.distOutputDir = chain.output.get("path") || path.resolve(process.cwd(), "dist");
|
|
56
58
|
});
|
|
57
59
|
api.config(function() {
|
|
58
|
-
var _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
60
|
+
var _modernjsConfig_tools, _devServerConfig_headers, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
59
61
|
var bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
60
62
|
var ipv4 = getIPV4();
|
|
61
63
|
if (userConfig.remoteIpStrategy === void 0) {
|
|
@@ -65,15 +67,30 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
65
67
|
userConfig.remoteIpStrategy = "ipv4";
|
|
66
68
|
}
|
|
67
69
|
}
|
|
70
|
+
var devServerConfig = (_modernjsConfig_tools = modernjsConfig.tools) === null || _modernjsConfig_tools === void 0 ? void 0 : _modernjsConfig_tools.devServer;
|
|
71
|
+
var corsWarnMsgs = [
|
|
72
|
+
", which exposes your dev server to all origins, potentially compromising your source code security. It is recommended to specify an allowlist of trusted origins instead."
|
|
73
|
+
];
|
|
74
|
+
if ((typeof devServerConfig === "undefined" ? "undefined" : _type_of(devServerConfig)) !== "object" || !("headers" in devServerConfig)) {
|
|
75
|
+
corsWarnMsgs.unshift('Detect devServer.headers is empty, mf modern plugin will add default cors header: devServer.headers["Access-Control-Allow-Headers"] = "*"');
|
|
76
|
+
} else if (((_devServerConfig_headers = devServerConfig.headers) === null || _devServerConfig_headers === void 0 ? void 0 : _devServerConfig_headers["Access-Control-Allow-Headers"]) === "*") {
|
|
77
|
+
corsWarnMsgs.unshift('Detect devServer.headers["Access-Control-Allow-Headers"] is *');
|
|
78
|
+
}
|
|
79
|
+
var exposes = (_userConfig_csrConfig = userConfig.csrConfig) === null || _userConfig_csrConfig === void 0 ? void 0 : _userConfig_csrConfig.exposes;
|
|
80
|
+
var hasExposes = exposes && Array.isArray(exposes) ? exposes.length : Object.keys(exposes !== null && exposes !== void 0 ? exposes : {}).length;
|
|
81
|
+
if (corsWarnMsgs.length > 1 && hasExposes) {
|
|
82
|
+
logger.warn(corsWarnMsgs.join(""));
|
|
83
|
+
}
|
|
84
|
+
var corsHeaders = hasExposes ? {
|
|
85
|
+
"Access-Control-Allow-Origin": "*",
|
|
86
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
87
|
+
"Access-Control-Allow-Headers": "*"
|
|
88
|
+
} : void 0;
|
|
68
89
|
var _modernjsConfig_source_enableAsyncEntry;
|
|
69
90
|
return {
|
|
70
91
|
tools: {
|
|
71
92
|
devServer: {
|
|
72
|
-
headers:
|
|
73
|
-
"Access-Control-Allow-Origin": "*",
|
|
74
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
75
|
-
"Access-Control-Allow-Headers": "*"
|
|
76
|
-
}
|
|
93
|
+
headers: corsHeaders
|
|
77
94
|
}
|
|
78
95
|
},
|
|
79
96
|
source: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig, addMyTypes2Ignored, isWebTarget, skipByTarget } from "./utils";
|
|
3
|
+
import logger from "./logger";
|
|
3
4
|
function setEnv(enableSSR) {
|
|
4
5
|
if (enableSSR) {
|
|
5
6
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
@@ -44,7 +45,7 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
44
45
|
userConfig.distOutputDir = chain.output.get("path") || path.resolve(process.cwd(), "dist");
|
|
45
46
|
});
|
|
46
47
|
api.config(() => {
|
|
47
|
-
var _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
48
|
+
var _modernjsConfig_tools, _devServerConfig_headers, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
48
49
|
const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
49
50
|
const ipv4 = getIPV4();
|
|
50
51
|
if (userConfig.remoteIpStrategy === void 0) {
|
|
@@ -54,15 +55,30 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
54
55
|
userConfig.remoteIpStrategy = "ipv4";
|
|
55
56
|
}
|
|
56
57
|
}
|
|
58
|
+
const devServerConfig = (_modernjsConfig_tools = modernjsConfig.tools) === null || _modernjsConfig_tools === void 0 ? void 0 : _modernjsConfig_tools.devServer;
|
|
59
|
+
const corsWarnMsgs = [
|
|
60
|
+
", which exposes your dev server to all origins, potentially compromising your source code security. It is recommended to specify an allowlist of trusted origins instead."
|
|
61
|
+
];
|
|
62
|
+
if (typeof devServerConfig !== "object" || !("headers" in devServerConfig)) {
|
|
63
|
+
corsWarnMsgs.unshift('Detect devServer.headers is empty, mf modern plugin will add default cors header: devServer.headers["Access-Control-Allow-Headers"] = "*"');
|
|
64
|
+
} else if (((_devServerConfig_headers = devServerConfig.headers) === null || _devServerConfig_headers === void 0 ? void 0 : _devServerConfig_headers["Access-Control-Allow-Headers"]) === "*") {
|
|
65
|
+
corsWarnMsgs.unshift('Detect devServer.headers["Access-Control-Allow-Headers"] is *');
|
|
66
|
+
}
|
|
67
|
+
const exposes = (_userConfig_csrConfig = userConfig.csrConfig) === null || _userConfig_csrConfig === void 0 ? void 0 : _userConfig_csrConfig.exposes;
|
|
68
|
+
const hasExposes = exposes && Array.isArray(exposes) ? exposes.length : Object.keys(exposes !== null && exposes !== void 0 ? exposes : {}).length;
|
|
69
|
+
if (corsWarnMsgs.length > 1 && hasExposes) {
|
|
70
|
+
logger.warn(corsWarnMsgs.join(""));
|
|
71
|
+
}
|
|
72
|
+
const corsHeaders = hasExposes ? {
|
|
73
|
+
"Access-Control-Allow-Origin": "*",
|
|
74
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
75
|
+
"Access-Control-Allow-Headers": "*"
|
|
76
|
+
} : void 0;
|
|
57
77
|
var _modernjsConfig_source_enableAsyncEntry;
|
|
58
78
|
return {
|
|
59
79
|
tools: {
|
|
60
80
|
devServer: {
|
|
61
|
-
headers:
|
|
62
|
-
"Access-Control-Allow-Origin": "*",
|
|
63
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
64
|
-
"Access-Control-Allow-Headers": "*"
|
|
65
|
-
}
|
|
81
|
+
headers: corsHeaders
|
|
66
82
|
}
|
|
67
83
|
},
|
|
68
84
|
source: {
|
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-20250401085244",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -89,11 +89,11 @@
|
|
|
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-
|
|
96
|
-
"@module-federation/cli": "0.0.0-next-
|
|
92
|
+
"@module-federation/rsbuild-plugin": "0.0.0-next-20250401085244",
|
|
93
|
+
"@module-federation/enhanced": "0.0.0-next-20250401085244",
|
|
94
|
+
"@module-federation/node": "0.0.0-next-20250401085244",
|
|
95
|
+
"@module-federation/sdk": "0.0.0-next-20250401085244",
|
|
96
|
+
"@module-federation/cli": "0.0.0-next-20250401085244"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@modern-js/app-tools": "2.65.1",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"@modern-js/module-tools": "2.65.1",
|
|
102
102
|
"@modern-js/runtime": "2.65.1",
|
|
103
103
|
"@modern-js/tsconfig": "2.65.1",
|
|
104
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
104
|
+
"@module-federation/manifest": "0.0.0-next-20250401085244"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
107
|
"react": ">=17",
|