@module-federation/modern-js 0.0.0-next-20240620124309 → 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.
@@ -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
- if ("entry" in remote && remote.entry.includes(import_constant.LOCALHOST)) {
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
- if (remoteInfo.entry.includes(import_constant.LOCALHOST)) {
45
- remoteInfo.entry = replaceLocalhost(remoteInfo.entry);
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 && remoteSnapshot.publicPath.includes(import_constant.LOCALHOST)) {
52
- remoteSnapshot.publicPath = replaceLocalhost(remoteSnapshot.publicPath);
63
+ if ("publicPath" in remoteSnapshot) {
64
+ replaceObjectLocalhost("publicPath", remoteSnapshot);
65
+ }
66
+ if ("getPublicPath" in remoteSnapshot) {
67
+ replaceObjectLocalhost("getPublicPath", remoteSnapshot);
53
68
  }
54
- if ("getPublicPath" in remoteSnapshot && remoteSnapshot.getPublicPath.includes(import_constant.LOCALHOST)) {
55
- remoteSnapshot.getPublicPath = replaceLocalhost(remoteSnapshot.getPublicPath);
69
+ if ("matchedVersion:" in remoteSnapshot) {
70
+ replaceObjectLocalhost("matchedVersion:", remoteSnapshot);
56
71
  }
57
72
  return args;
58
73
  }
@@ -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
- if ("entry" in remote && remote.entry.includes(LOCALHOST)) {
14
- remote.entry = replaceLocalhost(remote.entry);
15
- }
22
+ replaceObjectLocalhost("entry", remote);
16
23
  return args;
17
24
  },
18
- afterResolve: (
19
- // async fetch(manifestUrl) {
20
- // const ipv4ManifestUrl = manifestUrl.replace(LOCALHOST, ipv4);
21
- // return globalThis.fetch(ipv4ManifestUrl);
22
- // },
23
- function afterResolve(args) {
24
- return _async_to_generator(function() {
25
- var remoteInfo;
26
- return _ts_generator(this, function(_state) {
27
- remoteInfo = args.remoteInfo;
28
- if (remoteInfo.entry.includes(LOCALHOST)) {
29
- remoteInfo.entry = replaceLocalhost(remoteInfo.entry);
30
- }
31
- return [
32
- 2,
33
- args
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 && remoteSnapshot.publicPath.includes(LOCALHOST)) {
42
- remoteSnapshot.publicPath = replaceLocalhost(remoteSnapshot.publicPath);
51
+ if ("publicPath" in remoteSnapshot) {
52
+ replaceObjectLocalhost("publicPath", remoteSnapshot);
53
+ }
54
+ if ("getPublicPath" in remoteSnapshot) {
55
+ replaceObjectLocalhost("getPublicPath", remoteSnapshot);
43
56
  }
44
- if ("getPublicPath" in remoteSnapshot && remoteSnapshot.getPublicPath.includes(LOCALHOST)) {
45
- remoteSnapshot.getPublicPath = replaceLocalhost(remoteSnapshot.getPublicPath);
57
+ if ("matchedVersion:" in remoteSnapshot) {
58
+ replaceObjectLocalhost("matchedVersion:", remoteSnapshot);
46
59
  }
47
60
  return args;
48
61
  }
@@ -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
- if ("entry" in remote && remote.entry.includes(LOCALHOST)) {
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
- if (remoteInfo.entry.includes(LOCALHOST)) {
22
- remoteInfo.entry = replaceLocalhost(remoteInfo.entry);
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 && remoteSnapshot.publicPath.includes(LOCALHOST)) {
29
- remoteSnapshot.publicPath = replaceLocalhost(remoteSnapshot.publicPath);
40
+ if ("publicPath" in remoteSnapshot) {
41
+ replaceObjectLocalhost("publicPath", remoteSnapshot);
42
+ }
43
+ if ("getPublicPath" in remoteSnapshot) {
44
+ replaceObjectLocalhost("getPublicPath", remoteSnapshot);
30
45
  }
31
- if ("getPublicPath" in remoteSnapshot && remoteSnapshot.getPublicPath.includes(LOCALHOST)) {
32
- remoteSnapshot.getPublicPath = replaceLocalhost(remoteSnapshot.getPublicPath);
46
+ if ("matchedVersion:" in remoteSnapshot) {
47
+ replaceObjectLocalhost("matchedVersion:", remoteSnapshot);
33
48
  }
34
49
  return args;
35
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "0.0.0-next-20240620124309",
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-20240620124309",
50
- "@module-federation/enhanced": "0.0.0-next-20240620124309",
51
- "@module-federation/node": "0.0.0-next-20240620124309"
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-20240620124309"
59
+ "@module-federation/manifest": "0.0.0-next-20240621074837"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "react": ">=17",