@module-federation/bridge-react 2.0.1 → 2.2.0

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.
Files changed (48) hide show
  1. package/.turbo/turbo-build.log +85 -0
  2. package/CHANGELOG.md +22 -3
  3. package/dist/base.cjs.js +4 -4
  4. package/dist/base.es.js +5 -5
  5. package/dist/{bridge-base-BVX0EbsV.mjs → bridge-base-EnVXD4Hr.mjs} +1 -1
  6. package/dist/{bridge-base-vSCG9ebE.js → bridge-base-IlvdqYIj.js} +1 -1
  7. package/dist/{createHelpers-12yCVhCu.js → createHelpers-9B0ttrN_.js} +2 -2
  8. package/dist/{createHelpers-CGhHhtAd.mjs → createHelpers-D77sECmY.mjs} +2 -2
  9. package/dist/data-fetch-server-middleware.cjs.js +4 -4
  10. package/dist/data-fetch-server-middleware.es.js +2 -2
  11. package/dist/data-fetch-utils.cjs.js +2 -2
  12. package/dist/data-fetch-utils.es.js +4 -4
  13. package/dist/{index-DtXhorFI.mjs → index-Bs2NxD2z.mjs} +1 -1
  14. package/dist/{index-DhFNWacm.js → index-DbjGCKOr.js} +2 -2
  15. package/dist/index.cjs.js +5 -5
  16. package/dist/index.es.js +6 -6
  17. package/dist/{lazy-load-component-plugin-C7jasFos.js → lazy-load-component-plugin-0-2dETvt.js} +2 -2
  18. package/dist/{lazy-load-component-plugin-CrSLH5YP.mjs → lazy-load-component-plugin-ChXiUL6x.mjs} +2 -2
  19. package/dist/lazy-load-component-plugin.cjs.js +2 -2
  20. package/dist/lazy-load-component-plugin.es.js +2 -2
  21. package/dist/lazy-utils.cjs.js +2 -2
  22. package/dist/lazy-utils.es.js +7 -7
  23. package/dist/logger-DwWkXsWl.mjs +139 -0
  24. package/dist/logger-Dxblx6P-.js +138 -0
  25. package/dist/prefetch-BIuiJePI.js +884 -0
  26. package/dist/prefetch-DLfc6h__.mjs +885 -0
  27. package/dist/router-v5.cjs.js +1 -1
  28. package/dist/router-v5.es.js +1 -1
  29. package/dist/router-v6.cjs.js +1 -1
  30. package/dist/router-v6.es.js +1 -1
  31. package/dist/router-v7.cjs.js +1 -1
  32. package/dist/router-v7.es.js +1 -1
  33. package/dist/router.cjs.js +1 -1
  34. package/dist/router.es.js +1 -1
  35. package/dist/{utils-TDonIHDD.js → utils-CFTy4LVE.js} +18 -4
  36. package/dist/{utils-DpoLOH_j.mjs → utils-D4k5eixv.mjs} +22 -8
  37. package/dist/v18.cjs.js +1 -1
  38. package/dist/v18.es.js +1 -1
  39. package/dist/v19.cjs.js +1 -1
  40. package/dist/v19.es.js +1 -1
  41. package/package.json +8 -7
  42. package/src/lazy/utils.ts +5 -2
  43. package/vitest.config.ts +2 -2
  44. package/dist/index.esm-BvTtsZnu.mjs +0 -491
  45. package/dist/index.esm-CYiGJfQW.js +0 -490
  46. package/dist/prefetch-CFRpPfZQ.js +0 -632
  47. package/dist/prefetch-DMJyBeIs.mjs +0 -633
  48. package/project.json +0 -23
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const ReactRouterDom$1 = require("react-router-dom/index.js");
5
- const index = require("./index-DhFNWacm.js");
5
+ const index = require("./index-DbjGCKOr.js");
6
6
  const ReactRouterDom = require("react-router-dom/index.js");
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -1,6 +1,6 @@
1
1
  import React__default, { useContext } from "react";
