@module-federation/modern-js 0.0.0-next-20240523121007 → 0.0.0-next-20240528093255

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.
@@ -95,7 +95,7 @@ function collectLinks(id) {
95
95
  return links;
96
96
  }
97
97
  function MFReactComponent(props) {
98
- const { loading = "loading...", id } = props;
98
+ const { loading = "loading...", id, fallback } = props;
99
99
  const Component = /* @__PURE__ */ import_react.default.lazy(() => (0, import_runtime.loadRemote)(id).then((mod) => {
100
100
  const links = collectLinks(id);
101
101
  if (!mod) {
@@ -110,6 +110,14 @@ function MFReactComponent(props) {
110
110
  ]
111
111
  })
112
112
  };
113
+ }).catch((err) => {
114
+ if (!fallback) {
115
+ throw err;
116
+ }
117
+ const FallbackComponent = typeof fallback === "function" ? fallback(err) : fallback;
118
+ return {
119
+ default: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FallbackComponent, {})
120
+ };
113
121
  }));
114
122
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.Suspense, {
115
123
  fallback: loading,
@@ -62,7 +62,7 @@ function collectLinks(id) {
62
62
  return links;
63
63
  }
64
64
  function MFReactComponent(props) {
65
- var _props_loading = props.loading, loading = _props_loading === void 0 ? "loading..." : _props_loading, id = props.id;
65
+ var _props_loading = props.loading, loading = _props_loading === void 0 ? "loading..." : _props_loading, id = props.id, fallback = props.fallback;
66
66
  var Component = /* @__PURE__ */ React.lazy(function() {
67
67
  return loadRemote(id).then(function(mod) {
68
68
  var links = collectLinks(id);
@@ -80,6 +80,16 @@ function MFReactComponent(props) {
80
80
  });
81
81
  }
82
82
  };
83
+ }).catch(function(err) {
84
+ if (!fallback) {
85
+ throw err;
86
+ }
87
+ var FallbackComponent = typeof fallback === "function" ? fallback(err) : fallback;
88
+ return {
89
+ default: function() {
90
+ return /* @__PURE__ */ _jsx(FallbackComponent, {});
91
+ }
92
+ };
83
93
  });
84
94
  });
85
95
  return /* @__PURE__ */ _jsx(React.Suspense, {
@@ -61,7 +61,7 @@ function collectLinks(id) {
61
61
  return links;
62
62
  }
63
63
  function MFReactComponent(props) {
64
- const { loading = "loading...", id } = props;
64
+ const { loading = "loading...", id, fallback } = props;
65
65
  const Component = /* @__PURE__ */ React.lazy(() => loadRemote(id).then((mod) => {
66
66
  const links = collectLinks(id);
67
67
  if (!mod) {
@@ -76,6 +76,14 @@ function MFReactComponent(props) {
76
76
  ]
77
77
  })
78
78
  };
79
+ }).catch((err) => {
80
+ if (!fallback) {
81
+ throw err;
82
+ }
83
+ const FallbackComponent = typeof fallback === "function" ? fallback(err) : fallback;
84
+ return {
85
+ default: () => /* @__PURE__ */ _jsx(FallbackComponent, {})
86
+ };
79
87
  }));
80
88
  return /* @__PURE__ */ _jsx(React.Suspense, {
81
89
  fallback: loading,
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  interface IProps {
3
3
  id: string;
4
4
  loading?: React.ReactNode;
5
+ fallback?: (err: Error) => React.FC | React.FC;
5
6
  }
6
7
  declare function collectLinks(id: string): React.ReactNode[];
7
8
  declare function MFReactComponent(props: IProps): React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "0.0.0-next-20240523121007",
3
+ "version": "0.0.0-next-20240528093255",
4
4
  "files": [
5
5
  "dist/",
6
6
  "types.d.ts",
@@ -46,10 +46,10 @@
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-20240523121007",
50
- "@module-federation/enhanced": "0.0.0-next-20240523121007",
51
- "@module-federation/node": "0.0.0-next-20240523121007",
52
- "@module-federation/dts-plugin": "0.0.0-next-20240523121007"
49
+ "@module-federation/sdk": "0.0.0-next-20240528093255",
50
+ "@module-federation/enhanced": "0.0.0-next-20240528093255",
51
+ "@module-federation/node": "0.0.0-next-20240528093255",
52
+ "@module-federation/dts-plugin": "0.0.0-next-20240528093255"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@modern-js/app-tools": "^2.49.2",
@@ -57,7 +57,7 @@
57
57
  "@modern-js/runtime": "^2.49.2",
58
58
  "@modern-js/module-tools": "^2.35.0",
59
59
  "@modern-js/tsconfig": "^2.35.0",
60
- "@module-federation/manifest": "0.0.0-next-20240523121007"
60
+ "@module-federation/manifest": "0.0.0-next-20240528093255"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react": ">=17",