@module-federation/bridge-react
Advanced tools
Comparing version 0.7.6 to 0.7.7
# @module-federation/bridge-react | ||
## 0.7.7 | ||
### Patch Changes | ||
- ae5ee1e: feat: mount bridge api to module instance | ||
- @module-federation/sdk@0.7.7 | ||
- @module-federation/bridge-shared@0.7.7 | ||
## 0.7.6 | ||
@@ -4,0 +12,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
const ReactRouterDOM = require("react-router-dom"); | ||
const runtime = require("@module-federation/runtime"); | ||
const plugin = require("./plugin.cjs.js"); | ||
const ReactDOM = require("react-dom"); | ||
@@ -139,7 +139,7 @@ function _interopNamespaceDefault(e2) { | ||
} = props; | ||
const instance = plugin.federationRuntime.instance; | ||
const rootRef = ref && "current" in ref ? ref : React.useRef(null); | ||
const renderDom = React.useRef(null); | ||
const providerInfoRef = React.useRef(null); | ||
const hostInstance = runtime.getInstance(); | ||
context.LoggerInstance.log(`RemoteAppWrapper hostInstance >>>`, hostInstance); | ||
context.LoggerInstance.log(`RemoteAppWrapper instance from props >>>`, instance); | ||
React.useEffect(() => { | ||
@@ -165,5 +165,5 @@ const renderTimeout = setTimeout(() => { | ||
`createRemoteComponent LazyComponent hostInstance >>>`, | ||
hostInstance | ||
instance | ||
); | ||
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( | ||
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( | ||
renderProps | ||
@@ -173,5 +173,3 @@ )) || {}; | ||
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 | ||
); | ||
(_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps); | ||
}); | ||
@@ -187,3 +185,3 @@ return () => { | ||
); | ||
(_d = (_c = (_b = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({ | ||
(_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({ | ||
moduleName, | ||
@@ -200,3 +198,3 @@ 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({ | ||
(_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({ | ||
moduleName, | ||
@@ -223,3 +221,3 @@ dom: renderDom.current, | ||
}; | ||
RemoteApp2["__APP_VERSION__"] = "0.7.6"; | ||
RemoteApp2["__APP_VERSION__"] = "0.7.7"; | ||
return /* @__PURE__ */ React.createElement(RemoteApp2, null); | ||
@@ -376,4 +374,7 @@ }); | ||
const rootMap = /* @__PURE__ */ new Map(); | ||
const instance = runtime.getInstance(); | ||
context.LoggerInstance.log(`createBridgeComponent remote instance`, instance); | ||
const instance = plugin.federationRuntime.instance; | ||
context.LoggerInstance.log( | ||
`createBridgeComponent instance from props >>>`, | ||
instance | ||
); | ||
const RawComponent = (info) => { | ||
@@ -380,0 +381,0 @@ const { appInfo, propsInfo, ...restProps } = info; |
@@ -15,8 +15,3 @@ import { ComponentType } from 'react'; | ||
export declare function createRemoteComponent<T, E extends keyof T>(info: { | ||
loader: () => Promise<T>; | ||
loading: default_2.ReactNode; | ||
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent']; | ||
export?: E; | ||
}): default_2.ForwardRefExoticComponent<default_2.PropsWithoutRef<ProviderParams & ("__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.RefAttributes<HTMLDivElement>>; | ||
export declare function createRemoteComponent<T, E extends keyof T>(info: LazyRemoteComponentInfo<T, E>): default_2.ForwardRefExoticComponent<default_2.PropsWithoutRef<ProviderParams & ("__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.RefAttributes<HTMLDivElement>>; | ||
@@ -52,2 +47,9 @@ declare type DestroyParams = { | ||
declare type LazyRemoteComponentInfo<T, E extends keyof T> = { | ||
loader: () => Promise<T>; | ||
loading: default_2.ReactNode; | ||
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent']; | ||
export?: E; | ||
}; | ||
declare type ProviderFnParams<T> = { | ||
@@ -54,0 +56,0 @@ rootComponent: React_2.ComponentType<T>; |
@@ -5,3 +5,3 @@ import * as React from "react"; | ||
import * as ReactRouterDOM from "react-router-dom"; | ||
import { getInstance } from "@module-federation/runtime"; | ||
import { federationRuntime } from "./plugin.es.js"; | ||
import ReactDOM from "react-dom"; | ||
@@ -120,7 +120,7 @@ const ErrorBoundaryContext = createContext(null); | ||
} = props; | ||
const instance = federationRuntime.instance; | ||
const rootRef = ref && "current" in ref ? ref : useRef(null); | ||
const renderDom = useRef(null); | ||
const providerInfoRef = useRef(null); | ||
const hostInstance = getInstance(); | ||
LoggerInstance.log(`RemoteAppWrapper hostInstance >>>`, hostInstance); | ||
LoggerInstance.log(`RemoteAppWrapper instance from props >>>`, instance); | ||
useEffect(() => { | ||
@@ -146,5 +146,5 @@ const renderTimeout = setTimeout(() => { | ||
`createRemoteComponent LazyComponent hostInstance >>>`, | ||
hostInstance | ||
instance | ||
); | ||
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( | ||
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( | ||
renderProps | ||
@@ -154,5 +154,3 @@ )) || {}; | ||
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 | ||
); | ||
(_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps); | ||
}); | ||
@@ -168,3 +166,3 @@ return () => { | ||
); | ||
(_d = (_c = (_b = hostInstance == null ? void 0 : hostInstance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({ | ||
(_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({ | ||
moduleName, | ||
@@ -181,3 +179,3 @@ 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({ | ||
(_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({ | ||
moduleName, | ||
@@ -204,3 +202,3 @@ dom: renderDom.current, | ||
}; | ||
RemoteApp2["__APP_VERSION__"] = "0.7.6"; | ||
RemoteApp2["__APP_VERSION__"] = "0.7.7"; | ||
return /* @__PURE__ */ React__default.createElement(RemoteApp2, null); | ||
@@ -357,4 +355,7 @@ }); | ||
const rootMap = /* @__PURE__ */ new Map(); | ||
const instance = getInstance(); | ||
LoggerInstance.log(`createBridgeComponent remote instance`, instance); | ||
const instance = federationRuntime.instance; | ||
LoggerInstance.log( | ||
`createBridgeComponent instance from props >>>`, | ||
instance | ||
); | ||
const RawComponent = (info) => { | ||
@@ -361,0 +362,0 @@ const { appInfo, propsInfo, ...restProps } = info; |
{ | ||
"name": "@module-federation/bridge-react", | ||
"version": "0.7.6", | ||
"version": "0.7.7", | ||
"publishConfig": { | ||
@@ -29,2 +29,7 @@ "access": "public" | ||
}, | ||
"./plugin": { | ||
"types": "./dist/plugin.d.ts", | ||
"import": "./dist/plugin.es.js", | ||
"require": "./dist/plugin.es.js" | ||
}, | ||
"./router-v5": { | ||
@@ -45,5 +50,4 @@ "types": "./dist/router-v5.d.ts", | ||
"react-error-boundary": "^4.0.13", | ||
"@module-federation/bridge-shared": "0.7.6", | ||
"@module-federation/sdk": "0.7.6", | ||
"@module-federation/runtime": "0.7.6" | ||
"@module-federation/bridge-shared": "0.7.7", | ||
"@module-federation/sdk": "0.7.7" | ||
}, | ||
@@ -68,3 +72,4 @@ "peerDependencies": { | ||
"vite": "^5.2.14", | ||
"vite-plugin-dts": "^3.9.1" | ||
"vite-plugin-dts": "^4.3.0", | ||
"@module-federation/runtime": "0.7.7" | ||
}, | ||
@@ -71,0 +76,0 @@ "scripts": { |
@@ -24,2 +24,3 @@ import { defineConfig } from 'vite'; | ||
index: path.resolve(__dirname, 'src/index.ts'), | ||
plugin: path.resolve(__dirname, 'src/plugin.ts'), | ||
router: path.resolve(__dirname, 'src/router.tsx'), | ||
@@ -40,3 +41,2 @@ 'router-v5': path.resolve(__dirname, 'src/router-v5.tsx'), | ||
'react-router-dom/dist/index.js', | ||
'@module-federation/runtime', | ||
], | ||
@@ -43,0 +43,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
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
116761
7
41
3164
14
+ Added@module-federation/bridge-shared@0.7.7(transitive)
+ Added@module-federation/sdk@0.7.7(transitive)
- Removed@module-federation/runtime@0.7.6
- Removed@module-federation/bridge-shared@0.7.6(transitive)
- Removed@module-federation/error-codes@0.7.6(transitive)
- Removed@module-federation/runtime@0.7.6(transitive)
- Removed@module-federation/sdk@0.7.6(transitive)
Updated@module-federation/sdk@0.7.7