@module-federation/modern-js 0.0.0-next-20240515062211 → 0.0.0-next-20240515091026

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.
@@ -28,7 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var MFReactComponent_exports = {};
30
30
  __export(MFReactComponent_exports, {
31
- MFReactComponent: () => MFReactComponent
31
+ MFReactComponent: () => MFReactComponent,
32
+ collectLinks: () => collectLinks
32
33
  });
33
34
  module.exports = __toCommonJS(MFReactComponent_exports);
34
35
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -88,11 +89,15 @@ function MFReactComponent(props) {
88
89
  const { loading = "loading...", id } = props;
89
90
  const Component = /* @__PURE__ */ import_react.default.lazy(() => (0, import_runtime.loadRemote)(id).then((mod) => {
90
91
  const links = collectLinks(id);
92
+ if (!mod) {
93
+ throw new Error("load remote failed");
94
+ }
95
+ const Com = typeof mod === "object" ? "default" in mod ? mod.default : mod : mod;
91
96
  return {
92
97
  default: () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
93
98
  children: [
94
99
  links,
95
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(mod.default, {})
100
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Com, {})
96
101
  ]
97
102
  })
98
103
  };
@@ -104,5 +109,6 @@ function MFReactComponent(props) {
104
109
  }
105
110
  // Annotate the CommonJS export names for ESM import in node:
106
111
  0 && (module.exports = {
107
- MFReactComponent
112
+ MFReactComponent,
113
+ collectLinks
108
114
  });
@@ -19,7 +19,8 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
  var runtime_exports = {};
21
21
  __export(runtime_exports, {
22
- MFReactComponent: () => import_MFReactComponent.MFReactComponent
22
+ MFReactComponent: () => import_MFReactComponent.MFReactComponent,
23
+ collectLinks: () => import_MFReactComponent.collectLinks
23
24
  });
24
25
  module.exports = __toCommonJS(runtime_exports);
25
26
  __reExport(runtime_exports, require("@module-federation/enhanced/runtime"), module.exports);
@@ -27,5 +28,6 @@ var import_MFReactComponent = require("./MFReactComponent");
27
28
  // Annotate the CommonJS export names for ESM import in node:
28
29
  0 && (module.exports = {
29
30
  MFReactComponent,
31
+ collectLinks,
30
32
  ...require("@module-federation/enhanced/runtime")
31
33
  });
@@ -55,12 +55,16 @@ function MFReactComponent(props) {
55
55
  var Component = /* @__PURE__ */ React.lazy(function() {
56
56
  return loadRemote(id).then(function(mod) {
57
57
  var links = collectLinks(id);
58
+ if (!mod) {
59
+ throw new Error("load remote failed");
60
+ }
61
+ var Com = typeof mod === "object" ? "default" in mod ? mod.default : mod : mod;
58
62
  return {
59
63
  default: function() {
60
64
  return /* @__PURE__ */ _jsxs("div", {
61
65
  children: [
62
66
  links,
63
- /* @__PURE__ */ _jsx(mod.default, {})
67
+ /* @__PURE__ */ _jsx(Com, {})
64
68
  ]
65
69
  });
66
70
  }
@@ -73,5 +77,6 @@ function MFReactComponent(props) {
73
77
  });
74
78
  }
75
79
  export {
76
- MFReactComponent
80
+ MFReactComponent,
81
+ collectLinks
77
82
  };
@@ -1,5 +1,6 @@
1
1
  export * from "@module-federation/enhanced/runtime";
2
- import { MFReactComponent } from "./MFReactComponent";
2
+ import { MFReactComponent, collectLinks } from "./MFReactComponent";
3
3
  export {
4
- MFReactComponent
4
+ MFReactComponent,
5
+ collectLinks
5
6
  };
@@ -55,11 +55,15 @@ function MFReactComponent(props) {
55
55
  const { loading = "loading...", id } = props;
56
56
  const Component = /* @__PURE__ */ React.lazy(() => loadRemote(id).then((mod) => {
57
57
  const links = collectLinks(id);
58
+ if (!mod) {
59
+ throw new Error("load remote failed");
60
+ }
61
+ const Com = typeof mod === "object" ? "default" in mod ? mod.default : mod : mod;
58
62
  return {
59
63
  default: () => /* @__PURE__ */ _jsxs("div", {
60
64
  children: [
61
65
  links,
62
- /* @__PURE__ */ _jsx(mod.default, {})
66
+ /* @__PURE__ */ _jsx(Com, {})
63
67
  ]
64
68
  })
65
69
  };
@@ -70,5 +74,6 @@ function MFReactComponent(props) {
70
74
  });
71
75
  }
72
76
  export {
73
- MFReactComponent
77
+ MFReactComponent,
78
+ collectLinks
74
79
  };
@@ -1,5 +1,6 @@
1
1
  export * from "@module-federation/enhanced/runtime";
2
- import { MFReactComponent } from "./MFReactComponent";
2
+ import { MFReactComponent, collectLinks } from "./MFReactComponent";
3
3
  export {
4
- MFReactComponent
4
+ MFReactComponent,
5
+ collectLinks
5
6
  };
@@ -3,5 +3,6 @@ interface IProps {
3
3
  id: string;
4
4
  loading?: React.ReactNode;
5
5
  }
6
+ declare function collectLinks(id: string): React.ReactNode[];
6
7
  declare function MFReactComponent(props: IProps): React.JSX.Element;
7
- export { MFReactComponent };
8
+ export { MFReactComponent, collectLinks };
@@ -1,2 +1,2 @@
1
1
  export * from '@module-federation/enhanced/runtime';
2
- export { MFReactComponent } from './MFReactComponent';
2
+ export { MFReactComponent, collectLinks } from './MFReactComponent';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "0.0.0-next-20240515062211",
3
+ "version": "0.0.0-next-20240515091026",
4
4
  "files": [
5
5
  "dist/",
6
6
  "types.d.ts",
@@ -38,9 +38,9 @@
38
38
  "@swc/helpers": "0.5.3",
39
39
  "@modern-js/utils": "^2.49.2",
40
40
  "@modern-js/node-bundle-require": "^2.49.2",
41
- "@module-federation/sdk": "0.0.0-next-20240515062211",
42
- "@module-federation/enhanced": "0.0.0-next-20240515062211",
43
- "@module-federation/node": "0.0.0-next-20240515062211"
41
+ "@module-federation/sdk": "0.0.0-next-20240515091026",
42
+ "@module-federation/enhanced": "0.0.0-next-20240515091026",
43
+ "@module-federation/node": "0.0.0-next-20240515091026"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@modern-js/app-tools": "^2.49.2",
@@ -48,7 +48,7 @@
48
48
  "@modern-js/runtime": "^2.49.2",
49
49
  "@modern-js/module-tools": "^2.35.0",
50
50
  "@modern-js/tsconfig": "^2.35.0",
51
- "@module-federation/manifest": "0.0.0-next-20240515062211"
51
+ "@module-federation/manifest": "0.0.0-next-20240515091026"
52
52
  },
53
53
  "scripts": {
54
54
  "build": "modern build"