@module-federation/bridge-vue3
Advanced tools
Comparing version 0.0.0-next-20241216131539 to 0.0.0-next-20241218082038
# @module-federation/bridge-vue3 | ||
## 0.0.0-next-20241216131539 | ||
## 0.0.0-next-20241218082038 | ||
### Patch Changes | ||
- @module-federation/runtime@0.0.0-next-20241216131539 | ||
- @module-federation/sdk@0.0.0-next-20241216131539 | ||
- @module-federation/bridge-shared@0.0.0-next-20241216131539 | ||
- Updated dependencies [b7905dc] | ||
- @module-federation/sdk@0.0.0-next-20241218082038 | ||
- @module-federation/runtime@0.0.0-next-20241218082038 | ||
- @module-federation/bridge-shared@0.0.0-next-20241218082038 | ||
## 0.8.5 | ||
### Patch Changes | ||
- d161cbe: 1. Added type annotations for the argument in the `createBridgeComponent` function. 2. Added passing the instance of the created Vue-application to `appOptions` so that necessary plugins can be registered in this callback. 3. Made `router` returned from `appOptions` optional. 4. Fixed issues reported by TypeScript and ESLint, including allowing `beforeBridgeRenderRes` to be a promise. 5. Updated the documentation. | ||
- @module-federation/runtime@0.8.5 | ||
- @module-federation/sdk@0.8.5 | ||
- @module-federation/bridge-shared@0.8.5 | ||
## 0.8.4 | ||
@@ -12,0 +22,0 @@ |
import { AsyncComponentOptions } from 'vue'; | ||
import { ComponentPublicInstance } from 'vue'; | ||
import * as Vue from 'vue'; | ||
import * as VueRouter from 'vue-router'; | ||
export declare function createBridgeComponent(bridgeInfo: any): () => { | ||
declare type AddOptionsFnParams = { | ||
app: Vue.App<Vue.Component>; | ||
basename: RenderFnParams['basename']; | ||
memoryRoute: RenderFnParams['memoryRoute']; | ||
[key: string]: any; | ||
}; | ||
export declare function createBridgeComponent(bridgeInfo: ProviderFnParams): () => { | ||
__APP_VERSION__: string; | ||
render(info: RenderFnParams): void; | ||
render(info: RenderFnParams): Promise<void>; | ||
destroy(info: { | ||
@@ -18,2 +27,9 @@ dom: HTMLElement; | ||
declare type ProviderFnParams = { | ||
rootComponent: Vue.Component; | ||
appOptions: (params: AddOptionsFnParams) => { | ||
router?: VueRouter.Router; | ||
} | void; | ||
}; | ||
declare interface ProviderParams { | ||
@@ -20,0 +36,0 @@ moduleName?: string; |
@@ -10,3 +10,3 @@ { | ||
}, | ||
"version": "0.0.0-next-20241216131539", | ||
"version": "0.0.0-next-20241218082038", | ||
"publishConfig": { | ||
@@ -36,5 +36,5 @@ "access": "public" | ||
"dependencies": { | ||
"@module-federation/bridge-shared": "0.0.0-next-20241216131539", | ||
"@module-federation/sdk": "0.0.0-next-20241216131539", | ||
"@module-federation/runtime": "0.0.0-next-20241216131539" | ||
"@module-federation/bridge-shared": "0.0.0-next-20241218082038", | ||
"@module-federation/sdk": "0.0.0-next-20241218082038", | ||
"@module-federation/runtime": "0.0.0-next-20241218082038" | ||
}, | ||
@@ -41,0 +41,0 @@ "devDependencies": { |
@@ -9,3 +9,17 @@ import * as Vue from 'vue'; | ||
export function createBridgeComponent(bridgeInfo: any) { | ||
type AddOptionsFnParams = { | ||
app: Vue.App<Vue.Component>; | ||
basename: RenderFnParams['basename']; | ||
memoryRoute: RenderFnParams['memoryRoute']; | ||
[key: string]: any; | ||
}; | ||
export type ProviderFnParams = { | ||
rootComponent: Vue.Component; | ||
appOptions: ( | ||
params: AddOptionsFnParams, | ||
) => { router?: VueRouter.Router } | void; | ||
}; | ||
export function createBridgeComponent(bridgeInfo: ProviderFnParams) { | ||
const rootMap = new Map(); | ||
@@ -16,3 +30,3 @@ const instance = getInstance(); | ||
__APP_VERSION__, | ||
render(info: RenderFnParams) { | ||
async render(info: RenderFnParams) { | ||
LoggerInstance.log(`createBridgeComponent render Info`, info); | ||
@@ -23,3 +37,3 @@ const app = Vue.createApp(bridgeInfo.rootComponent); | ||
const beforeBridgeRenderRes = | ||
instance?.bridgeHook?.lifecycle?.beforeBridgeRender?.emit(info) || {}; | ||
await instance?.bridgeHook?.lifecycle?.beforeBridgeRender?.emit(info); | ||
@@ -33,3 +47,4 @@ const extraProps = | ||
const appOptions = bridgeInfo.appOptions({ | ||
const bridgeOptions = bridgeInfo.appOptions({ | ||
app, | ||
basename: info.basename, | ||
@@ -40,28 +55,27 @@ memoryRoute: info.memoryRoute, | ||
const history = info.memoryRoute | ||
? VueRouter.createMemoryHistory(info.basename) | ||
: VueRouter.createWebHistory(info.basename); | ||
if (bridgeOptions?.router) { | ||
const history = info.memoryRoute | ||
? VueRouter.createMemoryHistory(info.basename) | ||
: VueRouter.createWebHistory(info.basename); | ||
const router = VueRouter.createRouter({ | ||
...appOptions.router.options, | ||
history, | ||
routes: appOptions.router.getRoutes(), | ||
}); | ||
const router = VueRouter.createRouter({ | ||
...bridgeOptions.router.options, | ||
history, | ||
routes: bridgeOptions.router.getRoutes(), | ||
}); | ||
LoggerInstance.log(`createBridgeComponent render router info>>>`, { | ||
name: info.moduleName, | ||
router, | ||
}); | ||
// memory route Initializes the route | ||
if (info.memoryRoute) { | ||
router.push(info.memoryRoute.entryPath).then(() => { | ||
app.use(router); | ||
app.mount(info.dom); | ||
LoggerInstance.log(`createBridgeComponent render router info>>>`, { | ||
name: info.moduleName, | ||
router, | ||
}); | ||
} else { | ||
// memory route Initializes the route | ||
if (info.memoryRoute) { | ||
await router.push(info.memoryRoute.entryPath); | ||
} | ||
app.use(router); | ||
app.mount(info.dom); | ||
} | ||
instance?.bridgeHook?.lifecycle?.afterBridgeRender?.emit(info) || {}; | ||
app.mount(info.dom); | ||
instance?.bridgeHook?.lifecycle?.afterBridgeRender?.emit(info); | ||
}, | ||
@@ -68,0 +82,0 @@ destroy(info: { dom: HTMLElement }) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
179238
3293
+ Added@module-federation/bridge-shared@0.0.0-next-20241218082038(transitive)
+ Added@module-federation/error-codes@0.0.0-next-20241218082038(transitive)
+ Added@module-federation/runtime@0.0.0-next-20241218082038(transitive)
+ Added@module-federation/sdk@0.0.0-next-20241218082038(transitive)
- Removed@module-federation/bridge-shared@0.0.0-next-20241216131539(transitive)
- Removed@module-federation/error-codes@0.0.0-next-20241216131539(transitive)
- Removed@module-federation/runtime@0.0.0-next-20241216131539(transitive)
- Removed@module-federation/sdk@0.0.0-next-20241216131539(transitive)
Updated@module-federation/bridge-shared@0.0.0-next-20241218082038