@module-federation/bridge-react 0.0.0-next-20250321090937 → 0.0.0-next-20250323051630

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,31 +1,13 @@
1
1
  # @module-federation/bridge-react
2
2
 
3
- ## 0.0.0-next-20250321090937
4
-
5
- ### Patch Changes
6
-
7
- - f4f843d: remove @loadable/component from package.json
8
- - @module-federation/sdk@0.0.0-next-20250321090937
9
- - @module-federation/bridge-shared@0.0.0-next-20250321090937
10
-
11
- ## 0.11.1
12
-
13
- ### Patch Changes
14
-
15
- - 790bdea: fix(bridge-react): export DestroyParams and RenderParams types
16
- - @module-federation/sdk@0.11.1
17
- - @module-federation/bridge-shared@0.11.1
18
-
19
- ## 0.11.0
3
+ ## 0.0.0-next-20250323051630
20
4
 
21
5
  ### Patch Changes
22
6
 
23
7
  - 4d67b8f: feat(bridge-react): enable custom createRoot in bridge-react
24
- - 2d086fc: Fix react-bridge version check for React versions earlier than 16.13.0
25
8
  - 4d67b8f: refactor(bridge-react): centralize type definitions into a single file for better maintainability and consistency
26
- - Updated dependencies [fce107e]
27
- - @module-federation/sdk@0.11.0
28
- - @module-federation/bridge-shared@0.11.0
9
+ - @module-federation/sdk@0.0.0-next-20250323051630
10
+ - @module-federation/bridge-shared@0.0.0-next-20250323051630
29
11
 
30
12
  ## 0.10.0
31
13
 
@@ -24,9 +24,6 @@ function isDebugMode() {
24
24
  return isBrowserDebug();
25
25
  }
