@module-federation/bridge-react 2.9.1 → 2.9.2

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/base.cjs.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const createHelpers = require("./createHelpers-D6thyyLv.js");
4
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DSURjnZ0.js");
5
- const lazyUtils = require("./utils-5dGErM3C.js");
4
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-CvxnfJOg.js");
5
+ const lazyUtils = require("./utils-D8Q9rUjs.js");
6
6
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
7
- const prefetch = require("./prefetch-Bxf6DSx_.js");
7
+ const prefetch = require("./prefetch-CoGdAWJ5.js");
8
8
  const createRemoteAppComponent = createHelpers.createRemoteAppComponentFactory(createHelpers.RemoteAppWrapper);
9
9
  const createRemoteComponent = createHelpers.createDeprecatedRemoteComponentFactory(
10
10
  createRemoteAppComponent
package/dist/base.es.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory, R as RemoteAppWrapper } from "./createHelpers-D3Sg5lKp.mjs";
2
2
  import { b } from "./createHelpers-D3Sg5lKp.mjs";
3
- import { a, c, b as b2, l } from "./lazy-load-component-plugin-NZphPG7_.mjs";
4
- import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-BBP3hEeV.mjs";
3
+ import { a, c, b as b2, l } from "./lazy-load-component-plugin-7YolNNMz.mjs";
4
+ import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-qyCrhZb7.mjs";
5
5
  import { callDataFetch } from "./data-fetch-utils.es.js";
6
- import { p } from "./prefetch-TKq_EK_q.mjs";
6
+ import { p } from "./prefetch-BLNg7m1Y.mjs";
7
7
  const createRemoteAppComponent = createRemoteAppComponentFactory(RemoteAppWrapper);
