Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@module-federation/bridge-react

Package Overview
Dependencies
Maintainers
0
Versions
339
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@module-federation/bridge-react - npm Package Compare versions

Comparing version 0.0.0-next-20240718080108 to 0.0.0-next-20240722031635

5

CHANGELOG.md
# @module-federation/bridge-react
## 0.0.0-next-20240718080108
## 0.0.0-next-20240722031635
### Patch Changes
- chore: bump next
- @module-federation/bridge-shared@0.0.0-next-20240718080108
- @module-federation/bridge-shared@0.0.0-next-20240722031635

@@ -10,0 +9,0 @@ ## 0.2.6

56

dist/index.cjs.js

@@ -310,46 +310,28 @@ "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 }));
};
return {
async render(info) {
render(info) {
context.LoggerInstance.log(`createBridgeComponent render Info`, info);
const { name, basename, memoryRoute, ...propsInfo } = info;
if (context.atLeastReact18(React__namespace)) {
if (bridgeInfo == null ? void 0 : bridgeInfo.render) {
Promise.resolve(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
)).then((root) => rootMap.set(info.dom, root));
} else {
const 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(

@@ -370,3 +352,3 @@ RawComponent,

},
async destroy(info) {
destroy(info) {
context.LoggerInstance.log(`createBridgeComponent destroy Info`, {

@@ -373,0 +355,0 @@ dom: info.dom

import { ComponentType } from 'react';
import { default as default_2 } from 'react';
import { default as default_3 } from 'react-dom/client';
import { ErrorInfo } from 'react';

@@ -9,6 +8,6 @@ import { PropsWithChildren } from 'react';

export declare function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>): () => {
render(info: RenderFnParams & any): Promise<void>;
render(info: RenderFnParams & any): void;
destroy(info: {
dom: HTMLElement;
}): Promise<void>;
}): void;
rawComponent: React_2.ComponentType<T>;

@@ -24,4 +23,4 @@ __BRIDGE_FN__: (_args: T) => void;

}): (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;

@@ -55,3 +54,2 @@

rootComponent: React_2.ComponentType<T>;
render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
};

@@ -71,4 +69,2 @@

declare type RootType = HTMLElement | default_3.Root;
export { }

@@ -291,46 +291,28 @@ 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 }));
};
return {
async render(info) {
render(info) {
LoggerInstance.log(`createBridgeComponent render Info`, info);
const { name, basename, memoryRoute, ...propsInfo } = info;
if (atLeastReact18(React)) {
if (bridgeInfo == null ? void 0 : bridgeInfo.render) {
Promise.resolve(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
)).then((root) => rootMap.set(info.dom, root));
} else {
const 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(

@@ -351,3 +333,3 @@ RawComponent,

},
async destroy(info) {
destroy(info) {
LoggerInstance.log(`createBridgeComponent destroy Info`, {

@@ -354,0 +336,0 @@ dom: info.dom

@@ -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-20240718080108",
"version": "0.0.0-next-20240722031635",
"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-20240718080108"
"@module-federation/bridge-shared": "0.0.0-next-20240722031635"
},

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc