@module-federation/bridge-react 0.0.0-next-20250208084948 → 0.0.0-next-20250214035103

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,12 +1,21 @@
1
1
  # @module-federation/bridge-react
2
2
 
3
- ## 0.0.0-next-20250208084948
3
+ ## 0.0.0-next-20250214035103
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - c3387db: fix: the bridge-react package was failing when used with React 16 due to missing react-dom/client module
8
- - @module-federation/sdk@0.0.0-next-20250208084948
9
- - @module-federation/bridge-shared@0.0.0-next-20250208084948
7
+ - 4ef21d2: chore: adjust bridge-react to structure directory
8
+ - Updated dependencies [cb463da]
9
+ - @module-federation/sdk@0.0.0-next-20250214035103
10
+ - @module-federation/bridge-shared@0.0.0-next-20250214035103
11
+
12
+ ## 0.8.11
13
+
14
+ ### Patch Changes
15
+
16
+ - 646314d: fix: the bridge-react package was failing when used with React 16 due to missing react-dom/client module
17
+ - @module-federation/sdk@0.8.11
18
+ - @module-federation/bridge-shared@0.8.11
10
19
 
11
20
  ## 0.8.10
12
21
 
@@ -8,8 +8,8 @@ import {
8
8
  Outlet,
9
9
  createBrowserRouter,
10
10
  } from 'react-router-dom';
11
- import { BrowserRouter, RouterProvider } from '../src/router';
12
- import { RouterContext } from '../src/context';
11
+ import { BrowserRouter, RouterProvider } from '../src/router/default';
12
+ import { RouterContext } from '../src/provider/context';
13
13
  import { getHtml, getWindowImpl } from './util';
14
14
 
15
15
  describe('react router proxy', () => {
package/dist/index.cjs.js CHANGED
@@ -1,26 +1,4 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
3
  const React = require("react");
26
4
  const context = require("./context-BwD5jfgB.cjs");
@@ -234,7 +212,7 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
234
212
  }
235
213
  );
236
214
  };
237
- RemoteApp2["__APP_VERSION__"] = "0.8.10";
215
+ RemoteApp2["__APP_VERSION__"] = "0.8.11";
238
216
  return /* @__PURE__ */ React.createElement(RemoteApp2, null);
239
217
  });
240
218
  function withRouterData(WrappedComponent) {
@@ -365,6 +343,20 @@ function createRemoteComponent(info) {
365
343
  }
366
344
  );
367
345
  }
346
+ const isReact18 = ReactDOM.version.startsWith("18");
347
+ function createRoot(container, options) {
348
+ if (isReact18) {
349
+ return ReactDOM.createRoot(container, options);
350
+ }
351
+ return {
352
+ render(children) {
353
+ ReactDOM.render(children, container);
354
+ },
355
+ unmount() {
356
+ ReactDOM.unmountComponentAtNode(container);
357
+ }
358
+ };
359
+ }
368
360
  function createBridgeComponent(bridgeInfo) {
369
361
  return () => {
370
362
  const rootMap = /* @__PURE__ */ new Map();
@@ -414,13 +406,9 @@ function createBridgeComponent(bridgeInfo) {
414
406
  bridgeInfo == null ? void 0 : bridgeInfo.render(rootComponentWithErrorBoundary, dom)
415
407
  ).then((root) => rootMap.set(info.dom, root));
416
408
  } else {
417
- import("react-dom/client").then(
418
- (ReactDOMClient) => {
419
- const root = ReactDOMClient.createRoot(info.dom);
420
- root.render(rootComponentWithErrorBoundary);
421
- rootMap.set(info.dom, root);
422
- }
423
- );
409
+ const root = createRoot(info.dom);
410
+ root.render(rootComponentWithErrorBoundary);
411
+ rootMap.set(info.dom, root);
424
412
  }
425
413
  ((_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)) || {};
426
414
  },
package/dist/index.es.js CHANGED
@@ -193,7 +193,7 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
193
193
  }
194
194
  );
195
195
  };
196
- RemoteApp2["__APP_VERSION__"] = "0.8.10";
196
+ RemoteApp2["__APP_VERSION__"] = "0.8.11";
197
197
  return /* @__PURE__ */ React__default.createElement(RemoteApp2, null);
198
198
  });
199
199
  function withRouterData(WrappedComponent) {
@@ -324,6 +324,20 @@ function createRemoteComponent(info) {
324
324
  }
325
325
  );
326
326
  }
327
+ const isReact18 = ReactDOM.version.startsWith("18");
328
+ function createRoot(container, options) {
329
+ if (isReact18) {
330
+ return ReactDOM.createRoot(container, options);
331
+ }
332
+ return {
333
+ render(children) {
334
+ ReactDOM.render(children, container);
335
+ },
336
+ unmount() {
337
+ ReactDOM.unmountComponentAtNode(container);
338
+ }
339
+ };
340
+ }
327
341
  function createBridgeComponent(bridgeInfo) {
328
342
  return () => {
329
343
  const rootMap = /* @__PURE__ */ new Map();
@@ -373,13 +387,9 @@ function createBridgeComponent(bridgeInfo) {
373
387
  bridgeInfo == null ? void 0 : bridgeInfo.render(rootComponentWithErrorBoundary, dom)
374
388
  ).then((root) => rootMap.set(info.dom, root));
375
389
  } else {
376
- import("react-dom/client").then(
377
- (ReactDOMClient) => {
378
- const root = ReactDOMClient.createRoot(info.dom);
379
- root.render(rootComponentWithErrorBoundary);
380
- rootMap.set(info.dom, root);
381
- }
382
- );
390
+ const root = createRoot(info.dom);
391
+ root.render(rootComponentWithErrorBoundary);
392
+ rootMap.set(info.dom, root);
383
393
  }
384
394
  ((_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)) || {};
385
395
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-react",
3
- "version": "0.0.0-next-20250208084948",
3
+ "version": "0.0.0-next-20250214035103",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -46,8 +46,8 @@
46
46
  "dependencies": {
47
47
  "@loadable/component": "^5.16.4",
48
48
  "react-error-boundary": "^4.1.2",
49
- "@module-federation/bridge-shared": "0.0.0-next-20250208084948",
50
- "@module-federation/sdk": "0.0.0-next-20250208084948"
49
+ "@module-federation/bridge-shared": "0.0.0-next-20250214035103",
50
+ "@module-federation/sdk": "0.0.0-next-20250214035103"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "react": ">=16.9.0",
@@ -68,7 +68,7 @@
68
68
  "typescript": "^5.2.2",
69
69
  "vite": "^5.2.14",
70
70
  "vite-plugin-dts": "^4.3.0",
71
- "@module-federation/runtime": "0.0.0-next-20250208084948"
71
+ "@module-federation/runtime": "0.0.0-next-20250214035103"
72
72
  },
73
73
  "scripts": {
74
74
  "dev": "vite",
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { createRemoteComponent } from './create';
2
- export { createBridgeComponent } from './provider';
1
+ export { createRemoteComponent } from './remote/create';
2
+ export { createBridgeComponent } from './provider/create';
3
3
  export type {
4
4
  ProviderParams,
5
5
  RenderFnParams,
@@ -11,7 +11,6 @@ interface Root {
11
11
  unmount(): void;
12
12
  }
13
13
 
14
- // Check if we're running React 18
15
14
  const isReact18 = ReactDOM.version.startsWith('18');
16
15
 
17
16
  /**
@@ -27,9 +26,10 @@ export function createRoot(
27
26
  return (ReactDOM as any).createRoot(container, options);
28
27
  }
29
28
 
30
- // For React 16, simulate the new root API using render/unmountComponentAtNode
29
+ // For React 16/17, simulate the new root API using render/unmountComponentAtNode
31
30
  return {
32
31
  render(children: React.ReactNode) {
32
+ // @ts-ignore - React 17's render method is deprecated but still functional
33
33
  ReactDOM.render(children, container);
34
34
  },
35
35
  unmount() {
@@ -52,9 +52,10 @@ export function hydrateRoot(
52
52
  return (ReactDOM as any).hydrateRoot(container, initialChildren, options);
53
53
  }
54
54
 
55
- // For React 16, simulate the new root API using hydrate
55
+ // For React 16/17, simulate the new root API using hydrate
56
56
  return {
57
57
  render(children: React.ReactNode) {
58
+ // @ts-ignore - React 17's hydrate method is deprecated but still functional
58
59
  ReactDOM.hydrate(children, container);
59
60
  },
60
61
  unmount() {
@@ -6,7 +6,7 @@ import type {
6
6
  } from '@module-federation/bridge-shared';
7
7
  import { ErrorBoundary } from 'react-error-boundary';
8
8
  import { RouterContext } from './context';
9
- import { LoggerInstance } from './utils';
9
+ import { LoggerInstance } from '../utils';
10
10
  import { federationRuntime } from './plugin';
11
11
  import { createRoot } from './compat';
12
12
 
@@ -86,14 +86,9 @@ export function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>) {
86
86
  bridgeInfo?.render(rootComponentWithErrorBoundary, dom),
87
87
  ).then((root: RootType) => rootMap.set(info.dom, root));
88
88
  } else {
89
- // Dynamically import react-dom/client
90
- import('react-dom/client').then(
91
- (ReactDOMClient: typeof import('react-dom/client')) => {
92
- const root = ReactDOMClient.createRoot(info.dom);
93
- root.render(rootComponentWithErrorBoundary);
94
- rootMap.set(info.dom, root);
95
- },
96
- );
89
+ const root = createRoot(info.dom);
90
+ root.render(rootComponentWithErrorBoundary);
91
+ rootMap.set(info.dom, root);
97
92
  }
98
93
 
99
94
  instance?.bridgeHook?.lifecycle?.afterBridgeRender?.emit(info) || {};
@@ -1,5 +1,7 @@
1
- import type { FederationRuntimePlugin } from '@module-federation/runtime';
2
- import type { FederationHost } from '@module-federation/runtime';
1
+ import type {
2
+ FederationRuntimePlugin,
3
+ FederationHost,
4
+ } from '@module-federation/runtime';
3
5
 
4
6
  export type FederationRuntimeType = {
5
7
  instance: FederationHost | null;
@@ -10,7 +10,7 @@ import type { ProviderParams } from '@module-federation/bridge-shared';
10
10
  import { dispatchPopstateEnv } from '@module-federation/bridge-shared';
11
11
  import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
12
12
  import { LoggerInstance, pathJoin, getRootDomDefaultClassName } from '../utils';
13
- import { federationRuntime } from '../plugin';
13
+ import { federationRuntime } from '../provider/plugin';
14
14
 
15
15
  declare const __APP_VERSION__: string;
16
16
  export interface RenderFnParams extends ProviderParams {
@@ -3,8 +3,8 @@ import {
3
3
  ErrorBoundary,
4
4
  ErrorBoundaryPropsWithComponent,
5
5
  } from 'react-error-boundary';
6
- import { LoggerInstance } from './utils';
7
- import RemoteApp from './remote';
6
+ import { LoggerInstance } from '../utils';
7
+ import RemoteApp from './component';
8
8
  import type { ProviderParams } from '@module-federation/bridge-shared';
9
9
 
10
10
  export interface RenderFnParams extends ProviderParams {
@@ -1,8 +1,8 @@
1
1
  import React, { useContext } from 'react';
2
2
  // The upper alias react-router-dom$ into this file avoids the loop
3
3
  import * as ReactRouterDom from 'react-router-dom/';
4
- import { RouterContext } from './context';
5
- import { LoggerInstance } from './utils';
4
+ import { RouterContext } from '../provider/context';
5
+ import { LoggerInstance } from '../utils';
6
6
 
7
7
  function WrapperRouter(
8
8
  props:
@@ -2,8 +2,8 @@ import React, { useContext } from 'react';
2
2
  // The upper alias react-router-dom$ into this file avoids the loop
3
3
  // @ts-ignore
4
4
  import * as ReactRouterDom from 'react-router-dom/index.js';
5
- import { RouterContext } from './context';
6
- import { LoggerInstance } from './utils';
5
+ import { RouterContext } from '../provider/context';
6
+ import { LoggerInstance } from '../utils';
7
7
 
8
8
  function WraperRouter(
9
9
  props:
@@ -1,9 +1,8 @@
1
1
  import React, { useContext } from 'react';
2
2
  // The upper alias react-router-dom$ into this file avoids the loop
3
3
  import * as ReactRouterDom from 'react-router-dom/dist/index.js';
4
-
5
- import { RouterContext } from './context';
6
- import { LoggerInstance } from './utils';
4
+ import { RouterContext } from '../provider/context';
5
+ import { LoggerInstance } from '../utils';
7
6
 
8
7
  function WraperRouter(
9
8
  props:
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { createLogger } from '@module-federation/sdk';
2
+ import { createLogger } from '@module-federation/sdk/logger';
3
3
 
4
4
  export const LoggerInstance = createLogger(
5
5
  '[ Module Federation Bridge React ]',
package/vite.config.ts CHANGED
@@ -21,10 +21,10 @@ export default defineConfig({
21
21
  lib: {
22
22
  entry: {
23
23
  index: path.resolve(__dirname, 'src/index.ts'),
24
- plugin: path.resolve(__dirname, 'src/plugin.ts'),
25
- router: path.resolve(__dirname, 'src/router.tsx'),
26
- 'router-v5': path.resolve(__dirname, 'src/router-v5.tsx'),
27
- 'router-v6': path.resolve(__dirname, 'src/router-v6.tsx'),
24
+ plugin: path.resolve(__dirname, 'src/provider/plugin.ts'),
25
+ router: path.resolve(__dirname, 'src/router/default.tsx'),
26
+ 'router-v5': path.resolve(__dirname, 'src/router/v5.tsx'),
27
+ 'router-v6': path.resolve(__dirname, 'src/router/v6.tsx'),
28
28
  },
29
29
  formats: ['cjs', 'es'],
30
30
  fileName: (format, entryName) => `${entryName}.${format}.js`,
File without changes