@module-federation/modern-js 0.0.0-next-20240620115801 → 0.0.0-next-20240621074837
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/index.js +7 -0
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +28 -13
- package/dist/cjs/cli/utils.js +3 -0
- package/dist/esm/cli/index.js +7 -0
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js +40 -27
- package/dist/esm/cli/utils.js +3 -0
- package/dist/esm-node/cli/index.js +7 -0
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.js +28 -13
- package/dist/esm-node/cli/utils.js +3 -0
- package/package.json +5 -5
package/dist/cjs/cli/index.js
CHANGED
|
@@ -107,6 +107,13 @@ const moduleFederationPlugin = (userConfig = {}) => ({
|
|
|
107
107
|
};
|
|
108
108
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(new import_enhanced.AsyncBoundaryPlugin(asyncBoundaryPluginOptions));
|
|
109
109
|
}
|
|
110
|
+
config.ignoreWarnings = config.ignoreWarnings || [];
|
|
111
|
+
config.ignoreWarnings.push((warning) => {
|
|
112
|
+
if (warning.message.includes("external script")) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
});
|
|
110
117
|
},
|
|
111
118
|
devServer: {
|
|
112
119
|
headers: {
|
|
@@ -23,6 +23,15 @@ __export(resolve_entry_ipv4_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(resolve_entry_ipv4_exports);
|
|
24
24
|
var import_constant = require("../../constant");
|
|
25
25
|
const ipv4 = typeof FEDERATION_IPV4 !== "undefined" ? FEDERATION_IPV4 : "127.0.0.1";
|
|
26
|
+
function replaceObjectLocalhost(key, obj) {
|
|
27
|
+
if (!(key in obj)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const remote = obj[key];
|
|
31
|
+
if (remote && typeof remote === "string" && remote.includes(import_constant.LOCALHOST)) {
|
|
32
|
+
obj[key] = replaceLocalhost(remote);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
26
35
|
function replaceLocalhost(url) {
|
|
27
36
|
return url.replace(import_constant.LOCALHOST, ipv4);
|
|
28
37
|
}
|
|
@@ -30,29 +39,35 @@ const resolveEntryIpv4Plugin = () => ({
|
|
|
30
39
|
name: "resolve-entry-ipv4",
|
|
31
40
|
beforeRegisterRemote(args) {
|
|
32
41
|
const { remote } = args;
|
|
33
|
-
|
|
34
|
-
remote.entry = replaceLocalhost(remote.entry);
|
|
35
|
-
}
|
|
42
|
+
replaceObjectLocalhost("entry", remote);
|
|
36
43
|
return args;
|
|
37
44
|
},
|
|
38
|
-
// async fetch(manifestUrl) {
|
|
39
|
-
// const ipv4ManifestUrl = manifestUrl.replace(LOCALHOST, ipv4);
|
|
40
|
-
// return globalThis.fetch(ipv4ManifestUrl);
|
|
41
|
-
// },
|
|
42
45
|
async afterResolve(args) {
|
|
43
46
|
const { remoteInfo } = args;
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
replaceObjectLocalhost("entry", remoteInfo);
|
|
48
|
+
return args;
|
|
49
|
+
},
|
|
50
|
+
beforeLoadRemoteSnapshot(args) {
|
|
51
|
+
const { moduleInfo } = args;
|
|
52
|
+
if ("entry" in moduleInfo) {
|
|
53
|
+
replaceObjectLocalhost("entry", moduleInfo);
|
|
54
|
+
return args;
|
|
55
|
+
}
|
|
56
|
+
if ("version" in moduleInfo) {
|
|
57
|
+
replaceObjectLocalhost("version", moduleInfo);
|
|
46
58
|
}
|
|
47
59
|
return args;
|
|
48
60
|
},
|
|
49
61
|
loadRemoteSnapshot(args) {
|
|
50
62
|
const { remoteSnapshot } = args;
|
|
51
|
-
if ("publicPath" in remoteSnapshot
|
|
52
|
-
|
|
63
|
+
if ("publicPath" in remoteSnapshot) {
|
|
64
|
+
replaceObjectLocalhost("publicPath", remoteSnapshot);
|
|
65
|
+
}
|
|
66
|
+
if ("getPublicPath" in remoteSnapshot) {
|
|
67
|
+
replaceObjectLocalhost("getPublicPath", remoteSnapshot);
|
|
53
68
|
}
|
|
54
|
-
if ("
|
|
55
|
-
|
|
69
|
+
if ("matchedVersion:" in remoteSnapshot) {
|
|
70
|
+
replaceObjectLocalhost("matchedVersion:", remoteSnapshot);
|
|
56
71
|
}
|
|
57
72
|
return args;
|
|
58
73
|
}
|
package/dist/cjs/cli/utils.js
CHANGED
|
@@ -50,6 +50,9 @@ const getMFConfig = async (userConfig) => {
|
|
|
50
50
|
const preBundlePath = await (0, import_node_bundle_require.bundle)(mfConfigPath);
|
|
51
51
|
const mfConfig = (await Promise.resolve().then(() => __toESM(require(preBundlePath)))).default;
|
|
52
52
|
await replaceRemoteUrl(mfConfig);
|
|
53
|
+
if (mfConfig.remoteType === void 0) {
|
|
54
|
+
mfConfig.remoteType = "script";
|
|
55
|
+
}
|
|
53
56
|
return mfConfig;
|
|
54
57
|
};
|
|
55
58
|
const injectRuntimePlugins = (runtimePlugin, runtimePlugins) => {
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -100,6 +100,13 @@ var moduleFederationPlugin = function() {
|
|
|
100
100
|
};
|
|
101
101
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(new AsyncBoundaryPlugin(asyncBoundaryPluginOptions));
|
|
102
102
|
}
|
|
103
|
+
config.ignoreWarnings = config.ignoreWarnings || [];
|
|
104
|
+
config.ignoreWarnings.push(function(warning) {
|
|
105
|
+
if (warning.message.includes("external script")) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
});
|
|
103
110
|
},
|
|
104
111
|
devServer: {
|
|
105
112
|
headers: {
|
|
@@ -2,6 +2,15 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import { LOCALHOST } from "../../constant";
|
|
4
4
|
var ipv4 = typeof FEDERATION_IPV4 !== "undefined" ? FEDERATION_IPV4 : "127.0.0.1";
|
|
5
|
+
function replaceObjectLocalhost(key, obj) {
|
|
6
|
+
if (!(key in obj)) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
var remote = obj[key];
|
|
10
|
+
if (remote && typeof remote === "string" && remote.includes(LOCALHOST)) {
|
|
11
|
+
obj[key] = replaceLocalhost(remote);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
5
14
|
function replaceLocalhost(url) {
|
|
6
15
|
return url.replace(LOCALHOST, ipv4);
|
|
7
16
|
}
|
|
@@ -10,39 +19,43 @@ var resolveEntryIpv4Plugin = function() {
|
|
|
10
19
|
name: "resolve-entry-ipv4",
|
|
11
20
|
beforeRegisterRemote: function beforeRegisterRemote(args) {
|
|
12
21
|
var remote = args.remote;
|
|
13
|
-
|
|
14
|
-
remote.entry = replaceLocalhost(remote.entry);
|
|
15
|
-
}
|
|
22
|
+
replaceObjectLocalhost("entry", remote);
|
|
16
23
|
return args;
|
|
17
24
|
},
|
|
18
|
-
afterResolve: (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
afterResolve: function afterResolve(args) {
|
|
26
|
+
return _async_to_generator(function() {
|
|
27
|
+
var remoteInfo;
|
|
28
|
+
return _ts_generator(this, function(_state) {
|
|
29
|
+
remoteInfo = args.remoteInfo;
|
|
30
|
+
replaceObjectLocalhost("entry", remoteInfo);
|
|
31
|
+
return [
|
|
32
|
+
2,
|
|
33
|
+
args
|
|
34
|
+
];
|
|
35
|
+
});
|
|
36
|
+
})();
|
|
37
|
+
},
|
|
38
|
+
beforeLoadRemoteSnapshot: function beforeLoadRemoteSnapshot(args) {
|
|
39
|
+
var moduleInfo = args.moduleInfo;
|
|
40
|
+
if ("entry" in moduleInfo) {
|
|
41
|
+
replaceObjectLocalhost("entry", moduleInfo);
|
|
42
|
+
return args;
|
|
43
|
+
}
|
|
44
|
+
if ("version" in moduleInfo) {
|
|
45
|
+
replaceObjectLocalhost("version", moduleInfo);
|
|
37
46
|
}
|
|
38
|
-
|
|
47
|
+
return args;
|
|
48
|
+
},
|
|
39
49
|
loadRemoteSnapshot: function loadRemoteSnapshot(args) {
|
|
40
50
|
var remoteSnapshot = args.remoteSnapshot;
|
|
41
|
-
if ("publicPath" in remoteSnapshot
|
|
42
|
-
|
|
51
|
+
if ("publicPath" in remoteSnapshot) {
|
|
52
|
+
replaceObjectLocalhost("publicPath", remoteSnapshot);
|
|
53
|
+
}
|
|
54
|
+
if ("getPublicPath" in remoteSnapshot) {
|
|
55
|
+
replaceObjectLocalhost("getPublicPath", remoteSnapshot);
|
|
43
56
|
}
|
|
44
|
-
if ("
|
|
45
|
-
|
|
57
|
+
if ("matchedVersion:" in remoteSnapshot) {
|
|
58
|
+
replaceObjectLocalhost("matchedVersion:", remoteSnapshot);
|
|
46
59
|
}
|
|
47
60
|
return args;
|
|
48
61
|
}
|
package/dist/esm/cli/utils.js
CHANGED
|
@@ -71,6 +71,13 @@ const moduleFederationPlugin = (userConfig = {}) => ({
|
|
|
71
71
|
};
|
|
72
72
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(new AsyncBoundaryPlugin(asyncBoundaryPluginOptions));
|
|
73
73
|
}
|
|
74
|
+
config.ignoreWarnings = config.ignoreWarnings || [];
|
|
75
|
+
config.ignoreWarnings.push((warning) => {
|
|
76
|
+
if (warning.message.includes("external script")) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
});
|
|
74
81
|
},
|
|
75
82
|
devServer: {
|
|
76
83
|
headers: {
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { LOCALHOST } from "../../constant";
|
|
2
2
|
const ipv4 = typeof FEDERATION_IPV4 !== "undefined" ? FEDERATION_IPV4 : "127.0.0.1";
|
|
3
|
+
function replaceObjectLocalhost(key, obj) {
|
|
4
|
+
if (!(key in obj)) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const remote = obj[key];
|
|
8
|
+
if (remote && typeof remote === "string" && remote.includes(LOCALHOST)) {
|
|
9
|
+
obj[key] = replaceLocalhost(remote);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
3
12
|
function replaceLocalhost(url) {
|
|
4
13
|
return url.replace(LOCALHOST, ipv4);
|
|
5
14
|
}
|
|
@@ -7,29 +16,35 @@ const resolveEntryIpv4Plugin = () => ({
|
|
|
7
16
|
name: "resolve-entry-ipv4",
|
|
8
17
|
beforeRegisterRemote(args) {
|
|
9
18
|
const { remote } = args;
|
|
10
|
-
|
|
11
|
-
remote.entry = replaceLocalhost(remote.entry);
|
|
12
|
-
}
|
|
19
|
+
replaceObjectLocalhost("entry", remote);
|
|
13
20
|
return args;
|
|
14
21
|
},
|
|
15
|
-
// async fetch(manifestUrl) {
|
|
16
|
-
// const ipv4ManifestUrl = manifestUrl.replace(LOCALHOST, ipv4);
|
|
17
|
-
// return globalThis.fetch(ipv4ManifestUrl);
|
|
18
|
-
// },
|
|
19
22
|
async afterResolve(args) {
|
|
20
23
|
const { remoteInfo } = args;
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
replaceObjectLocalhost("entry", remoteInfo);
|
|
25
|
+
return args;
|
|
26
|
+
},
|
|
27
|
+
beforeLoadRemoteSnapshot(args) {
|
|
28
|
+
const { moduleInfo } = args;
|
|
29
|
+
if ("entry" in moduleInfo) {
|
|
30
|
+
replaceObjectLocalhost("entry", moduleInfo);
|
|
31
|
+
return args;
|
|
32
|
+
}
|
|
33
|
+
if ("version" in moduleInfo) {
|
|
34
|
+
replaceObjectLocalhost("version", moduleInfo);
|
|
23
35
|
}
|
|
24
36
|
return args;
|
|
25
37
|
},
|
|
26
38
|
loadRemoteSnapshot(args) {
|
|
27
39
|
const { remoteSnapshot } = args;
|
|
28
|
-
if ("publicPath" in remoteSnapshot
|
|
29
|
-
|
|
40
|
+
if ("publicPath" in remoteSnapshot) {
|
|
41
|
+
replaceObjectLocalhost("publicPath", remoteSnapshot);
|
|
42
|
+
}
|
|
43
|
+
if ("getPublicPath" in remoteSnapshot) {
|
|
44
|
+
replaceObjectLocalhost("getPublicPath", remoteSnapshot);
|
|
30
45
|
}
|
|
31
|
-
if ("
|
|
32
|
-
|
|
46
|
+
if ("matchedVersion:" in remoteSnapshot) {
|
|
47
|
+
replaceObjectLocalhost("matchedVersion:", remoteSnapshot);
|
|
33
48
|
}
|
|
34
49
|
return args;
|
|
35
50
|
}
|
|
@@ -13,6 +13,9 @@ const getMFConfig = async (userConfig) => {
|
|
|
13
13
|
const preBundlePath = await bundle(mfConfigPath);
|
|
14
14
|
const mfConfig = (await import(preBundlePath)).default;
|
|
15
15
|
await replaceRemoteUrl(mfConfig);
|
|
16
|
+
if (mfConfig.remoteType === void 0) {
|
|
17
|
+
mfConfig.remoteType = "script";
|
|
18
|
+
}
|
|
16
19
|
return mfConfig;
|
|
17
20
|
};
|
|
18
21
|
const injectRuntimePlugins = (runtimePlugin, runtimePlugins) => {
|
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-20240621074837",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"@modern-js/utils": "^2.49.2",
|
|
47
47
|
"@modern-js/node-bundle-require": "^2.49.2",
|
|
48
48
|
"node-fetch": "~3.3.0",
|
|
49
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
50
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
51
|
-
"@module-federation/node": "0.0.0-next-
|
|
49
|
+
"@module-federation/sdk": "0.0.0-next-20240621074837",
|
|
50
|
+
"@module-federation/enhanced": "0.0.0-next-20240621074837",
|
|
51
|
+
"@module-federation/node": "0.0.0-next-20240621074837"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@modern-js/app-tools": "^2.49.2",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@modern-js/runtime": "^2.49.2",
|
|
57
57
|
"@modern-js/module-tools": "^2.35.0",
|
|
58
58
|
"@modern-js/tsconfig": "^2.35.0",
|
|
59
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
59
|
+
"@module-federation/manifest": "0.0.0-next-20240621074837"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"react": ">=17",
|