8
8
  const createRemoteComponent = createDeprecatedRemoteComponentFactory(
9
9
  createRemoteAppComponent
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const lazyUtils = require("./utils-5dGErM3C.js");
2
+ const lazyUtils = require("./utils-D8Q9rUjs.js");
3
3
  const logger = require("./logger-Dxblx6P-.js");
4
4
  function wrapSetTimeout(targetPromise, delay = 2e4, id) {
5
5
  if (targetPromise && typeof targetPromise.then === "function") {
@@ -1,4 +1,4 @@
1
- import { D as DATA_FETCH_QUERY, l as logger, e as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, h as fetchData, j as loadDataFetchModule } from "./utils-BBP3hEeV.mjs";
1
+ import { D as DATA_FETCH_QUERY, l as logger, e as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, h as fetchData, j as loadDataFetchModule } from "./utils-qyCrhZb7.mjs";
2
2
  import { M as MANIFEST_EXT, S as SEPARATOR } from "./logger-DwWkXsWl.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
- const lazyUtils = require("./utils-5dGErM3C.js");
4
- const prefetch = require("./prefetch-Bxf6DSx_.js");
3
+ const lazyUtils = require("./utils-D8Q9rUjs.js");
4
+ const prefetch = require("./prefetch-CoGdAWJ5.js");
5
5
  async function callDataFetch() {
6
6
  const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
7
7
  if (dataFetch) {
@@ -1,7 +1,7 @@
1
- import { y as DATA_FETCH_FUNCTION } from "./utils-BBP3hEeV.mjs";
2
- import { C, a, c, b, d, g, r } from "./utils-BBP3hEeV.mjs";
3
- import { d as dataFetchFunction } from "./prefetch-TKq_EK_q.mjs";
4
- import { i, p } from "./prefetch-TKq_EK_q.mjs";
1
+ import { y as DATA_FETCH_FUNCTION } from "./utils-qyCrhZb7.mjs";
2
+ import { C, a, c, b, d, g, r } from "./utils-qyCrhZb7.mjs";
3
+ import { d as dataFetchFunction } from "./prefetch-BLNg7m1Y.mjs";
4
+ import { i, p } from "./prefetch-BLNg7m1Y.mjs";
5
5
  async function callDataFetch() {
6
6
  const dataFetch = globalThis[DATA_FETCH_FUNCTION];
7
7
  if (dataFetch) {
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DSURjnZ0.js");
4
- const lazyUtils = require("./utils-5dGErM3C.js");
3
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-CvxnfJOg.js");
4
+ const lazyUtils = require("./utils-D8Q9rUjs.js");
5
5
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
6
- const prefetch = require("./prefetch-Bxf6DSx_.js");
6
+ const prefetch = require("./prefetch-CoGdAWJ5.js");
7
7
  exports.autoFetchDataPlugin = lazyLoadComponentPlugin.autoFetchData;
8
8
  exports.collectSSRAssets = lazyLoadComponentPlugin.collectSSRAssets;
9
9
  exports.createLazyComponent = lazyLoadComponentPlugin.createLazyComponent;
@@ -1,7 +1,7 @@
1
- import { a, c, b, l } from "./lazy-load-component-plugin-NZphPG7_.mjs";
2
- import { C, a as a2, E, c as c2, b as b2, d, f, g, r, s } from "./utils-BBP3hEeV.mjs";
1
+ import { a, c, b, l } from "./lazy-load-component-plugin-7YolNNMz.mjs";
2
+ import { C, a as a2, E, c as c2, b as b2, d, f, g, r, s } from "./utils-qyCrhZb7.mjs";
3
3
  import { callDataFetch } from "./data-fetch-utils.es.js";
4
- import { p } from "./prefetch-TKq_EK_q.mjs";
4
+ import { p } from "./prefetch-BLNg7m1Y.mjs";
5
5
  export {
6
6
  C as CacheSize,
7
7
  a2 as CacheTime,
package/dist/index.cjs.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const createHelpers = require("./createHelpers-D6thyyLv.js");
4
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DSURjnZ0.js");
5
- const lazyUtils = require("./utils-5dGErM3C.js");
4
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-CvxnfJOg.js");
5
+ const lazyUtils = require("./utils-D8Q9rUjs.js");
6
6
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
7
7
  const React = require("react");
8
8
  const ReactRouterDOM = require("react-router-dom");
9
9
  const index = require("./index-DbjGCKOr.js");
10
10
  const plugin = require("./plugin.cjs.js");
11
- const prefetch = require("./prefetch-Bxf6DSx_.js");
11
+ const prefetch = require("./prefetch-CoGdAWJ5.js");
12
12
  function _interopNamespaceDefault(e2) {
13
13
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
14
14
  if (e2) {
package/dist/index.es.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from "./createHelpers-D3Sg5lKp.mjs";
2
2
  import { b } from "./createHelpers-D3Sg5lKp.mjs";
3
- import { a, c, b as b2, l } from "./lazy-load-component-plugin-NZphPG7_.mjs";
4
- import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-BBP3hEeV.mjs";
3
+ import { a, c, b as b2, l } from "./lazy-load-component-plugin-7YolNNMz.mjs";
4
+ import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-qyCrhZb7.mjs";
5
5
  import { callDataFetch } from "./data-fetch-utils.es.js";
6
6
  import React__default, { forwardRef, useContext, useState, useEffect } from "react";
7
7
  import * as ReactRouterDOM from "react-router-dom";
8
8
  import { p as pathJoin, L as LoggerInstance } from "./index-Bs2NxD2z.mjs";
9
9
  import { federationRuntime } from "./plugin.es.js";
10
- import { p } from "./prefetch-TKq_EK_q.mjs";
10
+ import { p } from "./prefetch-BLNg7m1Y.mjs";
11
11
  function e() {
12
12
  const t = new PopStateEvent("popstate", { state: window.history.state });
13
13
  window.dispatchEvent(t);
@@ -17,6 +17,7 @@ export declare function getDataFetchMap(): MF_DATA_FETCH_MAP;
17
17
  export declare function getDataFetchCache(): MF_DATA_FETCH_CACHE;
18
18
  export declare const flushDataFetch: () => void;
19
19
  export declare function setDataFetchItemLoadedStatus(id: string): void;
20
+ export declare function resetDataFetchResult(id: string): void;
20
21
  export declare const wrapDataFetchId: (id?: string) => string;
21
22
  export declare const getDataFetchIdWithErrorMsgs: (errMsgs: string) => string | undefined;
22
23
  export declare function fetchData(id: string, params: DataFetchParams, remoteInfo?: NoSSRRemoteInfo): Promise<unknown | undefined>;
@@ -1,5 +1,5 @@
1
- import { i as injectDataFetch, p as prefetch } from "./prefetch-TKq_EK_q.mjs";
2
- import { i as initDataFetchMap, k as isDataLoaderExpose, m as getDataFetchInfo, n as getDataFetchMapKey, l as logger, o as getDataFetchItem, p as DATA_FETCH_CLIENT_SUFFIX, q as MF_DATA_FETCH_TYPE, t as isCSROnly, M as MF_DATA_FETCH_STATUS, j as loadDataFetchModule, e as getDataFetchMap, u as isServerEnv, v as getDataFetchIdWithErrorMsgs, w as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, x as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, y as DATA_FETCH_FUNCTION, z as getLoadedRemoteInfos, h as fetchData$1, A as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-BBP3hEeV.mjs";
1
+ import { i as injectDataFetch, p as prefetch } from "./prefetch-BLNg7m1Y.mjs";
2
+ import { i as initDataFetchMap, k as isDataLoaderExpose, m as getDataFetchInfo, n as getDataFetchMapKey, l as logger, o as getDataFetchItem, p as DATA_FETCH_CLIENT_SUFFIX, q as MF_DATA_FETCH_TYPE, t as isCSROnly, M as MF_DATA_FETCH_STATUS, j as loadDataFetchModule, e as getDataFetchMap, u as isServerEnv, v as getDataFetchIdWithErrorMsgs, w as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, x as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, y as DATA_FETCH_FUNCTION, z as getLoadedRemoteInfos, h as fetchData$1, A as setDataFetchItemLoadedStatus, B as resetDataFetchResult, F as FS_HREF } from "./utils-qyCrhZb7.mjs";
3
3
  import React__default, { useRef, useState, useEffect, Suspense } from "react";
4
4
  const autoFetchData = () => {
5
5
  initDataFetchMap();
@@ -455,14 +455,23 @@ function createLazyComponent(options) {
455
455
  throw new Error("instance is required for createLazyComponent!");
456
456
  }
457
457
  const exportName = (options == null ? void 0 : options.export) || "default";
458
- const callLoader = async () => {
459
- logger.debug("callLoader start", Date.now());
460
- const m = await options.loader();
461
- logger.debug("callLoader end", Date.now());
462
- if (!m) {
463
- throw new Error("load remote failed");
458
+ let loaderPromise;
459
+ const callLoader = () => {
460
+ if (!loaderPromise) {
461
+ logger.debug("callLoader start", Date.now());
462
+ loaderPromise = (async () => {
463
+ const m = await options.loader();
464
+ logger.debug("callLoader end", Date.now());
465
+ if (!m) {
466
+ throw new Error("load remote failed");
467
+ }
468
+ return m;
469
+ })().catch((error) => {
470
+ loaderPromise = void 0;
471
+ throw error;
472
+ });
464
473
  }
465
- return m;
474
+ return loaderPromise;
466
475
  };
467
476
  const getData = async (noSSR) => {
468
477
  let loadedRemoteInfo;
@@ -512,10 +521,16 @@ function createLazyComponent(options) {
512
521
  const errMsg = `${DATA_FETCH_ERROR_PREFIX}${wrapDataFetchId(dataFetchMapKey)}${err}`;
513
522
  logger.debug(errMsg);
514
523
  throw new Error(errMsg);
524
+ } finally {
525
+ if (noSSR && dataFetchMapKey) {
526
+ resetDataFetchResult(dataFetchMapKey);
527
+ }
515
528
  }
516
529
  };
517
- const LazyComponent = React__default.lazy(async () => {
518
- const m = await callLoader();
530
+ const getNoSSRData = () => getData(true).catch((error) => {
531
+ throw error instanceof Error ? error.message : error;
532
+ });
533
+ const createLoadedComponent = (m) => {
519
534
  const moduleId = m && m[Symbol.for("mf_module_id")];
520
535
  const loadedRemoteInfo = getLoadedRemoteInfos(moduleId, instance);
521
536
  loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.snapshot;
@@ -541,20 +556,18 @@ function createLazyComponent(options) {
541
556
  ];
542
557
  const Com = m[exportName];
543
558
  if (exportName in m && typeof Com === "function") {
544
- return {
545
- default: (props) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, globalThis.FEDERATION_SSR && dataFetchMapKey && /* @__PURE__ */ React__default.createElement(
546
- "script",
547
- {
548
- suppressHydrationWarning: true,
549
- dangerouslySetInnerHTML: {
550
- __html: String.raw`
559
+ return (props) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, globalThis.FEDERATION_SSR && dataFetchMapKey && /* @__PURE__ */ React__default.createElement(
560
+ "script",
561
+ {
562
+ suppressHydrationWarning: true,
563
+ dangerouslySetInnerHTML: {
564
+ __html: String.raw`
551
565
  globalThis['${DATA_FETCH_FUNCTION}'] = globalThis['${DATA_FETCH_FUNCTION}'] || [];
552
566
  globalThis['${DATA_FETCH_FUNCTION}'].push(['${dataFetchMapKey}',${JSON.stringify(props.mfData)}]);
553
567
  `
554
- }
555
568
  }
556
- ), globalThis.FEDERATION_SSR && assets, /* @__PURE__ */ React__default.createElement(Com, { ...props }))
557
- };
569
+ }
570
+ ), globalThis.FEDERATION_SSR && assets, /* @__PURE__ */ React__default.createElement(Com, { ...props }));
558
571
  } else {
559
572
  throw Error(
560
573
  `Make sure that ${moduleId} has the correct export when export is ${String(
@@ -562,6 +575,12 @@ function createLazyComponent(options) {
562
575
  )}`
563
576
  );
564
577
  }
578
+ };
579
+ const LazyComponent = React__default.lazy(async () => {
580
+ const m = await callLoader();
581
+ return {
582
+ default: createLoadedComponent(m)
583
+ };
565
584
  });
566
585
  return (props) => {
567
586
  const { key, ...args } = props;
@@ -577,40 +596,46 @@ function createLazyComponent(options) {
577
596
  (data) => /* @__PURE__ */ React__default.createElement(LazyComponent, { ...args, mfData: data })
578
597
  );
579
598
  } else {
580
- const [data, setData] = useState(null);
581
- const [loading, setLoading] = useState(true);
582
- const [error, setError] = useState(null);
599
+ const [state, setState] = useState({ status: "loading" });
600
+ const loadPromiseRef = useRef();
583
601
  useEffect(() => {
584
602
  let isMounted = true;
585
- const fetchDataAsync = async () => {
586
- try {
587
- setLoading(true);
588
- const result = await getData(options.noSSR);
603
+ loadPromiseRef.current ?? (loadPromiseRef.current = (async () => {
604
+ const data = await getNoSSRData();
605
+ const m = await callLoader();
606
+ const Component = createLoadedComponent(m);
607
+ return { status: "loaded", Component, data };
608
+ })());
609
+ loadPromiseRef.current.then(
610
+ (loadedState) => {
589
611
  if (isMounted) {
590
- setData(result);
612
+ setState(loadedState);
591
613
  }
592
- } catch (e) {
614
+ },
615
+ (error) => {
593
616
  if (isMounted) {
594
- setError(transformError(e));
595
- }
596
- } finally {
597
- if (isMounted) {
598
- setLoading(false);
617
+ setState({
618
+ status: "error",
619
+ error: transformError(error)
620
+ });
599
621
  }
600
622
  }
601
- };
602
- fetchDataAsync();
623
+ );
603
624
  return () => {
604
625
  isMounted = false;
605
626
  };
606
627
  }, []);
607
- if (loading) {
628
+ if (typeof window === "undefined") {
608
629
  return /* @__PURE__ */ React__default.createElement(DelayedLoading, { delayLoading: options.delayLoading }, options.loading);
609
630
  }
610
- if (error) {
611
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, typeof options.fallback === "function" ? options.fallback(error) : options.fallback);
631
+ if (state.status === "error") {
632
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, typeof options.fallback === "function" ? options.fallback(state.error) : options.fallback);
633
+ }
634
+ if (state.status === "loading") {
635
+ return /* @__PURE__ */ React__default.createElement(DelayedLoading, { delayLoading: options.delayLoading }, options.loading);
612
636
  }
613
- return /* @__PURE__ */ React__default.createElement(LazyComponent, { ...args, mfData: data });
637
+ const LoadedComponent = state.Component;
638
+ return /* @__PURE__ */ React__default.createElement(LoadedComponent, { ...args, mfData: state.data });
614
639
  }
615
640
  };
616
641
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const prefetch = require("./prefetch-Bxf6DSx_.js");
3
- const lazyUtils = require("./utils-5dGErM3C.js");
2
+ const prefetch = require("./prefetch-CoGdAWJ5.js");
3
+ const lazyUtils = require("./utils-D8Q9rUjs.js");
4
4
  const React = require("react");
5
5
  const autoFetchData = () => {
6
6
  lazyUtils.initDataFetchMap();
@@ -456,14 +456,23 @@ function createLazyComponent(options) {
456
456
  throw new Error("instance is required for createLazyComponent!");
457
457
  }
458
458
  const exportName = (options == null ? void 0 : options.export) || "default";
459
- const callLoader = async () => {
460
- lazyUtils.logger.debug("callLoader start", Date.now());
461
- const m = await options.loader();
462
- lazyUtils.logger.debug("callLoader end", Date.now());
463
- if (!m) {
464
- throw new Error("load remote failed");
459
+ let loaderPromise;
460
+ const callLoader = () => {
461
+ if (!loaderPromise) {
462
+ lazyUtils.logger.debug("callLoader start", Date.now());
463
+ loaderPromise = (async () => {
464
+ const m = await options.loader();
465
+ lazyUtils.logger.debug("callLoader end", Date.now());
466
+ if (!m) {
467
+ throw new Error("load remote failed");
468
+ }
469
+ return m;
470
+ })().catch((error) => {
471
+ loaderPromise = void 0;
472
+ throw error;
473
+ });
465
474
  }
466
- return m;
475
+ return loaderPromise;
467
476
  };
468
477
  const getData = async (noSSR) => {
469
478
  let loadedRemoteInfo;
@@ -513,10 +522,16 @@ function createLazyComponent(options) {
513
522
  const errMsg = `${lazyUtils.DATA_FETCH_ERROR_PREFIX}${lazyUtils.wrapDataFetchId(dataFetchMapKey)}${err}`;
514
523
  lazyUtils.logger.debug(errMsg);
515
524
  throw new Error(errMsg);
525
+ } finally {
526
+ if (noSSR && dataFetchMapKey) {
527
+ lazyUtils.resetDataFetchResult(dataFetchMapKey);
528
+ }
516
529
  }
517
530
  };
518
- const LazyComponent = React.lazy(async () => {
519
- const m = await callLoader();
531
+ const getNoSSRData = () => getData(true).catch((error) => {
532
+ throw error instanceof Error ? error.message : error;
533
+ });
534
+ const createLoadedComponent = (m) => {
520
535
  const moduleId = m && m[Symbol.for("mf_module_id")];
521
536
  const loadedRemoteInfo = lazyUtils.getLoadedRemoteInfos(moduleId, instance);
522
537
  loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.snapshot;
@@ -542,20 +557,18 @@ function createLazyComponent(options) {
542
557
  ];
543
558
  const Com = m[exportName];
544
559
  if (exportName in m && typeof Com === "function") {
545
- return {
546
- default: (props) => /* @__PURE__ */ React.createElement(React.Fragment, null, globalThis.FEDERATION_SSR && dataFetchMapKey && /* @__PURE__ */ React.createElement(
547
- "script",
548
- {
549
- suppressHydrationWarning: true,
550
- dangerouslySetInnerHTML: {
551
- __html: String.raw`
560
+ return (props) => /* @__PURE__ */ React.createElement(React.Fragment, null, globalThis.FEDERATION_SSR && dataFetchMapKey && /* @__PURE__ */ React.createElement(
561
+ "script",
562
+ {
563
+ suppressHydrationWarning: true,
564
+ dangerouslySetInnerHTML: {
565
+ __html: String.raw`
552
566
  globalThis['${lazyUtils.DATA_FETCH_FUNCTION}'] = globalThis['${lazyUtils.DATA_FETCH_FUNCTION}'] || [];
553
567
  globalThis['${lazyUtils.DATA_FETCH_FUNCTION}'].push(['${dataFetchMapKey}',${JSON.stringify(props.mfData)}]);
554
568
  `
555
- }
556
569
  }
557
- ), globalThis.FEDERATION_SSR && assets, /* @__PURE__ */ React.createElement(Com, { ...props }))
558
- };
570
+ }
571
+ ), globalThis.FEDERATION_SSR && assets, /* @__PURE__ */ React.createElement(Com, { ...props }));
559
572
  } else {
560
573
  throw Error(
561
574
  `Make sure that ${moduleId} has the correct export when export is ${String(
@@ -563,6 +576,12 @@ function createLazyComponent(options) {
563
576
  )}`
564
577
  );
565
578
  }
579
+ };
580
+ const LazyComponent = React.lazy(async () => {
581
+ const m = await callLoader();
582
+ return {
583
+ default: createLoadedComponent(m)
584
+ };
566
585
  });
567
586
  return (props) => {
568
587
  const { key, ...args } = props;
@@ -578,40 +597,46 @@ function createLazyComponent(options) {
578
597
  (data) => /* @__PURE__ */ React.createElement(LazyComponent, { ...args, mfData: data })
579
598
  );
580
599
  } else {
581
- const [data, setData] = React.useState(null);
582
- const [loading, setLoading] = React.useState(true);
583
- const [error, setError] = React.useState(null);
600
+ const [state, setState] = React.useState({ status: "loading" });
601
+ const loadPromiseRef = React.useRef();
584
602
  React.useEffect(() => {
585
603
  let isMounted = true;
586
- const fetchDataAsync = async () => {
587
- try {
588
- setLoading(true);
589
- const result = await getData(options.noSSR);
604
+ loadPromiseRef.current ?? (loadPromiseRef.current = (async () => {
605
+ const data = await getNoSSRData();
606
+ const m = await callLoader();
607
+ const Component = createLoadedComponent(m);
608
+ return { status: "loaded", Component, data };
609
+ })());
610
+ loadPromiseRef.current.then(
611
+ (loadedState) => {
590
612
  if (isMounted) {
591
- setData(result);
613
+ setState(loadedState);
592
614
  }
593
- } catch (e) {
615
+ },
616
+ (error) => {
594
617
  if (isMounted) {
595
- setError(transformError(e));
596
- }
597
- } finally {
598
- if (isMounted) {
599
- setLoading(false);
618
+ setState({
619
+ status: "error",
620
+ error: transformError(error)
621
+ });
600
622
  }
601
623
  }
602
- };
603
- fetchDataAsync();
624
+ );
604
625
  return () => {
605
626
  isMounted = false;
606
627
  };
607
628
  }, []);
608
- if (loading) {
629
+ if (typeof window === "undefined") {
609
630
  return /* @__PURE__ */ React.createElement(DelayedLoading, { delayLoading: options.delayLoading }, options.loading);
610
631
  }
611
- if (error) {
612
- return /* @__PURE__ */ React.createElement(React.Fragment, null, typeof options.fallback === "function" ? options.fallback(error) : options.fallback);
632
+ if (state.status === "error") {
633
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, typeof options.fallback === "function" ? options.fallback(state.error) : options.fallback);
634
+ }
635
+ if (state.status === "loading") {
636
+ return /* @__PURE__ */ React.createElement(DelayedLoading, { delayLoading: options.delayLoading }, options.loading);
613
637
  }
614
- return /* @__PURE__ */ React.createElement(LazyComponent, { ...args, mfData: data });
638
+ const LoadedComponent = state.Component;
639
+ return /* @__PURE__ */ React.createElement(LoadedComponent, { ...args, mfData: state.data });
615
640
  }
616
641
  };
617
642
  }
@@ -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-DSURjnZ0.js");
4
- require("./prefetch-Bxf6DSx_.js");
3
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-CvxnfJOg.js");
4
+ require("./prefetch-CoGdAWJ5.js");
5
5
  exports.default = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
6
6
  exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
@@ -1,5 +1,5 @@
1
- import { l, l as l2 } from "./lazy-load-component-plugin-NZphPG7_.mjs";
2
- import "./prefetch-TKq_EK_q.mjs";
1
+ import { l, l as l2 } from "./lazy-load-component-plugin-7YolNNMz.mjs";
2
+ import "./prefetch-BLNg7m1Y.mjs";
3
3
  export {
4
4
  l as default,
5
5
  l2 as lazyLoadComponentPlugin
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("./logger-Dxblx6P-.js");
4
- const lazyUtils = require("./utils-5dGErM3C.js");
4
+ const lazyUtils = require("./utils-D8Q9rUjs.js");
5
5
  exports.callAllDowngrade = lazyUtils.callAllDowngrade;
6
6
  exports.callDowngrade = lazyUtils.callDowngrade;
7
7
  exports.fetchData = lazyUtils.fetchData;
@@ -19,6 +19,7 @@ exports.isCSROnly = lazyUtils.isCSROnly;
19
19
  exports.isDataLoaderExpose = lazyUtils.isDataLoaderExpose;
20
20
  exports.isServerEnv = lazyUtils.isServerEnv;
21
21
  exports.loadDataFetchModule = lazyUtils.loadDataFetchModule;
22
+ exports.resetDataFetchResult = lazyUtils.resetDataFetchResult;
22
23
  exports.setDataFetchItemLoadedStatus = lazyUtils.setDataFetchItemLoadedStatus;
23
24
  exports.setSSREnv = lazyUtils.setSSREnv;
24
25
  exports.wrapDataFetchId = lazyUtils.wrapDataFetchId;
@@ -1,23 +1,24 @@
1
1
  import "./logger-DwWkXsWl.mjs";
2
- import { H, I, h, f, O, v, m, o, e, n, J, z, i, t, k, u, j, A, s, x } from "./utils-BBP3hEeV.mjs";
2
+ import { I, J, h, f, P, v, m, o, e, n, K, z, i, t, k, u, j, B, A, s, x } from "./utils-qyCrhZb7.mjs";
3
3
  export {
4
- H as callAllDowngrade,
5
- I as callDowngrade,
4
+ I as callAllDowngrade,
5
+ J as callDowngrade,
6
6
  h as fetchData,
7
7
  f as flushDataFetch,
8
- O as getDataFetchCache,
8
+ P as getDataFetchCache,
9
9
  v as getDataFetchIdWithErrorMsgs,
10
10
  m as getDataFetchInfo,
11
11
  o as getDataFetchItem,
12
12
  e as getDataFetchMap,
13
13
  n as getDataFetchMapKey,
14
- J as getDowngradeTag,
14
+ K as getDowngradeTag,
15
15
  z as getLoadedRemoteInfos,
16
16
  i as initDataFetchMap,
17
17
  t as isCSROnly,
18
18
  k as isDataLoaderExpose,
19
19
  u as isServerEnv,
20
20
  j as loadDataFetchModule,
21
+ B as resetDataFetchResult,
21
22
  A as setDataFetchItemLoadedStatus,
22
23
  s as setSSREnv,
23
24
  x as wrapDataFetchId
@@ -1,4 +1,4 @@
1
- import { B as warn, y as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger, e as getDataFetchMap, i as initDataFetchMap, o as getDataFetchItem, M as MF_DATA_FETCH_STATUS, q as MF_DATA_FETCH_TYPE, G as DOWNGRADE_KEY, H as callAllDowngrade, I as callDowngrade, J as getDowngradeTag, K as composeKeyWithSeparator, N as safeToString, m as getDataFetchInfo, n as getDataFetchMapKey } from "./utils-BBP3hEeV.mjs";
1
+ import { G as warn, y as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger, e as getDataFetchMap, i as initDataFetchMap, o as getDataFetchItem, M as MF_DATA_FETCH_STATUS, q as MF_DATA_FETCH_TYPE, H as DOWNGRADE_KEY, I as callAllDowngrade, J as callDowngrade, K as getDowngradeTag, N as composeKeyWithSeparator, O as safeToString, m as getDataFetchInfo, n as getDataFetchMapKey } from "./utils-qyCrhZb7.mjs";
2
2
  import { i as isBrowserEnvValue } from "./logger-DwWkXsWl.mjs";
3
3
  async function safeWrapper(callback, disableWarn) {
4
4
  try {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const lazyUtils = require("./utils-5dGErM3C.js");
2
+ const lazyUtils = require("./utils-D8Q9rUjs.js");
3
3
  const logger = require("./logger-Dxblx6P-.js");
4
4
  async function safeWrapper(callback, disableWarn) {
5
5
  try {
@@ -336,6 +336,14 @@ function setDataFetchItemLoadedStatus(id) {
336
336
  }
337
337
  dataFetchItem[2] = MF_DATA_FETCH_STATUS.LOADED;
338
338
  }
339
+ function resetDataFetchResult(id) {
340
+ const dataFetchItem = getDataFetchItem(id);
341
+ if (!dataFetchItem) {
342
+ return;
343
+ }
344
+ dataFetchItem[1] = void 0;
345
+ dataFetchItem[2] = MF_DATA_FETCH_STATUS.AWAIT;
346
+ }
339
347
  const wrapDataFetchId = (id) => {
340
348
  return `${WRAP_DATA_FETCH_ID_IDENTIFIER}${id}${WRAP_DATA_FETCH_ID_IDENTIFIER}`;
341
349
  };
@@ -580,6 +588,7 @@ exports.isDataLoaderExpose = isDataLoaderExpose;
580
588
  exports.isServerEnv = isServerEnv;
581
589
  exports.loadDataFetchModule = loadDataFetchModule;
582
590
  exports.logger = logger;
591
+ exports.resetDataFetchResult = resetDataFetchResult;
583
592
  exports.revalidateTag = revalidateTag;
584
593
  exports.safeToString = safeToString;
585
594
  exports.setDataFetchItemLoadedStatus = setDataFetchItemLoadedStatus;
@@ -335,6 +335,14 @@ function setDataFetchItemLoadedStatus(id) {
335
335
  }
336
336
  dataFetchItem[2] = MF_DATA_FETCH_STATUS.LOADED;
337
337
  }
338
+ function resetDataFetchResult(id) {
339
+ const dataFetchItem = getDataFetchItem(id);
340
+ if (!dataFetchItem) {
341
+ return;
342
+ }
343
+ dataFetchItem[1] = void 0;
344
+ dataFetchItem[2] = MF_DATA_FETCH_STATUS.AWAIT;
345
+ }
338
346
  const wrapDataFetchId = (id) => {
339
347
  return `${WRAP_DATA_FETCH_ID_IDENTIFIER}${id}${WRAP_DATA_FETCH_ID_IDENTIFIER}`;
340
348
  };
@@ -546,20 +554,21 @@ function getLoadedRemoteInfos(id, instance) {
546
554
  }
547
555
  export {
548
556
  setDataFetchItemLoadedStatus as A,
549
- warn as B,
557
+ resetDataFetchResult as B,
550
558
  CacheSize as C,
551
559
  DATA_FETCH_QUERY as D,
552
560
  ERROR_TYPE as E,
553
561
  FS_HREF as F,
554
- DOWNGRADE_KEY as G,
555
- callAllDowngrade as H,
556
- callDowngrade as I,
557
- getDowngradeTag as J,
558
- composeKeyWithSeparator as K,
562
+ warn as G,
563
+ DOWNGRADE_KEY as H,
564
+ callAllDowngrade as I,
565
+ callDowngrade as J,
566
+ getDowngradeTag as K,
559
567
  LOAD_REMOTE_ERROR_PREFIX as L,
560
568
  MF_DATA_FETCH_STATUS as M,
561
- safeToString as N,
562
- getDataFetchCache as O,
569
+ composeKeyWithSeparator as N,
570
+ safeToString as O,
571
+ getDataFetchCache as P,
563
572
  CacheTime as a,
564
573
  clearStore as b,
565
574
  cache as c,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-react",
3
- "version": "2.9.1",
3
+ "version": "2.9.2",
4
4
  "sideEffects": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -147,7 +147,7 @@
147
147
  }
148
148
  },
149
149
  "dependencies": {
150
- "@module-federation/sdk": "2.9.1"
150
+ "@module-federation/sdk": "2.9.2"
151
151
  },
152
152
  "peerDependencies": {
153
153
  "react": ">=16.9.0",
@@ -178,10 +178,10 @@
178
178
  "react-router": "7.18.2",
179
179
  "typescript": "7.0.2",
180
180
  "vite": "^5.4.21",
181
- "hono": "4.13.1",
182
- "@module-federation/runtime": "2.9.1",
183
- "@module-federation/runtime-core": "2.9.1",
184
- "@module-federation/bridge-shared": "2.9.1"
181
+ "hono": "4.13.5",
182
+ "@module-federation/bridge-shared": "2.9.2",
183
+ "@module-federation/runtime": "2.9.2",
184
+ "@module-federation/runtime-core": "2.9.2"
185
185
  },
186
186
  "scripts": {
187
187
  "dev": "vite",