@module-federation/bridge-react 0.0.0-next-20250708104625 → 0.0.0-next-20250708134245

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @module-federation/bridge-react
2
2
 
3
- ## 0.0.0-next-20250708104625
3
+ ## 0.0.0-next-20250708134245
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -9,8 +9,8 @@
9
9
  ### Patch Changes
10
10
 
11
11
  - eb0d1dc: feat(bridge-react): export createLazyCompoent api
12
- - @module-federation/sdk@0.0.0-next-20250708104625
13
- - @module-federation/bridge-shared@0.0.0-next-20250708104625
12
+ - @module-federation/sdk@0.0.0-next-20250708134245
13
+ - @module-federation/bridge-shared@0.0.0-next-20250708134245
14
14
 
15
15
  ## 0.16.0
16
16
 
@@ -6,7 +6,7 @@ export default dataFetchServerMiddleware;
6
6
  export { }
7
7
 
8
8
 
9
- declare module '@module-federation/runtime' {
9
+ declare module '@module-federation/runtime-core' {
10
10
  interface FederationHost {
11
11
  createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
12
12
  prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
@@ -1,4 +1,4 @@
1
- import { D as DATA_FETCH_QUERY, l as logger, g as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, f as fetchData, a as loadDataFetchModule } from "./utils-BTYYwZcb.mjs";
1
+ import { D as DATA_FETCH_QUERY, l as logger, g as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, f as fetchData, a as loadDataFetchModule } from "./utils-Cy-amYU5.mjs";
2
2
  import { M as MANIFEST_EXT, S as SEPARATOR } from "./index.esm-BCeUd-x9.mjs";
3
3
  function wrapSetTimeout(targetPromise, delay = 2e4, id) {
4
4
  if (targetPromise && typeof targetPromise.then === "function") {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const lazyUtils = require("./utils-iEVlDmyk.js");
4
- const prefetch = require("./prefetch-cGDaDkgV.js");
4
+ const prefetch = require("./prefetch-BWabXlKU.js");
5
5
  async function callDataFetch() {
6
6
  const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
7
7
  if (dataFetch) {
@@ -77,7 +77,7 @@ export declare function revalidateTag(tag: string): void;
77
77
  export { }
78
78
 
79
79
 
80
- declare module '@module-federation/runtime' {
80
+ declare module '@module-federation/runtime-core' {
81
81
  interface FederationHost {
82
82
  createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
83
83
  prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
@@ -1,7 +1,7 @@
1
- import { u as DATA_FETCH_FUNCTION } from "./utils-BTYYwZcb.mjs";
2
- import { C, b, e, h, c, d, r } from "./utils-BTYYwZcb.mjs";
3
- import { d as dataFetchFunction } from "./prefetch-Cx6MrkdU.mjs";
4
- import { i, p } from "./prefetch-Cx6MrkdU.mjs";
1
+ import { x as DATA_FETCH_FUNCTION } from "./utils-Cy-amYU5.mjs";
2
+ import { C, b, e, h, c, d, r } from "./utils-Cy-amYU5.mjs";
3
+ import { d as dataFetchFunction } from "./prefetch-Dq-ZhN17.mjs";
4
+ import { i, p } from "./prefetch-Dq-ZhN17.mjs";
5
5
  async function callDataFetch() {
6
6
  const dataFetch = globalThis[DATA_FETCH_FUNCTION];
7
7
  if (dataFetch) {
package/dist/index.cjs.js CHANGED
@@ -6,10 +6,10 @@ const React = require("react");
6
6
  const index = require("./index-C0fDZB5b.js");
7
7
  const ReactRouterDOM = require("react-router-dom");
8
8
  const plugin = require("./plugin.cjs.js");
9
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-CttAWi8N.js");
9
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-Bobxn-VP.js");
10
10
  const lazyUtils = require("./utils-iEVlDmyk.js");
11
11
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
12
- const prefetch = require("./prefetch-cGDaDkgV.js");
12
+ const prefetch = require("./prefetch-BWabXlKU.js");
13
13
  function _interopNamespaceDefault(e2) {
14
14
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
15
15
  if (e2) {
package/dist/index.d.ts CHANGED
@@ -82,6 +82,7 @@ export declare type CreateLazyComponentOptions<T, E extends keyof T> = {
82
82
  fallback: ReactNode | ((errorInfo: ErrorInfo) => ReactNode);
83
83
  export?: E;
84
84
  dataFetchParams?: DataFetchParams;
85
+ noSSR?: boolean;
85
86
  cacheData?: boolean;
86
87
  };
87
88
 
@@ -268,7 +269,7 @@ export declare function setSSREnv({ fetchServerQuery, }: {
268
269
  export { }
269
270
 
270
271
 
271
- declare module '@module-federation/runtime' {
272
+ declare module '@module-federation/runtime-core' {
272
273
  interface FederationHost {
273
274
  createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
274
275
  prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
package/dist/index.es.js CHANGED
@@ -4,10 +4,10 @@ import React__default, { forwardRef, useRef, useState, useEffect, useContext } f
4
4
  import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin } from "./index-CqxytsLY.mjs";
5
5
  import * as ReactRouterDOM from "react-router-dom";
6
6
  import { federationRuntime } from "./plugin.es.js";
7
- import { b, a, c, l } from "./lazy-load-component-plugin-hOC-Yus_.mjs";
8
- import { C, b as b2, E, e, h, c as c2, d, r, s } from "./utils-BTYYwZcb.mjs";
7
+ import { b, a, c, l } from "./lazy-load-component-plugin-Dvi5dnb7.mjs";
8
+ import { C, b as b2, E, e, h, c as c2, d, r, s } from "./utils-Cy-amYU5.mjs";
9
9
  import { callDataFetch } from "./data-fetch-utils.es.js";
10
- import { p } from "./prefetch-Cx6MrkdU.mjs";
10
+ import { p } from "./prefetch-Dq-ZhN17.mjs";
11
11
  function createReact16Or17Root(container) {
12
12
  return {
13
13
  render(children) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const prefetch = require("./prefetch-cGDaDkgV.js");
2
+ const prefetch = require("./prefetch-BWabXlKU.js");
3
3
  const lazyUtils = require("./utils-iEVlDmyk.js");
4
4
  const React = require("react");
5
5
  const autoFetchData = () => {
@@ -296,12 +296,9 @@ function collectSSRAssets(options) {
296
296
  }
297
297
  return [...scripts, ...links];
298
298
  }
299
- function getServerNeedRemoteInfo(loadedRemoteInfo, id) {
299
+ function getServerNeedRemoteInfo(loadedRemoteInfo, id, noSSR) {
300
300
  var _a;
301
- if (
302
- // noSSR ||
303
- typeof window !== "undefined" && window.location.href !== window[lazyUtils.FS_HREF]
304
- ) {
301
+ if (noSSR || typeof window !== "undefined" && window.location.href !== window[lazyUtils.FS_HREF]) {
305
302
  if (!(loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.version)) {
306
303
  throw new Error(`${loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.name} version is empty`);
307
304
  }
@@ -347,7 +344,7 @@ function createLazyComponent(options) {
347
344
  }
348
345
  return m;
349
346
  };
350
- const getData = async () => {
347
+ const getData = async (noSSR) => {
351
348
  let loadedRemoteInfo;
352
349
  let moduleId;
353
350
  try {
@@ -386,8 +383,7 @@ function createLazyComponent(options) {
386
383
  ...options.dataFetchParams,
387
384
  isDowngrade: false
388
385
  },
389
- // getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey, noSSR),
390
- getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey)
386
+ getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey, noSSR)
391
387
  );
392
388
  lazyUtils.setDataFetchItemLoadedStatus(dataFetchMapKey);
393
389
  lazyUtils.logger.debug("get data res: \n", data);
@@ -447,16 +443,53 @@ function createLazyComponent(options) {
447
443
  if (cacheData && dataCache) {
448
444
  return /* @__PURE__ */ React.createElement(LazyComponent, { ...args, mfData: dataCache });
449
445
  }
450
- return /* @__PURE__ */ React.createElement(
451
- AwaitDataFetch,
452
- {
453
- resolve: getData(),
454
- loading: options.loading,
455
- delayLoading: options.delayLoading,
456
- errorElement: options.fallback
457
- },
458
- (data) => /* @__PURE__ */ React.createElement(LazyComponent, { ...args, mfData: data })
459
- );
446
+ if (!options.noSSR) {
447
+ return /* @__PURE__ */ React.createElement(
448
+ AwaitDataFetch,
449
+ {
450
+ resolve: getData(options.noSSR),
451
+ loading: options.loading,
452
+ delayLoading: options.delayLoading,
453
+ errorElement: options.fallback
454
+ },
455
+ (data) => /* @__PURE__ */ React.createElement(LazyComponent, { ...args, mfData: data })
456
+ );
457
+ } else {
458
+ const [data, setData] = React.useState(null);
459
+ const [loading, setLoading] = React.useState(true);
460
+ const [error, setError] = React.useState(null);
461
+ React.useEffect(() => {
462
+ let isMounted = true;
463
+ const fetchDataAsync = async () => {
464
+ try {
465
+ setLoading(true);
466
+ const result = await getData(options.noSSR);
467
+ if (isMounted) {
468
+ setData(result);
469
+ }
470
+ } catch (e) {
471
+ if (isMounted) {
472
+ setError(transformError(e));
473
+ }
474
+ } finally {
475
+ if (isMounted) {
476
+ setLoading(false);
477
+ }
478
+ }
479
+ };
480
+ fetchDataAsync();
481
+ return () => {
482
+ isMounted = false;
483
+ };
484
+ }, []);
485
+ if (loading) {
486
+ return /* @__PURE__ */ React.createElement(DelayedLoading, { delayLoading: options.delayLoading }, options.loading);
487
+ }
488
+ if (error) {
489
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, typeof options.fallback === "function" ? options.fallback(error) : options.fallback);
490
+ }
491
+ return /* @__PURE__ */ React.createElement(LazyComponent, { ...args, mfData: data });
492
+ }
460
493
  };
461
494
  }
462
495
  function lazyLoadComponentPlugin() {
@@ -476,15 +509,6 @@ function lazyLoadComponentPlugin() {
476
509
  ...options
477
510
  });
478
511
  };
479
- instance.wrapNoSSR = (fn) => {
480
- return (options) => {
481
- return fn({
482
- instance,
483
- noSSR: true,
484
- ...options
485
- });
486
- };
487
- };
488
512
  instance.collectSSRAssets = (options) => {
489
513
  return collectSSRAssets({
490
514
  instance,
@@ -1,6 +1,6 @@
1
- import { i as injectDataFetch, p as prefetch } from "./prefetch-Cx6MrkdU.mjs";
2
- import { i as initDataFetchMap, j as isDataLoaderExpose, k as getDataFetchInfo, m as getDataFetchMapKey, l as logger, n as getDataFetchItem, o as DATA_FETCH_CLIENT_SUFFIX, p as MF_DATA_FETCH_TYPE, q as isServerEnv, t as isCSROnly, a as loadDataFetchModule, M as MF_DATA_FETCH_STATUS, g as getDataFetchMap, u as DATA_FETCH_FUNCTION, v as getDataFetchIdWithErrorMsgs, w as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, x as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, y as getLoadedRemoteInfos, f as fetchData$1, z as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-BTYYwZcb.mjs";
3
- import React__default, { useRef, Suspense, useState } from "react";
1
+ import { i as injectDataFetch, p as prefetch } from "./prefetch-Dq-ZhN17.mjs";
2
+ import { i as initDataFetchMap, j as isDataLoaderExpose, k as getDataFetchInfo, m as getDataFetchMapKey, l as logger, n as getDataFetchItem, o as DATA_FETCH_CLIENT_SUFFIX, p as MF_DATA_FETCH_TYPE, q as isServerEnv, t as isCSROnly, a as loadDataFetchModule, M as MF_DATA_FETCH_STATUS, g as getDataFetchMap, u as getDataFetchIdWithErrorMsgs, v as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, w as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, x as DATA_FETCH_FUNCTION, y as getLoadedRemoteInfos, f as fetchData$1, z as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-Cy-amYU5.mjs";
3
+ import React__default, { useRef, useState, Suspense, useEffect } from "react";
4
4
  const autoFetchData = () => {
5
5
  initDataFetchMap();
6
6
  injectDataFetch();
@@ -295,12 +295,9 @@ function collectSSRAssets(options) {
295
295
  }
296
296
  return [...scripts, ...links];
297
297
  }
298
- function getServerNeedRemoteInfo(loadedRemoteInfo, id) {
298
+ function getServerNeedRemoteInfo(loadedRemoteInfo, id, noSSR) {
299
299
  var _a;
300
- if (
301
- // noSSR ||
302
- typeof window !== "undefined" && window.location.href !== window[FS_HREF]
303
- ) {
300
+ if (noSSR || typeof window !== "undefined" && window.location.href !== window[FS_HREF]) {
304
301
  if (!(loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.version)) {
305
302
  throw new Error(`${loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.name} version is empty`);
306
303
  }
@@ -346,7 +343,7 @@ function createLazyComponent(options) {
346
343
  }
347
344
  return m;
348
345
  };
349
- const getData = async () => {
346
+ const getData = async (noSSR) => {
350
347
  let loadedRemoteInfo;
351
348
  let moduleId;
352
349
  try {
@@ -385,8 +382,7 @@ function createLazyComponent(options) {
385
382
  ...options.dataFetchParams,
386
383
  isDowngrade: false
387
384
  },
388
- // getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey, noSSR),
389
- getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey)
385
+ getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey, noSSR)
390
386
  );
391
387
  setDataFetchItemLoadedStatus(dataFetchMapKey);
392
388
  logger.debug("get data res: \n", data);
@@ -446,16 +442,53 @@ function createLazyComponent(options) {
446
442
  if (cacheData && dataCache) {
447
443
  return /* @__PURE__ */ React__default.createElement(LazyComponent, { ...args, mfData: dataCache });
448
444
  }
449
- return /* @__PURE__ */ React__default.createElement(
450
- AwaitDataFetch,
451
- {
452
- resolve: getData(),
453
- loading: options.loading,
454
- delayLoading: options.delayLoading,
455
- errorElement: options.fallback
456
- },
457
- (data) => /* @__PURE__ */ React__default.createElement(LazyComponent, { ...args, mfData: data })
458
- );
445
+ if (!options.noSSR) {
446
+ return /* @__PURE__ */ React__default.createElement(
447
+ AwaitDataFetch,
448
+ {
449
+ resolve: getData(options.noSSR),
450
+ loading: options.loading,
451
+ delayLoading: options.delayLoading,
452
+ errorElement: options.fallback
453
+ },
454
+ (data) => /* @__PURE__ */ React__default.createElement(LazyComponent, { ...args, mfData: data })
455
+ );
456
+ } else {
457
+ const [data, setData] = useState(null);
458
+ const [loading, setLoading] = useState(true);
459
+ const [error, setError] = useState(null);
460
+ useEffect(() => {
461
+ let isMounted = true;
462
+ const fetchDataAsync = async () => {
463
+ try {
464
+ setLoading(true);
465
+ const result = await getData(options.noSSR);
466
+ if (isMounted) {
467
+ setData(result);
468
+ }
469
+ } catch (e) {
470
+ if (isMounted) {
471
+ setError(transformError(e));
472
+ }
473
+ } finally {
474
+ if (isMounted) {
475
+ setLoading(false);
476
+ }
477
+ }
478
+ };
479
+ fetchDataAsync();
480
+ return () => {
481
+ isMounted = false;
482
+ };
483
+ }, []);
484
+ if (loading) {
485
+ return /* @__PURE__ */ React__default.createElement(DelayedLoading, { delayLoading: options.delayLoading }, options.loading);
486
+ }
487
+ if (error) {
488
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, typeof options.fallback === "function" ? options.fallback(error) : options.fallback);
489
+ }
490
+ return /* @__PURE__ */ React__default.createElement(LazyComponent, { ...args, mfData: data });
491
+ }
459
492
  };
460
493
  }
461
494
  function lazyLoadComponentPlugin() {
@@ -475,15 +508,6 @@ function lazyLoadComponentPlugin() {
475
508
  ...options
476
509
  });
477
510
  };
478
- instance.wrapNoSSR = (fn) => {
479
- return (options) => {
480
- return fn({
481
- instance,
482
- noSSR: true,
483
- ...options
484
- });
485
- };
486
- };
487
511
  instance.collectSSRAssets = (options) => {
488
512
  return collectSSRAssets({
489
513
  instance,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-CttAWi8N.js");
4
- require("./prefetch-cGDaDkgV.js");
3
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-Bobxn-VP.js");
4
+ require("./prefetch-BWabXlKU.js");
5
5
  exports.default = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
6
6
  exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
@@ -7,7 +7,7 @@ export { lazyLoadComponentPlugin }
7
7
  export { }
8
8
 
9
9
 
10
- declare module '@module-federation/runtime' {
10
+ declare module '@module-federation/runtime-core' {
11
11
  interface FederationHost {
12
12
  createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
13
13
  prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
@@ -1,5 +1,5 @@
1
- import { l, l as l2 } from "./lazy-load-component-plugin-hOC-Yus_.mjs";
2
- import "./prefetch-Cx6MrkdU.mjs";
1
+ import { l, l as l2 } from "./lazy-load-component-plugin-Dvi5dnb7.mjs";
2
+ import "./prefetch-Dq-ZhN17.mjs";
3
3
  export {
4
4
  l as default,
5
5
  l2 as lazyLoadComponentPlugin
@@ -140,7 +140,7 @@ export declare const wrapDataFetchId: (id?: string) => string;
140
140
  export { }
141
141
 
142
142
 
143
- declare module '@module-federation/runtime' {
143
+ declare module '@module-federation/runtime-core' {
144
144
  interface FederationHost {
145
145
  createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
146
146
  prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
@@ -1,12 +1,12 @@
1
1
  import "./index.esm-BCeUd-x9.mjs";
2
- import { G, H, f, J, I, v, k, n, g, m, B, y, i, t, j, q, a, z, s, x } from "./utils-BTYYwZcb.mjs";
2
+ import { G, H, f, J, I, u, k, n, g, m, B, y, i, t, j, q, a, z, s, w } from "./utils-Cy-amYU5.mjs";
3
3
  export {
4
4
  G as callAllDowngrade,
5
5
  H as callDowngrade,
6
6
  f as fetchData,
7
7
  J as flushDataFetch,
8
8
  I as getDataFetchCache,
9
- v as getDataFetchIdWithErrorMsgs,
9
+ u as getDataFetchIdWithErrorMsgs,
10
10
  k as getDataFetchInfo,
11
11
  n as getDataFetchItem,
12
12
  g as getDataFetchMap,
@@ -20,5 +20,5 @@ export {
20
20
  a as loadDataFetchModule,
21
21
  z as setDataFetchItemLoadedStatus,
22
22
  s as setSSREnv,
23
- x as wrapDataFetchId
23
+ w as wrapDataFetchId
24
24
  };
package/dist/plugin.d.ts CHANGED
@@ -13,7 +13,7 @@ export declare type FederationRuntimeType = {
13
13
  export { }
14
14
 
15
15
 
16
- declare module '@module-federation/runtime' {
16
+ declare module '@module-federation/runtime-core' {
17
17
  interface FederationHost {
18
18
  createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
19
19
  prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
@@ -1252,17 +1252,20 @@ var helpers = _extends$2({}, helpers$1, {
1252
1252
  async function prefetch(options) {
1253
1253
  const { instance, id, dataFetchParams, preloadComponentResource } = options;
1254
1254
  if (!id) {
1255
- throw new Error("id is required for prefetch!");
1255
+ lazyUtils.logger.error("id is required for prefetch!");
1256
+ return;
1256
1257
  }
1257
1258
  if (!instance) {
1258
- throw new Error("instance is required for prefetch!");
1259
+ lazyUtils.logger.error("instance is required for prefetch!");
1260
+ return;
1259
1261
  }
1260
1262
  const matchedRemoteInfo = helpers.utils.matchRemoteWithNameAndExpose(
1261
1263
  instance.options.remotes,
1262
1264
  id
1263
1265
  );
1264
1266
  if (!matchedRemoteInfo) {
1265
- throw new Error(`Can not found '${id}' in instance.options.remotes!`);
1267
+ lazyUtils.logger.error(`Can not found '${id}' in instance.options.remotes!`);
1268
+ return;
1266
1269
  }
1267
1270
  const { remote, expose } = matchedRemoteInfo;
1268
1271
  const { remoteSnapshot, globalSnapshot } = await instance.snapshotHandler.loadRemoteSnapshotInfo({
@@ -1,4 +1,4 @@
1
- import { u as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger$1, g as getDataFetchMap, i as initDataFetchMap, n as getDataFetchItem, M as MF_DATA_FETCH_STATUS, p as MF_DATA_FETCH_TYPE, A as DOWNGRADE_KEY, B as getDowngradeTag, G as callAllDowngrade, H as callDowngrade, k as getDataFetchInfo, m as getDataFetchMapKey } from "./utils-BTYYwZcb.mjs";
1
+ import { x as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger$1, g as getDataFetchMap, i as initDataFetchMap, n as getDataFetchItem, M as MF_DATA_FETCH_STATUS, p as MF_DATA_FETCH_TYPE, A as DOWNGRADE_KEY, B as getDowngradeTag, G as callAllDowngrade, H as callDowngrade, k as getDataFetchInfo, m as getDataFetchMapKey } from "./utils-Cy-amYU5.mjs";
2
2
  import { b as isDebugMode, d as createLink, e as createScript, i as isBrowserEnv, c as createLogger, a as composeKeyWithSeparator, l as loadScriptNode, f as loadScript } from "./index.esm-BCeUd-x9.mjs";
3
3
  const dataFetchFunction = async function(options) {
4
4
  var _a, _b;
@@ -1251,17 +1251,20 @@ var helpers = _extends$2({}, helpers$1, {
1251
1251
  async function prefetch(options) {
1252
1252
  const { instance, id, dataFetchParams, preloadComponentResource } = options;
1253
1253
  if (!id) {
1254
- throw new Error("id is required for prefetch!");
1254
+ logger$1.error("id is required for prefetch!");
1255
+ return;
1255
1256
  }
1256
1257
  if (!instance) {
1257
- throw new Error("instance is required for prefetch!");
1258
+ logger$1.error("instance is required for prefetch!");
1259
+ return;
1258
1260
  }
1259
1261
  const matchedRemoteInfo = helpers.utils.matchRemoteWithNameAndExpose(
1260
1262
  instance.options.remotes,
1261
1263
  id
1262
1264
  );
1263
1265
  if (!matchedRemoteInfo) {
1264
- throw new Error(`Can not found '${id}' in instance.options.remotes!`);
1266
+ logger$1.error(`Can not found '${id}' in instance.options.remotes!`);
1267
+ return;
1265
1268
  }
1266
1269
  const { remote, expose } = matchedRemoteInfo;
1267
1270
  const { remoteSnapshot, globalSnapshot } = await instance.snapshotHandler.loadRemoteSnapshotInfo({
@@ -9,7 +9,7 @@ export * from "react-router-dom/";
9
9
  export { }
10
10
 
11
11
 
12
- declare module '@module-federation/runtime' {
12
+ declare module '@module-federation/runtime-core' {
13
13
  interface FederationHost {
14
14
  createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
15
15
  prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
@@ -11,7 +11,7 @@ export * from "react-router-dom/";
11
11
  export { }
12
12
 
13
13
 
14
- declare module '@module-federation/runtime' {
14
+ declare module '@module-federation/runtime-core' {
15
15
  interface FederationHost {
16
16
  createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
17
17
  prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
package/dist/router.d.ts CHANGED
@@ -11,7 +11,7 @@ export * from "react-router-dom/";
11
11
  export { }
12
12
 
13
13
 
14
- declare module '@module-federation/runtime' {
14
+ declare module '@module-federation/runtime-core' {
15
15
  interface FederationHost {
16
16
  createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
17
17
  prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
@@ -2007,10 +2007,10 @@ export {
2007
2007
  revalidateTag as r,
2008
2008
  setSSREnv as s,
2009
2009
  isCSROnly as t,
2010
- DATA_FETCH_FUNCTION as u,
2011
- getDataFetchIdWithErrorMsgs as v,
2012
- DATA_FETCH_ERROR_PREFIX as w,
2013
- wrapDataFetchId as x,
2010
+ getDataFetchIdWithErrorMsgs as u,
2011
+ DATA_FETCH_ERROR_PREFIX as v,
2012
+ wrapDataFetchId as w,
2013
+ DATA_FETCH_FUNCTION as x,
2014
2014
  getLoadedRemoteInfos as y,
2015
2015
  setDataFetchItemLoadedStatus as z
2016
2016
  };
package/dist/v18.d.ts CHANGED
@@ -105,7 +105,7 @@ export declare type RootType = HTMLElement | Root_2;
105
105
  export { }
106
106
 
107
107
 
108
- declare module '@module-federation/runtime' {
108
+ declare module '@module-federation/runtime-core' {
109
109
  interface FederationHost {
110
110
  createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
111
111
  prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
package/dist/v19.d.ts CHANGED
@@ -106,7 +106,7 @@ export declare type RootType = HTMLElement | Root_2;
106
106
  export { }
107
107
 
108
108
 
109
- declare module '@module-federation/runtime' {
109
+ declare module '@module-federation/runtime-core' {
110
110
  interface FederationHost {
111
111
  createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
112
112
  prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-react",
3
- "version": "0.0.0-next-20250708104625",
3
+ "version": "0.0.0-next-20250708134245",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -94,8 +94,8 @@
94
94
  "dependencies": {
95
95
  "react-error-boundary": "^4.1.2",
96
96
  "lru-cache": "^10.4.3",
97
- "@module-federation/bridge-shared": "0.0.0-next-20250708104625",
98
- "@module-federation/sdk": "0.0.0-next-20250708104625"
97
+ "@module-federation/bridge-shared": "0.0.0-next-20250708134245",
98
+ "@module-federation/sdk": "0.0.0-next-20250708134245"
99
99
  },
100
100
  "peerDependencies": {
101
101
  "react": ">=16.9.0",
@@ -117,7 +117,8 @@
117
117
  "vite": "^5.4.18",
118
118
  "vite-plugin-dts": "^4.3.0",
119
119
  "hono": "3.12.12",
120
- "@module-federation/runtime": "0.0.0-next-20250708104625"
120
+ "@module-federation/runtime": "0.0.0-next-20250708134245",
121
+ "@module-federation/runtime-core": "0.0.0-next-20250708134245"
121
122
  },
122
123
  "scripts": {
123
124
  "dev": "vite",
@@ -42,7 +42,7 @@ export type CreateLazyComponentOptions<T, E extends keyof T> = {
42
42
  fallback: ReactNode | ((errorInfo: ErrorInfo) => ReactNode);
43
43
  export?: E;
44
44
  dataFetchParams?: DataFetchParams;
45
- // noSSR?: boolean;
45
+ noSSR?: boolean;
46
46
  cacheData?: boolean;
47
47
  };
48
48
 
@@ -157,12 +157,11 @@ export function collectSSRAssets(options: IProps) {
157
157
  function getServerNeedRemoteInfo(
158
158
  loadedRemoteInfo: ReturnType<typeof getLoadedRemoteInfos>,
159
159
  id: string,
160
- // noSSR?: boolean,
160
+ noSSR?: boolean,
161
161
  ): NoSSRRemoteInfo | undefined {
162
162
  if (
163
- // noSSR ||
164
- typeof window !== 'undefined' &&
165
- window.location.href !== window[FS_HREF]
163
+ noSSR ||
164
+ (typeof window !== 'undefined' && window.location.href !== window[FS_HREF])
166
165
  ) {
167
166
  if (!loadedRemoteInfo?.version) {
168
167
  throw new Error(`${loadedRemoteInfo?.name} version is empty`);
@@ -233,8 +232,7 @@ export function createLazyComponent<T, E extends keyof T>(
233
232
  return m;
234
233
  };
235
234
 
236
- // const getData = async (noSSR?: boolean) => {
237
- const getData = async () => {
235
+ const getData = async (noSSR?: boolean) => {
238
236
  let loadedRemoteInfo: ReturnType<typeof getLoadedRemoteInfos>;
239
237
  let moduleId: string;
240
238
  try {
@@ -273,8 +271,7 @@ export function createLazyComponent<T, E extends keyof T>(
273
271
  ...options.dataFetchParams,
274
272
  isDowngrade: false,
275
273
  },
276
- // getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey, noSSR),
277
- getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey),
274
+ getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey, noSSR),
278
275
  );
279
276
  setDataFetchItemLoadedStatus(dataFetchMapKey);
280
277
  logger.debug('get data res: \n', data);
@@ -347,72 +344,71 @@ export function createLazyComponent<T, E extends keyof T>(
347
344
  // @ts-expect-error ignore
348
345
  return <LazyComponent {...args} mfData={dataCache} />;
349
346
  }
350
- return (
351
- <AwaitDataFetch
352
- // resolve={getData(options.noSSR)}
353
- resolve={getData()}
354
- loading={options.loading}
355
- delayLoading={options.delayLoading}
356
- errorElement={options.fallback}
357
- >
358
- {/* @ts-expect-error ignore */}
359
- {(data) => <LazyComponent {...args} mfData={data} />}
360
- </AwaitDataFetch>
361
- );
362
- // if (!options.noSSR) {
363
347
 
364
- // } else {
365
- // // Client-side rendering logic
366
- // const [data, setData] = useState<unknown>(null);
367
- // const [loading, setLoading] = useState<boolean>(true);
368
- // const [error, setError] = useState<ErrorInfo | null>(null);
348
+ if (!options.noSSR) {
349
+ return (
350
+ <AwaitDataFetch
351
+ resolve={getData(options.noSSR)}
352
+ loading={options.loading}
353
+ delayLoading={options.delayLoading}
354
+ errorElement={options.fallback}
355
+ >
356
+ {/* @ts-expect-error ignore */}
357
+ {(data) => <LazyComponent {...args} mfData={data} />}
358
+ </AwaitDataFetch>
359
+ );
360
+ } else {
361
+ // Client-side rendering logic
362
+ const [data, setData] = useState<unknown>(null);
363
+ const [loading, setLoading] = useState<boolean>(true);
364
+ const [error, setError] = useState<ErrorInfo | null>(null);
369
365
 
370
- // useEffect(() => {
371
- // let isMounted = true;
372
- // const fetchDataAsync = async () => {
373
- // try {
374
- // setLoading(true);
375
- // const result = await getData(options.noSSR);
376
- // if (isMounted) {
377
- // setData(result);
378
- // }
379
- // } catch (e) {
380
- // if (isMounted) {
381
- // setError(transformError(e as Error));
382
- // }
383
- // } finally {
384
- // if (isMounted) {
385
- // setLoading(false);
386
- // }
387
- // }
388
- // };
366
+ useEffect(() => {
367
+ let isMounted = true;
368
+ const fetchDataAsync = async () => {
369
+ try {
370
+ setLoading(true);
371
+ const result = await getData(options.noSSR);
372
+ if (isMounted) {
373
+ setData(result);
374
+ }
375
+ } catch (e) {
376
+ if (isMounted) {
377
+ setError(transformError(e as Error));
378
+ }
379
+ } finally {
380
+ if (isMounted) {
381
+ setLoading(false);
382
+ }
383
+ }
384
+ };
389
385
 
390
- // fetchDataAsync();
386
+ fetchDataAsync();
391
387
 
392
- // return () => {
393
- // isMounted = false;
394
- // };
395
- // }, []);
388
+ return () => {
389
+ isMounted = false;
390
+ };
391
+ }, []);
396
392
 
397
- // if (loading) {
398
- // return (
399
- // <DelayedLoading delayLoading={options.delayLoading}>
400
- // {options.loading}
401
- // </DelayedLoading>
402
- // );
403
- // }
393
+ if (loading) {
394
+ return (
395
+ <DelayedLoading delayLoading={options.delayLoading}>
396
+ {options.loading}
397
+ </DelayedLoading>
398
+ );
399
+ }
404
400
 
405
- // if (error) {
406
- // return (
407
- // <>
408
- // {typeof options.fallback === 'function'
409
- // ? options.fallback(error)
410
- // : options.fallback}
411
- // </>
412
- // );
413
- // }
414
- // // @ts-expect-error ignore
415
- // return <LazyComponent {...args} mfData={data} />;
416
- // }
401
+ if (error) {
402
+ return (
403
+ <>
404
+ {typeof options.fallback === 'function'
405
+ ? options.fallback(error)
406
+ : options.fallback}
407
+ </>
408
+ );
409
+ }
410
+ // @ts-expect-error ignore
411
+ return <LazyComponent {...args} mfData={data} />;
412
+ }
417
413
  };
418
414
  }
@@ -4,6 +4,7 @@ import {
4
4
  getDataFetchMap,
5
5
  getDataFetchMapKey,
6
6
  } from '../utils';
7
+ import logger from '../logger';
7
8
  import helpers from '@module-federation/runtime/helpers';
8
9
  import { DataFetchParams } from '../types';
9
10
 
@@ -17,17 +18,20 @@ export type PrefetchOptions = {
17
18
  export async function prefetch(options: PrefetchOptions) {
18
19
  const { instance, id, dataFetchParams, preloadComponentResource } = options;
19
20
  if (!id) {
20
- throw new Error('id is required for prefetch!');
21
+ logger.error('id is required for prefetch!');
22
+ return;
21
23
  }
22
24
  if (!instance) {
23
- throw new Error('instance is required for prefetch!');
25
+ logger.error('instance is required for prefetch!');
26
+ return;
24
27
  }
25
28
  const matchedRemoteInfo = helpers.utils.matchRemoteWithNameAndExpose(
26
29
  instance.options.remotes,
27
30
  id,
28
31
  );
29
32
  if (!matchedRemoteInfo) {
30
- throw new Error(`Can not found '${id}' in instance.options.remotes!`);
33
+ logger.error(`Can not found '${id}' in instance.options.remotes!`);
34
+ return;
31
35
  }
32
36
  const { remote, expose } = matchedRemoteInfo;
33
37
  const { remoteSnapshot, globalSnapshot } =
@@ -10,7 +10,7 @@ import {
10
10
  } from '../lazy';
11
11
  import type { CreateLazyComponentOptions, PrefetchOptions } from '../lazy';
12
12
 
13
- declare module '@module-federation/runtime' {
13
+ declare module '@module-federation/runtime-core' {
14
14
  interface FederationHost {
15
15
  createLazyComponent<T, E extends keyof T>(
16
16
  options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>,
@@ -49,16 +49,6 @@ export function lazyLoadComponentPlugin(): FederationRuntimePlugin {
49
49
  });
50
50
  };
51
51
 
52
- instance.wrapNoSSR = (fn) => {
53
- return (options) => {
54
- return fn({
55
- instance,
56
- noSSR: true,
57
- ...options,
58
- });
59
- };
60
- };
61
-
62
52
  instance.collectSSRAssets = (options) => {
63
53
  return collectSSRAssets({
64
54
  instance,