26
26
  let Logger = class Logger2 {
27
- setPrefix(prefix) {
28
- this.prefix = prefix;
29
- }
30
27
  log(...args) {
31
28
  console.log(this.prefix, ...args);
32
29
  }
@@ -25,9 +25,6 @@ function isDebugMode() {
25
25
  return isBrowserDebug();
26
26
  }
27
27
  let Logger = class Logger2 {
28
- setPrefix(prefix) {
29
- this.prefix = prefix;
30
- }
31
28
  log(...args) {
32
29
  console.log(this.prefix, ...args);
33
30
  }
package/dist/index.cjs.js CHANGED
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
3
  const React = require("react");
5
- const context = require("./context-BGIGBPw-.cjs");
4
+ const context = require("./context-yPtLY2cD.cjs");
6
5
  const ReactRouterDOM = require("react-router-dom");
7
6
  const plugin = require("./plugin.cjs.js");
8
7
  const ReactDOM = require("react-dom");
@@ -146,8 +145,8 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
146
145
  providerInfoRef.current = providerReturn;
147
146
  setInitialized(true);
148
147
  return () => {
149
- var _a2, _b, _c, _d, _e, _f, _g, _h;
150
- if ((_a2 = providerInfoRef.current) == null ? void 0 : _a2.destroy) {
148
+ var _a, _b, _c, _d, _e, _f, _g, _h;
149
+ if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
151
150
  context.LoggerInstance.debug(
152
151
  `createRemoteComponent LazyComponent destroy >>>`,
153
152
  { moduleName, basename, dom: renderDom.current }
@@ -176,7 +175,7 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
176
175
  };
177
176
  }, [moduleName]);
178
177
  React.useEffect(() => {
179
- var _a2, _b, _c, _d, _e, _f;
178
+ var _a, _b, _c, _d, _e, _f;
180
179
  if (!initialized || !providerInfoRef.current) return;
181
180
  let renderProps = {
182
181
  moduleName,
@@ -187,7 +186,7 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
187
186
  ...resProps
188
187
  };
189
188
  renderDom.current = rootRef.current;
190
- const beforeBridgeRenderRes = ((_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(renderProps)) || {};
189
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(renderProps)) || {};
191
190
  renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
192
191
  providerInfoRef.current.render(renderProps);
193
192
  (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps);
@@ -197,7 +196,7 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
197
196
  });
198
197
  function withRouterData(WrappedComponent) {
199
198
  const Component = React.forwardRef(function(props, ref) {
200
- var _a2;
199
+ var _a;
201
200
  if (props == null ? void 0 : props.basename) {
202
201
  return /* @__PURE__ */ React.createElement(WrappedComponent, { ...props, basename: props.basename, ref });
203
202
  }
@@ -230,7 +229,7 @@ function withRouterData(WrappedComponent) {
230
229
  const match = useRouteMatch == null ? void 0 : useRouteMatch();
231
230
  if (useHistory) {
232
231
  const history = useHistory == null ? void 0 : useHistory();
233
- basename = (_a2 = history == null ? void 0 : history.createHref) == null ? void 0 : _a2.call(history, { pathname: "/" });
232
+ basename = (_a = history == null ? void 0 : history.createHref) == null ? void 0 : _a.call(history, { pathname: "/" });
234
233
  }
235
234
  if (match) {
236
235
  basename = context.pathJoin(basename, (match == null ? void 0 : match.path) || "/");
@@ -321,7 +320,7 @@ function createRemoteComponent(info) {
321
320
  return /* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: info.fallback }, /* @__PURE__ */ React.createElement(React.Suspense, { fallback: info.loading }, /* @__PURE__ */ React.createElement(LazyComponent, { ...props, ref })));
322
321
  });
323
322
  }
324
- const isReact18 = (_a = ReactDOM.version) == null ? void 0 : _a.startsWith("18");
323
+ const isReact18 = ReactDOM.version.startsWith("18");
325
324
  function createRoot(container, options) {
326
325
  if (isReact18) {
327
326
  return ReactDOM.createRoot(container, options);
@@ -360,7 +359,7 @@ function createBridgeComponent({
360
359
  };
361
360
  return {
362
361
  async render(info) {
363
- var _a2, _b, _c, _d, _e, _f;
362
+ var _a, _b, _c, _d, _e, _f;
364
363
  context.LoggerInstance.debug(`createBridgeComponent render Info`, info);
365
364
  const {
366
365
  moduleName,
@@ -370,7 +369,7 @@ function createBridgeComponent({
370
369
  fallback,
371
370
  ...propsInfo
372
371
  } = info;
373
- const beforeBridgeRenderRes = ((_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
372
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
374
373
  const rootComponentWithErrorBoundary = /* @__PURE__ */ React__namespace.createElement(ErrorBoundary, { FallbackComponent: fallback }, /* @__PURE__ */ React__namespace.createElement(
375
374
  RawComponent,
376
375
  {
@@ -399,7 +398,7 @@ function createBridgeComponent({
399
398
  ((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info)) || {};
400
399
  },
401
400
  destroy(info) {
402
- var _a2, _b, _c;
401
+ var _a, _b, _c;
403
402
  const { dom } = info;
404
403
  context.LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
405
404
  const root = rootMap.get(dom);
@@ -411,7 +410,7 @@ function createBridgeComponent({
411
410
  }
412
411
  rootMap.delete(dom);
413
412
  }
414
- (_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
413
+ (_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
415
414
  }
416
415
  };
417
416
  };
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@ declare interface CreateRootOptions {
20
20
  /**
21
21
  * Parameters for the destroy function
22
22
  */
23
- export declare interface DestroyParams {
23
+ declare interface DestroyParams {
24
24
  moduleName: string;
25
25
  dom: HTMLElement;
26
26
  }
@@ -89,7 +89,7 @@ export declare interface RenderFnParams extends ProviderParams {
89
89
  /**
90
90
  * Parameters for the render function
91
91
  */
92
- export declare interface RenderParams {
92
+ declare interface RenderParams {
93
93
  moduleName?: string;
94
94
  basename?: string;
95
95
  memoryRoute?: {
package/dist/index.es.js CHANGED
@@ -1,7 +1,6 @@
1
- var _a;
2
1
  import * as React from "react";
3
- import React__default, { createContext, Component, createElement, forwardRef, useRef, useState, useEffect, useContext } from "react";
4
- import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin, R as RouterContext } from "./context-B5HZIYe5.js";
2
+ import React__default, { Component, createElement, createContext, forwardRef, useRef, useState, useEffect, useContext } from "react";
3
+ import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin, R as RouterContext } from "./context-YcJWgOAv.js";
5
4
  import * as ReactRouterDOM from "react-router-dom";
6
5
  import { federationRuntime } from "./plugin.es.js";
7
6
  import ReactDOM from "react-dom";
@@ -127,8 +126,8 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
127
126
  providerInfoRef.current = providerReturn;
128
127
  setInitialized(true);
129
128
  return () => {
130
- var _a2, _b, _c, _d, _e, _f, _g, _h;
131
- if ((_a2 = providerInfoRef.current) == null ? void 0 : _a2.destroy) {
129
+ var _a, _b, _c, _d, _e, _f, _g, _h;
130
+ if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {
132
131
  LoggerInstance.debug(
133
132
  `createRemoteComponent LazyComponent destroy >>>`,
134
133
  { moduleName, basename, dom: renderDom.current }
@@ -157,7 +156,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
157
156
  };
158
157
  }, [moduleName]);
159
158
  useEffect(() => {
160
- var _a2, _b, _c, _d, _e, _f;
159
+ var _a, _b, _c, _d, _e, _f;
161
160
  if (!initialized || !providerInfoRef.current) return;
162
161
  let renderProps = {
163
162
  moduleName,
@@ -168,7 +167,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
168
167
  ...resProps
169
168
  };
170
169
  renderDom.current = rootRef.current;
171
- const beforeBridgeRenderRes = ((_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(renderProps)) || {};
170
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(renderProps)) || {};
172
171
  renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
173
172
  providerInfoRef.current.render(renderProps);
174
173
  (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps);
@@ -178,7 +177,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
178
177
  });
179
178
  function withRouterData(WrappedComponent) {
180
179
  const Component2 = forwardRef(function(props, ref) {
181
- var _a2;
180
+ var _a;
182
181
  if (props == null ? void 0 : props.basename) {
183
182
  return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename: props.basename, ref });
184
183
  }
@@ -211,7 +210,7 @@ function withRouterData(WrappedComponent) {
211
210
  const match = useRouteMatch == null ? void 0 : useRouteMatch();
212
211
  if (useHistory) {
213
212
  const history = useHistory == null ? void 0 : useHistory();
214
- basename = (_a2 = history == null ? void 0 : history.createHref) == null ? void 0 : _a2.call(history, { pathname: "/" });
213
+ basename = (_a = history == null ? void 0 : history.createHref) == null ? void 0 : _a.call(history, { pathname: "/" });
215
214
  }
216
215
  if (match) {
217
216
  basename = pathJoin(basename, (match == null ? void 0 : match.path) || "/");
@@ -302,7 +301,7 @@ function createRemoteComponent(info) {
302
301
  return /* @__PURE__ */ React__default.createElement(ErrorBoundary, { FallbackComponent: info.fallback }, /* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: info.loading }, /* @__PURE__ */ React__default.createElement(LazyComponent, { ...props, ref })));
303
302
  });
304
303
  }
305
- const isReact18 = (_a = ReactDOM.version) == null ? void 0 : _a.startsWith("18");
304
+ const isReact18 = ReactDOM.version.startsWith("18");
306
305
  function createRoot(container, options) {
307
306
  if (isReact18) {
308
307
  return ReactDOM.createRoot(container, options);
@@ -341,7 +340,7 @@ function createBridgeComponent({
341
340
  };
342
341
  return {
343
342
  async render(info) {
344
- var _a2, _b, _c, _d, _e, _f;
343
+ var _a, _b, _c, _d, _e, _f;
345
344
  LoggerInstance.debug(`createBridgeComponent render Info`, info);
346
345
  const {
347
346
  moduleName,
@@ -351,7 +350,7 @@ function createBridgeComponent({
351
350
  fallback,
352
351
  ...propsInfo
353
352
  } = info;
354
- const beforeBridgeRenderRes = ((_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
353
+ const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
355
354
  const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: fallback }, /* @__PURE__ */ React.createElement(
356
355
  RawComponent,
357
356
  {
@@ -380,7 +379,7 @@ function createBridgeComponent({
380
379
  ((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info)) || {};
381
380
  },
382
381
  destroy(info) {
383
- var _a2, _b, _c;
382
+ var _a, _b, _c;
384
383
  const { dom } = info;
385
384
  LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
386
385
  const root = rootMap.get(dom);
@@ -392,7 +391,7 @@ function createBridgeComponent({
392
391
  }
393
392
  rootMap.delete(dom);
394
393
  }
395
- (_c = (_b = (_a2 = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a2.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
394
+ (_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
396
395
  }
397
396
  };
398
397
  };
@@ -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 context = require("./context-BGIGBPw-.cjs");
5
+ const context = require("./context-yPtLY2cD.cjs");
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 "./context-B5HZIYe5.js";
3
+ import { R as RouterContext, L as LoggerInstance } from "./context-YcJWgOAv.js";
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 context = require("./context-BGIGBPw-.cjs");
5
+ const context = require("./context-yPtLY2cD.cjs");
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 "./context-B5HZIYe5.js";
3
+ import { R as RouterContext, L as LoggerInstance } from "./context-YcJWgOAv.js";
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-dom/");
5
- const context = require("./context-BGIGBPw-.cjs");
5
+ const context = require("./context-yPtLY2cD.cjs");
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 "./context-B5HZIYe5.js";
4
+ import { R as RouterContext, L as LoggerInstance } from "./context-YcJWgOAv.js";
5
5
  function WrapperRouter(props) {
6
6
  const { basename, ...propsRes } = props;
7
7
  const routerContextProps = useContext(RouterContext) || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-react",
3
- "version": "0.0.0-next-20250321090937",
3
+ "version": "0.0.0-next-20250323051630",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -44,14 +44,15 @@
44
44
  "./*": "./*"
45
45
  },
46
46
  "dependencies": {
47
+ "@loadable/component": "^5.16.4",
47
48
  "react-error-boundary": "^4.1.2",
48
- "@module-federation/bridge-shared": "0.0.0-next-20250321090937",
49
- "@module-federation/sdk": "0.0.0-next-20250321090937"
49
+ "@module-federation/bridge-shared": "0.0.0-next-20250323051630",
50
+ "@module-federation/sdk": "0.0.0-next-20250323051630"
50
51
  },
51
52
  "peerDependencies": {
52
53
  "react": ">=16.9.0",
53
54
  "react-dom": ">=16.9.0",
54
- "react-router-dom": "^4 || ^5 || ^6 || ^7"
55
+ "react-router-dom": "^4 || ^5 || ^6"
55
56
  },
56
57
  "devDependencies": {
57
58
  "@testing-library/react": "15.0.7",
@@ -67,7 +68,7 @@
67
68
  "typescript": "^5.2.2",
68
69
  "vite": "^5.4.12",
69
70
  "vite-plugin-dts": "^4.3.0",
70
- "@module-federation/runtime": "0.0.0-next-20250321090937"
71
+ "@module-federation/runtime": "0.0.0-next-20250323051630"
71
72
  },
72
73
  "scripts": {
73
74
  "dev": "vite",
package/src/index.ts CHANGED
@@ -1,8 +1,3 @@
1
1
  export { createRemoteComponent } from './remote/create';
2
2
  export { createBridgeComponent } from './provider/create';
3
- export type {
4
- ProviderParams,
5
- RenderFnParams,
6
- DestroyParams,
7
- RenderParams,
8
- } from './types';
3
+ export type { ProviderParams, RenderFnParams } from './types';
@@ -1,8 +1,7 @@
1
1
  import ReactDOM from 'react-dom';
2
2
  import { CreateRootOptions, Root } from '../types';
3
3
 
4
- // ReactDOM.version is only available in React 16.13.0 and later
5
- const isReact18 = ReactDOM.version?.startsWith('18');
4
+ const isReact18 = ReactDOM.version.startsWith('18');
6
5
 
7
6
  /**
8
7
  * Creates a root for a container element compatible with both React 16 and 18