@module-federation/bridge-react
Advanced tools
Comparing version 0.0.0-next-20240718040714 to 0.0.0-next-20240718061842
# @module-federation/bridge-react | ||
## 0.0.0-next-20240718040714 | ||
## 0.0.0-next-20240718061842 | ||
### Patch Changes | ||
- chore: bump next | ||
- @module-federation/bridge-shared@0.0.0-next-20240718040714 | ||
- @module-federation/bridge-shared@0.0.0-next-20240718061842 | ||
@@ -10,0 +9,0 @@ ## 0.2.6 |
@@ -310,5 +310,5 @@ "use strict"; | ||
const RawComponent = (info) => { | ||
const { appInfo, propsInfo, ...restProps } = info; | ||
const { appInfo, propsInfo } = info; | ||
const { name, memoryRoute, basename = "/" } = appInfo; | ||
return /* @__PURE__ */ React__namespace.createElement(context.RouterContext.Provider, { value: { name, basename, memoryRoute } }, /* @__PURE__ */ React__namespace.createElement(bridgeInfo.rootComponent, { ...propsInfo, basename, ...restProps })); | ||
return /* @__PURE__ */ React__namespace.createElement(context.RouterContext.Provider, { value: { name, basename, memoryRoute } }, /* @__PURE__ */ React__namespace.createElement(bridgeInfo.rootComponent, { ...propsInfo, basename })); | ||
}; | ||
@@ -320,38 +320,19 @@ return { | ||
if (context.atLeastReact18(React__namespace)) { | ||
let root = null; | ||
if (bridgeInfo == null ? void 0 : bridgeInfo.render) { | ||
root = bridgeInfo == null ? void 0 : bridgeInfo.render( | ||
/* @__PURE__ */ React__namespace.createElement( | ||
RawComponent, | ||
{ | ||
propsInfo, | ||
appInfo: { | ||
name, | ||
basename, | ||
memoryRoute | ||
} | ||
const root = client.createRoot(info.dom); | ||
rootMap.set(info.dom, root); | ||
root.render( | ||
/* @__PURE__ */ React__namespace.createElement( | ||
RawComponent, | ||
{ | ||
propsInfo, | ||
appInfo: { | ||
name, | ||
basename, | ||
memoryRoute | ||
} | ||
), | ||
info.dom | ||
); | ||
} else { | ||
root = client.createRoot(info.dom); | ||
root.render( | ||
/* @__PURE__ */ React__namespace.createElement( | ||
RawComponent, | ||
{ | ||
propsInfo, | ||
appInfo: { | ||
name, | ||
basename, | ||
memoryRoute | ||
} | ||
} | ||
) | ||
); | ||
} | ||
rootMap.set(info.dom, root); | ||
} | ||
) | ||
); | ||
} else { | ||
const renderFunc = (bridgeInfo == null ? void 0 : bridgeInfo.render) || ReactDOM.render; | ||
renderFunc( | ||
ReactDOM.render( | ||
/* @__PURE__ */ React__namespace.createElement( | ||
@@ -358,0 +339,0 @@ RawComponent, |
import { ComponentType } from 'react'; | ||
import { default as default_2 } from 'react'; | ||
import { default as default_3 } from 'react-dom/client'; | ||
import { ErrorInfo } from 'react'; | ||
@@ -23,4 +22,4 @@ import { PropsWithChildren } from 'react'; | ||
}): (props: { | ||
basename?: ProviderParams["basename"]; | ||
memoryRoute?: ProviderParams["memoryRoute"]; | ||
basename?: ProviderParams['basename']; | ||
memoryRoute?: ProviderParams['memoryRoute']; | ||
} & ("__BRIDGE_FN__" extends keyof (T[E] extends (...args: any) => any ? ReturnType<T[E]> : never) ? (T[E] extends (...args: any) => any ? ReturnType<T[E]> : never)["__BRIDGE_FN__"] extends (...args: any) => any ? Parameters<(T[E] extends (...args: any) => any ? ReturnType<T[E]> : never)["__BRIDGE_FN__"]>[0] : {} : {})) => default_2.JSX.Element; | ||
@@ -54,3 +53,2 @@ | ||
rootComponent: React_2.ComponentType<T>; | ||
render?: (App: React_2.ReactElement, id?: HTMLElement | string) => default_3.Root; | ||
}; | ||
@@ -57,0 +55,0 @@ |
@@ -291,5 +291,5 @@ import * as React from "react"; | ||
const RawComponent = (info) => { | ||
const { appInfo, propsInfo, ...restProps } = info; | ||
const { appInfo, propsInfo } = info; | ||
const { name, memoryRoute, basename = "/" } = appInfo; | ||
return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: { name, basename, memoryRoute } }, /* @__PURE__ */ React.createElement(bridgeInfo.rootComponent, { ...propsInfo, basename, ...restProps })); | ||
return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: { name, basename, memoryRoute } }, /* @__PURE__ */ React.createElement(bridgeInfo.rootComponent, { ...propsInfo, basename })); | ||
}; | ||
@@ -301,38 +301,19 @@ return { | ||
if (atLeastReact18(React)) { | ||
let root = null; | ||
if (bridgeInfo == null ? void 0 : bridgeInfo.render) { | ||
root = bridgeInfo == null ? void 0 : bridgeInfo.render( | ||
/* @__PURE__ */ React.createElement( | ||
RawComponent, | ||
{ | ||
propsInfo, | ||
appInfo: { | ||
name, | ||
basename, | ||
memoryRoute | ||
} | ||
const root = client.createRoot(info.dom); | ||
rootMap.set(info.dom, root); | ||
root.render( | ||
/* @__PURE__ */ React.createElement( | ||
RawComponent, | ||
{ | ||
propsInfo, | ||
appInfo: { | ||
name, | ||
basename, | ||
memoryRoute | ||
} | ||
), | ||
info.dom | ||
); | ||
} else { | ||
root = client.createRoot(info.dom); | ||
root.render( | ||
/* @__PURE__ */ React.createElement( | ||
RawComponent, | ||
{ | ||
propsInfo, | ||
appInfo: { | ||
name, | ||
basename, | ||
memoryRoute | ||
} | ||
} | ||
) | ||
); | ||
} | ||
rootMap.set(info.dom, root); | ||
} | ||
) | ||
); | ||
} else { | ||
const renderFunc = (bridgeInfo == null ? void 0 : bridgeInfo.render) || ReactDOM.render; | ||
renderFunc( | ||
ReactDOM.render( | ||
/* @__PURE__ */ React.createElement( | ||
@@ -339,0 +320,0 @@ RawComponent, |
@@ -63,6 +63,4 @@ "use strict"; | ||
const createBrowserRouter = ReactRouterDom__namespace["createBrowserRouter"]; | ||
console.log("=======resolve to v5!!"); | ||
if (!routerContextProps) | ||
return /* @__PURE__ */ React.createElement(RouterProvider, { ...props }); | ||
console.log("=======resolve to v6!!"); | ||
if (routerContextProps.memoryRoute) { | ||
@@ -74,7 +72,2 @@ const MemeoryRouterInstance = createMemoryRouter(routers, { | ||
} else { | ||
console.log("=======createBrowserRouter routers", routers); | ||
console.log( | ||
"=======createBrowserRouter routerContextProps.basename", | ||
routerContextProps.basename | ||
); | ||
const BrowserRouterInstance = createBrowserRouter(routers, { | ||
@@ -81,0 +74,0 @@ basename: routerContextProps.basename, |
@@ -45,6 +45,4 @@ import React__default, { useContext } from "react"; | ||
const createBrowserRouter = ReactRouterDom["createBrowserRouter"]; | ||
console.log("=======resolve to v5!!"); | ||
if (!routerContextProps) | ||
return /* @__PURE__ */ React__default.createElement(RouterProvider, { ...props }); | ||
console.log("=======resolve to v6!!"); | ||
if (routerContextProps.memoryRoute) { | ||
@@ -56,7 +54,2 @@ const MemeoryRouterInstance = createMemoryRouter(routers, { | ||
} else { | ||
console.log("=======createBrowserRouter routers", routers); | ||
console.log( | ||
"=======createBrowserRouter routerContextProps.basename", | ||
routerContextProps.basename | ||
); | ||
const BrowserRouterInstance = createBrowserRouter(routers, { | ||
@@ -63,0 +56,0 @@ basename: routerContextProps.basename, |
{ | ||
"name": "@module-federation/bridge-react", | ||
"version": "0.0.0-next-20240718040714", | ||
"version": "0.0.0-next-20240718061842", | ||
"publishConfig": { | ||
@@ -23,12 +23,2 @@ "access": "public" | ||
}, | ||
"./router-v5": { | ||
"types": "./dist/router-v5.d.ts", | ||
"import": "./dist/router-v5.es.js", | ||
"require": "./dist/router-v5.cjs.js" | ||
}, | ||
"./router-v6": { | ||
"types": "./dist/router-v6.d.ts", | ||
"import": "./dist/router-v6.es.js", | ||
"require": "./dist/router-v6.cjs.js" | ||
}, | ||
"./*": "./*" | ||
@@ -39,3 +29,3 @@ }, | ||
"react-error-boundary": "^4.0.13", | ||
"@module-federation/bridge-shared": "0.0.0-next-20240718040714" | ||
"@module-federation/bridge-shared": "0.0.0-next-20240718061842" | ||
}, | ||
@@ -42,0 +32,0 @@ "peerDependencies": { |
@@ -25,4 +25,2 @@ import { defineConfig } from 'vite'; | ||
router: path.resolve(__dirname, 'src/router.tsx'), | ||
'router-v5': path.resolve(__dirname, 'src/router-v5.tsx'), | ||
'router-v6': path.resolve(__dirname, 'src/router-v6.tsx'), | ||
}, | ||
@@ -38,4 +36,2 @@ formats: ['cjs', 'es'], | ||
'react-router-dom/', | ||
'react-router-dom/index.js', | ||
'react-router-dom/dist/index.js', | ||
], | ||
@@ -42,0 +38,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
66391
29
1854
+ Added@module-federation/bridge-shared@0.0.0-next-20240718061842(transitive)
- Removed@module-federation/bridge-shared@0.0.0-next-20240718040714(transitive)
Updated@module-federation/bridge-shared@0.0.0-next-20240718061842