2
2
  import * as ReactRouterDom$1 from "react-router-dom/index.js";
3
- import { R as RouterContext, L as LoggerInstance } from "./index-DtXhorFI.mjs";
3
+ import { R as RouterContext, L as LoggerInstance } from "./index-Bs2NxD2z.mjs";
4
4
  export * from "react-router-dom/index.js";
5
5
  function WraperRouter(props) {
6
6
  const { basename, ...propsRes } = props;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const ReactRouterDom$1 = require("react-router-dom/dist/index.js");
5
- const index = require("./index-DhFNWacm.js");
5
+ const index = require("./index-DbjGCKOr.js");
6
6
  const ReactRouterDom = require("react-router-dom/dist/index.js");
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -1,6 +1,6 @@
1
1
  import React__default, { useContext } from "react";
2
2
  import * as ReactRouterDom$1 from "react-router-dom/dist/index.js";
3
- import { R as RouterContext, L as LoggerInstance } from "./index-DtXhorFI.mjs";
3
+ import { R as RouterContext, L as LoggerInstance } from "./index-Bs2NxD2z.mjs";
4
4
  export * from "react-router-dom/dist/index.js";
5
5
  function WraperRouter(props) {
6
6
  const { basename, ...propsRes } = props;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const ReactRouterDom = require("react-router");
5
- const index = require("./index-DhFNWacm.js");
5
+ const index = require("./index-DbjGCKOr.js");
6
6
  function _interopNamespaceDefault(e) {
7
7
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
8
  if (e) {
@@ -1,7 +1,7 @@
1
1
  import React__default, { useContext } from "react";
2
2
  import * as ReactRouterDom from 'react-router/dist/production/index.js';
3
3
  export * from 'react-router/dist/production/index.js';
4
- import { R as RouterContext, L as LoggerInstance } from "./index-DtXhorFI.mjs";
4
+ import { R as RouterContext, L as LoggerInstance } from "./index-Bs2NxD2z.mjs";
5
5
  function WraperRouter(props) {
6
6
  const { basename, ...propsRes } = props;
7
7
  const routerContextProps = useContext(RouterContext) || {};
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const ReactRouterDom = require("react-router-dom/");
5
- const index = require("./index-DhFNWacm.js");
5
+ const index = require("./index-DbjGCKOr.js");
6
6
  function _interopNamespaceDefault(e) {
7
7
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
8
  if (e) {
package/dist/router.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import React__default, { useContext } from "react";
2
2
  import * as ReactRouterDom from "react-router-dom/";
3
3
  export * from "react-router-dom/";
4
- import { R as RouterContext, L as LoggerInstance } from "./index-DtXhorFI.mjs";
4
+ import { R as RouterContext, L as LoggerInstance } from "./index-Bs2NxD2z.mjs";
5
5
  function WrapperRouter(props) {
6
6
  const { basename, ...propsRes } = props;
7
7
  const routerContextProps = useContext(RouterContext) || {};
@@ -19,7 +19,19 @@ var __privateWrapper = (obj, member, setter, getter) => ({
19
19
  }
20
20
  });
21
21
  var _a, _constructing, _b, _c, _max, _maxSize, _dispose, _disposeAfter, _fetchMethod, _memoMethod, _size, _calculatedSize, _keyMap, _keyList, _valList, _next, _prev, _head, _tail, _free, _disposed, _sizes, _starts, _ttls, _hasDispose, _hasFetchMethod, _hasDisposeAfter, _LRUCache_instances, initializeTTLTracking_fn, _updateItemAge, _statusTTL, _setItemTTL, _isStale, initializeSizeTracking_fn, _removeItemSize, _addItemSize, _requireSize, indexes_fn, rindexes_fn, isValidIndex_fn, evict_fn, backgroundFetch_fn, isBackgroundFetch_fn, connect_fn, moveToTail_fn, delete_fn, clear_fn;
22
- const index_esm = require("./index.esm-CYiGJfQW.js");
22
+ const logger$1 = require("./logger-Dxblx6P-.js");
23
+ const LOG_CATEGORY = "[ Federation Runtime ]";
24
+ const composeKeyWithSeparator = function(...args) {
25
+ if (!args.length) return "";
26
+ return args.reduce((sum, cur) => {
27
+ if (!cur) return sum;
28
+ if (!sum) return cur;
29
+ return `${sum}${logger$1.SEPARATOR}${cur}`;
30
+ }, "");
31
+ };
32
+ const warn = (msg) => {
33
+ console.warn(`${LOG_CATEGORY}: ${msg}`);
34
+ };
23
35
  const PLUGIN_IDENTIFIER = "[ Module Federation React ]";
24
36
  const DOWNGRADE_KEY = "_mfSSRDowngrade";
25
37
  const DATA_FETCH_FUNCTION = "_mfDataFetch";
@@ -47,7 +59,7 @@ const DATA_FETCH_CLIENT_SUFFIX = ".client";
47
59
  const DATA_FETCH_QUERY = "x-mf-data-fetch";
48
60
  const DATA_FETCH_ERROR_PREFIX = "caught the following error during dataFetch: ";
49
61
  const LOAD_REMOTE_ERROR_PREFIX = "caught the following error during loadRemote: ";
50
- const logger = index_esm.createLogger(PLUGIN_IDENTIFIER);
62
+ const logger = logger$1.createLogger(PLUGIN_IDENTIFIER);
51
63
  const perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
52
64
  const warned = /* @__PURE__ */ new Set();
53
65
  const PROCESS = typeof process === "object" && !!process ? process : {};
@@ -1803,7 +1815,7 @@ async function fetchData(id, params, remoteInfo) {
1803
1815
  _id: id
1804
1816
  });
1805
1817
  };
1806
- if (index_esm.isBrowserEnv()) {
1818
+ if (logger$1.isBrowserEnvValue) {
1807
1819
  const dataFetchItem = getDataFetchItem(id);
1808
1820
  if (!dataFetchItem) {
1809
1821
  throw new Error(`dataFetchItem not found, id: ${id}`);
@@ -1839,7 +1851,7 @@ function getDataFetchMapKey(dataFetchInfo, hostInfo) {
1839
1851
  return;
1840
1852
  }
1841
1853
  const { dataFetchKey } = dataFetchInfo;
1842
- return index_esm.composeKeyWithSeparator(dataFetchKey, hostInfo.name, hostInfo.version);
1854
+ return composeKeyWithSeparator(dataFetchKey, hostInfo.name, hostInfo.version);
1843
1855
  }
1844
1856
  async function loadDataFetchModule(instance, id) {
1845
1857
  return instance.loadRemote(id).then((m) => {
@@ -1991,6 +2003,7 @@ exports.cache = cache;
1991
2003
  exports.callAllDowngrade = callAllDowngrade;
1992
2004
  exports.callDowngrade = callDowngrade;
1993
2005
  exports.clearStore = clearStore;
2006
+ exports.composeKeyWithSeparator = composeKeyWithSeparator;
1994
2007
  exports.configureCache = configureCache;
1995
2008
  exports.fetchData = fetchData;
1996
2009
  exports.flushDataFetch = flushDataFetch;
@@ -2012,4 +2025,5 @@ exports.logger = logger;
2012
2025
  exports.revalidateTag = revalidateTag;
2013
2026
  exports.setDataFetchItemLoadedStatus = setDataFetchItemLoadedStatus;
2014
2027
  exports.setSSREnv = setSSREnv;
2028
+ exports.warn = warn;
2015
2029
  exports.wrapDataFetchId = wrapDataFetchId;
@@ -18,7 +18,19 @@ var __privateWrapper = (obj, member, setter, getter) => ({
18
18
  }
19
19
  });
20
20
  var _a, _constructing, _b, _c, _max, _maxSize, _dispose, _disposeAfter, _fetchMethod, _memoMethod, _size, _calculatedSize, _keyMap, _keyList, _valList, _next, _prev, _head, _tail, _free, _disposed, _sizes, _starts, _ttls, _hasDispose, _hasFetchMethod, _hasDisposeAfter, _LRUCache_instances, initializeTTLTracking_fn, _updateItemAge, _statusTTL, _setItemTTL, _isStale, initializeSizeTracking_fn, _removeItemSize, _addItemSize, _requireSize, indexes_fn, rindexes_fn, isValidIndex_fn, evict_fn, backgroundFetch_fn, isBackgroundFetch_fn, connect_fn, moveToTail_fn, delete_fn, clear_fn;
21
- import { c as createLogger, i as isBrowserEnv, d as composeKeyWithSeparator } from "./index.esm-BvTtsZnu.mjs";
21
+ import { S as SEPARATOR, c as createLogger, i as isBrowserEnvValue } from "./logger-DwWkXsWl.mjs";
22
+ const LOG_CATEGORY = "[ Federation Runtime ]";
23
+ const composeKeyWithSeparator = function(...args) {
24
+ if (!args.length) return "";
25
+ return args.reduce((sum, cur) => {
26
+ if (!cur) return sum;
27
+ if (!sum) return cur;
28
+ return `${sum}${SEPARATOR}${cur}`;
29
+ }, "");
30
+ };
31
+ const warn = (msg) => {
32
+ console.warn(`${LOG_CATEGORY}: ${msg}`);
33
+ };
22
34
  const PLUGIN_IDENTIFIER = "[ Module Federation React ]";
23
35
  const DOWNGRADE_KEY = "_mfSSRDowngrade";
24
36
  const DATA_FETCH_FUNCTION = "_mfDataFetch";
@@ -1802,7 +1814,7 @@ async function fetchData(id, params, remoteInfo) {
1802
1814
  _id: id
1803
1815
  });
1804
1816
  };
1805
- if (isBrowserEnv()) {
1817
+ if (isBrowserEnvValue) {
1806
1818
  const dataFetchItem = getDataFetchItem(id);
1807
1819
  if (!dataFetchItem) {
1808
1820
  throw new Error(`dataFetchItem not found, id: ${id}`);
@@ -1975,18 +1987,20 @@ function getLoadedRemoteInfos(id, instance) {
1975
1987
  };
1976
1988
  }
1977
1989
  export {
1978
- DOWNGRADE_KEY as A,
1979
- callAllDowngrade as B,
1990
+ warn as A,
1991
+ DOWNGRADE_KEY as B,
1980
1992
  CacheSize as C,
1981
1993
  DATA_FETCH_QUERY as D,
1982
1994
  ERROR_TYPE as E,
1983
1995
  FS_HREF as F,
1984
- callDowngrade as G,
1985
- getDowngradeTag as H,
1986
- flushDataFetch as I,
1987
- getDataFetchCache as J,
1996
+ callAllDowngrade as G,
1997
+ callDowngrade as H,
1998
+ getDowngradeTag as I,
1999
+ composeKeyWithSeparator as J,
2000
+ flushDataFetch as K,
1988
2001
  LOAD_REMOTE_ERROR_PREFIX as L,
1989
2002
  MF_DATA_FETCH_STATUS as M,
2003
+ getDataFetchCache as N,
1990
2004
  CacheTime as a,
1991
2005
  clearStore as b,
1992
2006
  cache as c,
package/dist/v18.cjs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const client = require("react-dom/client");
4
- const bridgeBase = require("./bridge-base-vSCG9ebE.js");
4
+ const bridgeBase = require("./bridge-base-IlvdqYIj.js");
5
5
  function createReact18Root(container, options) {
6
6
  return client.createRoot(container, options);
7
7
  }
package/dist/v18.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRoot } from "react-dom/client";
2
- import { c as createBaseBridgeComponent } from "./bridge-base-BVX0EbsV.mjs";
2
+ import { c as createBaseBridgeComponent } from "./bridge-base-EnVXD4Hr.mjs";
3
3
  function createReact18Root(container, options) {
4
4
  return createRoot(container, options);
5
5
  }
package/dist/v19.cjs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const client = require("react-dom/client");
4
- const bridgeBase = require("./bridge-base-vSCG9ebE.js");
4
+ const bridgeBase = require("./bridge-base-IlvdqYIj.js");
5
5
  function createReact19Root(container, options) {
6
6
  return client.createRoot(container, options);
7
7
  }
package/dist/v19.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRoot } from "react-dom/client";
2
- import { c as createBaseBridgeComponent } from "./bridge-base-BVX0EbsV.mjs";
2
+ import { c as createBaseBridgeComponent } from "./bridge-base-EnVXD4Hr.mjs";
3
3
  function createReact19Root(container, options) {
4
4
  return createRoot(container, options);
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-react",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "sideEffects": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -129,8 +129,8 @@
129
129
  "dependencies": {
130
130
  "react-error-boundary": "^4.1.2",
131
131
  "lru-cache": "^10.4.3",
132
- "@module-federation/sdk": "2.0.1",
133
- "@module-federation/bridge-shared": "2.0.1"
132
+ "@module-federation/bridge-shared": "2.2.0",
133
+ "@module-federation/sdk": "2.2.0"
134
134
  },
135
135
  "peerDependencies": {
136
136
  "react": ">=16.9.0",
@@ -161,13 +161,14 @@
161
161
  "typescript": "^5.2.2",
162
162
  "vite": "^5.4.21",
163
163
  "vite-plugin-dts": "^4.3.0",
164
- "hono": "4.11.7",
165
- "@module-federation/runtime": "2.0.1",
166
- "@module-federation/runtime-core": "2.0.1"
164
+ "hono": "4.12.7",
165
+ "@module-federation/runtime": "2.2.0",
166
+ "@module-federation/runtime-core": "2.2.0"
167
167
  },
168
168
  "scripts": {
169
169
  "dev": "vite",
170
170
  "build": "vite build",
171
- "preview": "vite preview"
171
+ "preview": "vite preview",
172
+ "test": "pnpm exec jest --config jest.config.ts --passWithNoTests"
172
173
  }
173
174
  }
package/src/lazy/utils.ts CHANGED
@@ -1,4 +1,7 @@
1
- import { isBrowserEnv, composeKeyWithSeparator } from '@module-federation/sdk';
1
+ import {
2
+ isBrowserEnvValue,
3
+ composeKeyWithSeparator,
4
+ } from '@module-federation/sdk';
2
5
  import logger from './logger';
3
6
  import {
4
7
  DOWNGRADE_KEY,
@@ -153,7 +156,7 @@ export async function fetchData(
153
156
  _id: id,
154
157
  });
155
158
  };
156
- if (isBrowserEnv()) {
159
+ if (isBrowserEnvValue) {
157
160
  const dataFetchItem = getDataFetchItem(id);
158
161
  if (!dataFetchItem) {
159
162
  throw new Error(`dataFetchItem not found, id: ${id}`);
package/vitest.config.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineConfig } from 'vitest/config';
2
- import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
2
+ import tsconfigPaths from 'vite-tsconfig-paths';
3
3
  import react from '@vitejs/plugin-react';
4
4
  import path from 'path';
5
5
  export default defineConfig({
@@ -13,7 +13,7 @@ export default defineConfig({
13
13
  resolve: {
14
14
  extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'],
15
15
  },
16
- plugins: [react(), nxViteTsPaths()],
16
+ plugins: [react(), tsconfigPaths()],
17
17
  test: {
18
18
  environment: 'jsdom',
19
19
  include: [