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
330
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-20241114041727 to 0.0.0-next-20241114065146

dist/context-BBLu8BlQ.cjs

16

CHANGELOG.md
# @module-federation/bridge-react
## 0.0.0-next-20241114041727
## 0.0.0-next-20241114065146
### Patch Changes
- 3082116: feat: feat: support lifecycyle hooks in module-deferation bridge
- Updated dependencies [3082116]
- @module-federation/runtime@0.0.0-next-20241114041727
- @module-federation/sdk@0.0.0-next-20241114041727
- @module-federation/bridge-shared@0.0.0-next-20241114041727
## 0.7.3
### Patch Changes
- Updated dependencies [4ab9295]
- @module-federation/sdk@0.7.3
- @module-federation/bridge-shared@0.7.3
- @module-federation/sdk@0.0.0-next-20241114065146
- @module-federation/bridge-shared@0.0.0-next-20241114065146

@@ -21,0 +11,0 @@ ## 0.7.2

"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const React = require("react");
const context = require("./context-BcJ-YlNr.cjs");
const context = require("./context-BBLu8BlQ.cjs");
const ReactRouterDOM = require("react-router-dom");
const runtime = require("@module-federation/runtime");
const ReactDOM = require("react-dom");

@@ -141,10 +140,7 @@ function _interopNamespaceDefault(e2) {

const providerInfoRef = React.useRef(null);
const hostInstance = runtime.getInstance();
context.LoggerInstance.log(`RemoteAppWrapper hostInstance >>>`, hostInstance);
React.useEffect(() => {
const renderTimeout = setTimeout(() => {
var _a, _b, _c, _d, _e, _f;
const providerReturn = providerInfo();
providerInfoRef.current = providerReturn;
let renderProps = {
const renderProps = {
moduleName,

@@ -162,14 +158,3 @@ dom: rootRef.current,

);
context.LoggerInstance.log(
`createRemoteComponent LazyComponent hostInstance >>>`,
hostInstance
);
const beforeBridgeRenderRes = ((_c = (_b = (_a = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(
renderProps
)) || {};
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
providerReturn.render(renderProps);
(_f = (_e = (_d = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(
renderProps
);
});

@@ -179,3 +164,3 @@ return () => {

setTimeout(() => {
var _a, _b, _c, _d, _e, _f, _g, _h;
var _a, _b;
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {

@@ -186,22 +171,5 @@ context.LoggerInstance.log(

);
(_d = (_c = (_b = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
moduleName,
dom: renderDom.current,
basename,
memoryRoute,
fallback,
...resProps
});
(_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
moduleName,
(_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
dom: renderDom.current
});
(_h = (_g = (_f = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
moduleName,
dom: renderDom.current,
basename,
memoryRoute,
fallback,
...resProps
});
}

@@ -211,7 +179,6 @@ });

}, []);
const rootComponentClassName = `${context.getRootDomDefaultClassName(moduleName)} ${props == null ? void 0 : props.className}`;
return /* @__PURE__ */ React.createElement(
"div",
{
className: rootComponentClassName,
className: props == null ? void 0 : props.className,
style: props == null ? void 0 : props.style,

@@ -222,3 +189,3 @@ ref: rootRef

};
RemoteApp2["__APP_VERSION__"] = "0.7.3";
RemoteApp2["__APP_VERSION__"] = "0.7.2";
return /* @__PURE__ */ React.createElement(RemoteApp2, null);

@@ -375,4 +342,2 @@ });

const rootMap = /* @__PURE__ */ new Map();
const instance = runtime.getInstance();
context.LoggerInstance.log(`createBridgeComponent remote instance`, instance);
const RawComponent = (info) => {

@@ -392,3 +357,2 @@ const { appInfo, propsInfo, ...restProps } = info;

async render(info) {
var _a, _b, _c, _d, _e, _f;
context.LoggerInstance.log(`createBridgeComponent render Info`, info);

@@ -403,3 +367,2 @@ const {

} = info;
const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
const rootComponentWithErrorBoundary = (

@@ -415,3 +378,3 @@ // set ErrorBoundary for RawComponent rendering error, usually caused by user app rendering error

},
propsInfo: { ...propsInfo, ...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps }
propsInfo
}

@@ -434,10 +397,7 @@ ))

}
((_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)) || {};
},
async destroy(info) {
var _a, _b, _c, _d, _e, _f;
context.LoggerInstance.log(`createBridgeComponent destroy Info`, {
dom: info.dom
});
(_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeDestroy) == null ? void 0 : _c.emit(info);
if (context.atLeastReact18(React__namespace)) {

@@ -450,3 +410,2 @@ const root = rootMap.get(info.dom);

}
(_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeDestroy) == null ? void 0 : _f.emit(info);
},

@@ -453,0 +412,0 @@ rawComponent: bridgeInfo.rootComponent,

@@ -9,4 +9,6 @@ import { ComponentType } from 'react';

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

@@ -23,7 +25,2 @@ __BRIDGE_FN__: (_args: T) => void;

declare type DestroyParams = {
moduleName: string;
dom: HTMLElement;
};
declare type ErrorBoundaryPropsWithComponent = ErrorBoundarySharedProps & {

@@ -72,8 +69,4 @@ fallback?: never;

declare type RenderParams = RenderFnParams & {
[key: string]: unknown;
};
declare type RootType = HTMLElement | default_3.Root;
export { }
import * as React from "react";
import React__default, { createContext, Component, createElement, isValidElement, forwardRef, useRef, useEffect, useContext, useState } from "react";
import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin, a as atLeastReact18, R as RouterContext } from "./context-CUbFnlO5.js";
import { L as LoggerInstance, p as pathJoin, a as atLeastReact18, R as RouterContext } from "./context-BcyT-d0V.js";
import * as ReactRouterDOM from "react-router-dom";
import { getInstance } from "@module-federation/runtime";
import ReactDOM from "react-dom";

@@ -122,10 +121,7 @@ const ErrorBoundaryContext = createContext(null);

const providerInfoRef = useRef(null);
const hostInstance = getInstance();
LoggerInstance.log(`RemoteAppWrapper hostInstance >>>`, hostInstance);
useEffect(() => {
const renderTimeout = setTimeout(() => {
var _a, _b, _c, _d, _e, _f;
const providerReturn = providerInfo();
providerInfoRef.current = providerReturn;
let renderProps = {
const renderProps = {
moduleName,

@@ -143,14 +139,3 @@ dom: rootRef.current,

);
LoggerInstance.log(
`createRemoteComponent LazyComponent hostInstance >>>`,
hostInstance
);
const beforeBridgeRenderRes = ((_c = (_b = (_a = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(
renderProps
)) || {};
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
providerReturn.render(renderProps);
(_f = (_e = (_d = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(
renderProps
);
});

@@ -160,3 +145,3 @@ return () => {

setTimeout(() => {
var _a, _b, _c, _d, _e, _f, _g, _h;
var _a, _b;
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {

@@ -167,22 +152,5 @@ LoggerInstance.log(

);
(_d = (_c = (_b = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({
moduleName,
dom: renderDom.current,
basename,
memoryRoute,
fallback,
...resProps
});
(_e = providerInfoRef.current) == null ? void 0 : _e.destroy({
moduleName,
(_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
dom: renderDom.current
});
(_h = (_g = (_f = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({
moduleName,
dom: renderDom.current,
basename,
memoryRoute,
fallback,
...resProps
});
}

@@ -192,7 +160,6 @@ });

}, []);
const rootComponentClassName = `${getRootDomDefaultClassName(moduleName)} ${props == null ? void 0 : props.className}`;
return /* @__PURE__ */ React__default.createElement(
"div",
{
className: rootComponentClassName,
className: props == null ? void 0 : props.className,
style: props == null ? void 0 : props.style,

@@ -203,3 +170,3 @@ ref: rootRef

};
RemoteApp2["__APP_VERSION__"] = "0.7.3";
RemoteApp2["__APP_VERSION__"] = "0.7.2";
return /* @__PURE__ */ React__default.createElement(RemoteApp2, null);

@@ -356,4 +323,2 @@ });

const rootMap = /* @__PURE__ */ new Map();
const instance = getInstance();
LoggerInstance.log(`createBridgeComponent remote instance`, instance);
const RawComponent = (info) => {

@@ -373,3 +338,2 @@ const { appInfo, propsInfo, ...restProps } = info;

async render(info) {
var _a, _b, _c, _d, _e, _f;
LoggerInstance.log(`createBridgeComponent render Info`, info);

@@ -384,3 +348,2 @@ const {

} = info;
const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
const rootComponentWithErrorBoundary = (

@@ -396,3 +359,3 @@ // set ErrorBoundary for RawComponent rendering error, usually caused by user app rendering error

},
propsInfo: { ...propsInfo, ...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps }
propsInfo
}

@@ -415,10 +378,7 @@ ))

}
((_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)) || {};
},
async destroy(info) {
var _a, _b, _c, _d, _e, _f;
LoggerInstance.log(`createBridgeComponent destroy Info`, {
dom: info.dom
});
(_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeDestroy) == null ? void 0 : _c.emit(info);
if (atLeastReact18(React)) {

@@ -431,3 +391,2 @@ const root = rootMap.get(info.dom);

}
(_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeDestroy) == null ? void 0 : _f.emit(info);
},

@@ -434,0 +393,0 @@ rawComponent: bridgeInfo.rootComponent,

@@ -5,3 +5,3 @@ "use strict";

const ReactRouterDom$1 = require("react-router-dom/index.js");
const context = require("./context-BcJ-YlNr.cjs");
const context = require("./context-BBLu8BlQ.cjs");
const ReactRouterDom = require("react-router-dom/index.js");

@@ -8,0 +8,0 @@ function _interopNamespaceDefault(e) {

import React__default, { useContext } from "react";
import * as ReactRouterDom$1 from "react-router-dom/index.js";
import { R as RouterContext, L as LoggerInstance } from "./context-CUbFnlO5.js";
import { R as RouterContext, L as LoggerInstance } from "./context-BcyT-d0V.js";
export * from "react-router-dom/index.js";

@@ -5,0 +5,0 @@ function WraperRouter(props) {

@@ -5,3 +5,3 @@ "use strict";

const ReactRouterDom = require("react-router-dom/dist/index.js");
const context = require("./context-BcJ-YlNr.cjs");
const context = require("./context-BBLu8BlQ.cjs");
function _interopNamespaceDefault(e) {

@@ -8,0 +8,0 @@ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });

import React__default, { useContext } from "react";
import * as ReactRouterDom from "react-router-dom/dist/index.js";
export * from "react-router-dom/dist/index.js";
import { R as RouterContext, L as LoggerInstance } from "./context-CUbFnlO5.js";
import { R as RouterContext, L as LoggerInstance } from "./context-BcyT-d0V.js";
function WraperRouter(props) {

@@ -6,0 +6,0 @@ const { basename, ...propsRes } = props;

@@ -5,3 +5,3 @@ "use strict";

const ReactRouterDom = require("react-router-dom/");
const context = require("./context-BcJ-YlNr.cjs");
const context = require("./context-BBLu8BlQ.cjs");
function _interopNamespaceDefault(e) {

@@ -69,3 +69,3 @@ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });

const BrowserRouterInstance = createBrowserRouter(routers, {
basename: routerContextProps.basename || (router == null ? void 0 : router.basename),
basename: routerContextProps.basename,
future: router.future,

@@ -72,0 +72,0 @@ window: router.window

import React__default, { useContext } from "react";
import * as ReactRouterDom from "react-router-dom/";
export * from "react-router-dom/";
import { R as RouterContext, L as LoggerInstance } from "./context-CUbFnlO5.js";
import { R as RouterContext, L as LoggerInstance } from "./context-BcyT-d0V.js";
function WrapperRouter(props) {

@@ -50,3 +50,3 @@ const { basename, ...propsRes } = props;

const BrowserRouterInstance = createBrowserRouter(routers, {
basename: routerContextProps.basename || (router == null ? void 0 : router.basename),
basename: routerContextProps.basename,
future: router.future,

@@ -53,0 +53,0 @@ window: router.window

{
"name": "@module-federation/bridge-react",
"version": "0.0.0-next-20241114041727",
"version": "0.0.0-next-20241114065146",
"publishConfig": {

@@ -44,5 +44,4 @@ "access": "public"

"react-error-boundary": "^4.0.13",
"@module-federation/bridge-shared": "0.0.0-next-20241114041727",
"@module-federation/sdk": "0.0.0-next-20241114041727",
"@module-federation/runtime": "0.0.0-next-20241114041727"
"@module-federation/bridge-shared": "0.0.0-next-20241114065146",
"@module-federation/sdk": "0.0.0-next-20241114065146"
},

@@ -49,0 +48,0 @@ "peerDependencies": {

import React from 'react';
import { FederationHost } from '@module-federation/runtime';
import { createLogger } from '@module-federation/sdk';

@@ -45,22 +44,1 @@

}
export const getModuleName = (id: string) => {
if (!id) {
return id;
}
// separate module name without detailed module path
// @vmok-e2e/edenx-demo-app2/button -> @vmok-e2e/edenx-demo-app2
const idArray = id.split('/');
if (idArray.length < 2) {
return id;
}
return idArray[0] + '/' + idArray[1];
};
export const getRootDomDefaultClassName = (moduleName: string) => {
if (!moduleName) {
return '';
}
const name = getModuleName(moduleName).replace(/\@/, '').replace(/\//, '-');
return `bridge-root-component-${name}`;
};

@@ -39,3 +39,2 @@ import { defineConfig } from 'vite';

'react-router-dom/dist/index.js',
'@module-federation/runtime',
],

@@ -42,0 +41,0 @@ plugins: [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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