@module-federation/bridge-react
Advanced tools
Comparing version 0.0.0-next-20250208084948 to 0.0.0-next-20250208115611
# @module-federation/bridge-react | ||
## 0.0.0-next-20250208084948 | ||
## 0.0.0-next-20250208115611 | ||
@@ -8,4 +8,4 @@ ### Patch Changes | ||
- c3387db: fix: the bridge-react package was failing when used with React 16 due to missing react-dom/client module | ||
- @module-federation/sdk@0.0.0-next-20250208084948 | ||
- @module-federation/bridge-shared@0.0.0-next-20250208084948 | ||
- @module-federation/sdk@0.0.0-next-20250208115611 | ||
- @module-federation/bridge-shared@0.0.0-next-20250208115611 | ||
@@ -12,0 +12,0 @@ ## 0.8.10 |
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | ||
@@ -368,2 +346,16 @@ const React = require("react"); | ||
} | ||
const isReact18 = ReactDOM.version.startsWith("18"); | ||
function createRoot(container, options) { | ||
if (isReact18) { | ||
return ReactDOM.createRoot(container, options); | ||
} | ||
return { | ||
render(children) { | ||
ReactDOM.render(children, container); | ||
}, | ||
unmount() { | ||
ReactDOM.unmountComponentAtNode(container); | ||
} | ||
}; | ||
} | ||
function createBridgeComponent(bridgeInfo) { | ||
@@ -418,9 +410,5 @@ return () => { | ||
} else { | ||
import("react-dom/client").then( | ||
(ReactDOMClient) => { | ||
const root = ReactDOMClient.createRoot(info.dom); | ||
root.render(rootComponentWithErrorBoundary); | ||
rootMap.set(info.dom, root); | ||
} | ||
); | ||
const root = createRoot(info.dom); | ||
root.render(rootComponentWithErrorBoundary); | ||
rootMap.set(info.dom, root); | ||
} | ||
@@ -427,0 +415,0 @@ ((_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)) || {}; |
@@ -327,2 +327,16 @@ import * as React from "react"; | ||
} | ||
const isReact18 = ReactDOM.version.startsWith("18"); | ||
function createRoot(container, options) { | ||
if (isReact18) { | ||
return ReactDOM.createRoot(container, options); | ||
} | ||
return { | ||
render(children) { | ||
ReactDOM.render(children, container); | ||
}, | ||
unmount() { | ||
ReactDOM.unmountComponentAtNode(container); | ||
} | ||
}; | ||
} | ||
function createBridgeComponent(bridgeInfo) { | ||
@@ -377,9 +391,5 @@ return () => { | ||
} else { | ||
import("react-dom/client").then( | ||
(ReactDOMClient) => { | ||
const root = ReactDOMClient.createRoot(info.dom); | ||
root.render(rootComponentWithErrorBoundary); | ||
rootMap.set(info.dom, root); | ||
} | ||
); | ||
const root = createRoot(info.dom); | ||
root.render(rootComponentWithErrorBoundary); | ||
rootMap.set(info.dom, root); | ||
} | ||
@@ -386,0 +396,0 @@ ((_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)) || {}; |
{ | ||
"name": "@module-federation/bridge-react", | ||
"version": "0.0.0-next-20250208084948", | ||
"version": "0.0.0-next-20250208115611", | ||
"publishConfig": { | ||
@@ -49,4 +49,4 @@ "access": "public" | ||
"react-error-boundary": "^4.1.2", | ||
"@module-federation/bridge-shared": "0.0.0-next-20250208084948", | ||
"@module-federation/sdk": "0.0.0-next-20250208084948" | ||
"@module-federation/bridge-shared": "0.0.0-next-20250208115611", | ||
"@module-federation/sdk": "0.0.0-next-20250208115611" | ||
}, | ||
@@ -72,3 +72,3 @@ "peerDependencies": { | ||
"vite-plugin-dts": "^4.3.0", | ||
"@module-federation/runtime": "0.0.0-next-20250208084948" | ||
"@module-federation/runtime": "0.0.0-next-20250208115611" | ||
}, | ||
@@ -75,0 +75,0 @@ "scripts": { |
@@ -14,3 +14,2 @@ import ReactDOM from 'react-dom'; | ||
// Check if we're running React 18 | ||
const isReact18 = ReactDOM.version.startsWith('18'); | ||
@@ -31,5 +30,6 @@ | ||
// For React 16, simulate the new root API using render/unmountComponentAtNode | ||
// For React 16/17, simulate the new root API using render/unmountComponentAtNode | ||
return { | ||
render(children: React.ReactNode) { | ||
// @ts-ignore - React 17's render method is deprecated but still functional | ||
ReactDOM.render(children, container); | ||
@@ -57,5 +57,6 @@ }, | ||
// For React 16, simulate the new root API using hydrate | ||
// For React 16/17, simulate the new root API using hydrate | ||
return { | ||
render(children: React.ReactNode) { | ||
// @ts-ignore - React 17's hydrate method is deprecated but still functional | ||
ReactDOM.hydrate(children, container); | ||
@@ -62,0 +63,0 @@ }, |
Sorry, the diff of this file is not supported yet
119352
3210
+ Added@module-federation/bridge-shared@0.0.0-next-20250208115611(transitive)
+ Added@module-federation/sdk@0.0.0-next-20250208115611(transitive)
- Removed@module-federation/bridge-shared@0.0.0-next-20250208084948(transitive)
- Removed@module-federation/sdk@0.0.0-next-20250208084948(transitive)
Updated@module-federation/bridge-shared@0.0.0-next-20250208115611