@module-federation/bridge-react
Advanced tools
Comparing version 0.0.0-next-20240716133146 to 0.0.0-next-20240717101902
# @module-federation/bridge-react | ||
## 0.0.0-next-20240716133146 | ||
## 0.0.0-next-20240717101902 | ||
### Patch Changes | ||
- @module-federation/bridge-shared@0.0.0-next-20240716133146 | ||
- chore: bump next | ||
- @module-federation/bridge-shared@0.0.0-next-20240717101902 | ||
@@ -9,0 +10,0 @@ ## 0.2.6 |
@@ -310,5 +310,5 @@ "use strict"; | ||
const RawComponent = (info) => { | ||
const { appInfo, propsInfo } = info; | ||
const { appInfo, propsInfo, ...restProps } = 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 })); | ||
return /* @__PURE__ */ React__namespace.createElement(context.RouterContext.Provider, { value: { name, basename, memoryRoute } }, /* @__PURE__ */ React__namespace.createElement(bridgeInfo.rootComponent, { ...propsInfo, basename, ...restProps })); | ||
}; | ||
@@ -320,19 +320,38 @@ return { | ||
if (context.atLeastReact18(React__namespace)) { | ||
const root = client.createRoot(info.dom); | ||
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 | ||
} | ||
} | ||
), | ||
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); | ||
root.render( | ||
/* @__PURE__ */ React__namespace.createElement( | ||
RawComponent, | ||
{ | ||
propsInfo, | ||
appInfo: { | ||
name, | ||
basename, | ||
memoryRoute | ||
} | ||
} | ||
) | ||
); | ||
} else { | ||
ReactDOM.render( | ||
const renderFunc = (bridgeInfo == null ? void 0 : bridgeInfo.render) || ReactDOM.render; | ||
renderFunc( | ||
/* @__PURE__ */ React__namespace.createElement( | ||
@@ -339,0 +358,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'; | ||
@@ -22,4 +23,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; | ||
@@ -53,2 +54,3 @@ | ||
rootComponent: React_2.ComponentType<T>; | ||
render?: (App: React_2.ReactElement, id?: HTMLElement | string) => default_3.Root; | ||
}; | ||
@@ -55,0 +57,0 @@ |
@@ -291,5 +291,5 @@ import * as React from "react"; | ||
const RawComponent = (info) => { | ||
const { appInfo, propsInfo } = info; | ||
const { appInfo, propsInfo, ...restProps } = info; | ||
const { name, memoryRoute, basename = "/" } = appInfo; | ||
return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: { name, basename, memoryRoute } }, /* @__PURE__ */ React.createElement(bridgeInfo.rootComponent, { ...propsInfo, basename })); | ||
return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: { name, basename, memoryRoute } }, /* @__PURE__ */ React.createElement(bridgeInfo.rootComponent, { ...propsInfo, basename, ...restProps })); | ||
}; | ||
@@ -301,19 +301,38 @@ return { | ||
if (atLeastReact18(React)) { | ||
const root = client.createRoot(info.dom); | ||
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 | ||
} | ||
} | ||
), | ||
info.dom | ||
); | ||
} else { | ||
root = client.createRoot(info.dom); | ||
root.render( | ||
/* @__PURE__ */ React.createElement( | ||
RawComponent, | ||
{ | ||
propsInfo, | ||
appInfo: { | ||
name, | ||
basename, | ||
memoryRoute | ||
} | ||
} | ||
) | ||
); | ||
} | ||
rootMap.set(info.dom, root); | ||
root.render( | ||
/* @__PURE__ */ React.createElement( | ||
RawComponent, | ||
{ | ||
propsInfo, | ||
appInfo: { | ||
name, | ||
basename, | ||
memoryRoute | ||
} | ||
} | ||
) | ||
); | ||
} else { | ||
ReactDOM.render( | ||
const renderFunc = (bridgeInfo == null ? void 0 : bridgeInfo.render) || ReactDOM.render; | ||
renderFunc( | ||
/* @__PURE__ */ React.createElement( | ||
@@ -320,0 +339,0 @@ RawComponent, |
@@ -63,4 +63,6 @@ "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) { | ||
@@ -72,2 +74,7 @@ const MemeoryRouterInstance = createMemoryRouter(routers, { | ||
} else { | ||
console.log("=======createBrowserRouter routers", routers); | ||
console.log( | ||
"=======createBrowserRouter routerContextProps.basename", | ||
routerContextProps.basename | ||
); | ||
const BrowserRouterInstance = createBrowserRouter(routers, { | ||
@@ -74,0 +81,0 @@ basename: routerContextProps.basename, |
@@ -45,4 +45,6 @@ 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) { | ||
@@ -54,2 +56,7 @@ const MemeoryRouterInstance = createMemoryRouter(routers, { | ||
} else { | ||
console.log("=======createBrowserRouter routers", routers); | ||
console.log( | ||
"=======createBrowserRouter routerContextProps.basename", | ||
routerContextProps.basename | ||
); | ||
const BrowserRouterInstance = createBrowserRouter(routers, { | ||
@@ -56,0 +63,0 @@ basename: routerContextProps.basename, |
{ | ||
"name": "@module-federation/bridge-react", | ||
"version": "0.0.0-next-20240716133146", | ||
"version": "0.0.0-next-20240717101902", | ||
"publishConfig": { | ||
@@ -23,2 +23,12 @@ "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" | ||
}, | ||
"./*": "./*" | ||
@@ -29,3 +39,3 @@ }, | ||
"react-error-boundary": "^4.0.13", | ||
"@module-federation/bridge-shared": "0.0.0-next-20240716133146" | ||
"@module-federation/bridge-shared": "0.0.0-next-20240717101902" | ||
}, | ||
@@ -32,0 +42,0 @@ "peerDependencies": { |
@@ -25,2 +25,4 @@ 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'), | ||
}, | ||
@@ -36,2 +38,4 @@ formats: ['cjs', 'es'], | ||
'react-router-dom/', | ||
'react-router-dom/index.js', | ||
'react-router-dom/dist/index.js', | ||
], | ||
@@ -38,0 +42,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87164
37
2380
+ Added@module-federation/bridge-shared@0.0.0-next-20240717101902(transitive)
- Removed@module-federation/bridge-shared@0.0.0-next-20240716133146(transitive)
Updated@module-federation/bridge-shared@0.0.0-next-20240717101902