@module-federation/bridge-vue3 0.0.0-next-20240830100524 → 0.0.0-next-20240902075042
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -6
- package/dist/index.cjs.js +3 -59
- package/dist/index.es.js +87 -2481
- package/package.json +3 -4
- package/src/create.ts +1 -4
- package/src/provider.ts +0 -4
- package/src/remoteApp.tsx +3 -8
- package/src/lifecycle.ts +0 -21
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/bridge-vue3",
|
|
3
3
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
4
|
-
"version": "0.0.0-next-
|
|
4
|
+
"version": "0.0.0-next-20240902075042",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -23,11 +23,10 @@
|
|
|
23
23
|
],
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"vue": "=3",
|
|
26
|
-
"vue-router": "=3"
|
|
27
|
-
"@module-federation/runtime": "0.0.0-next-20240830100524"
|
|
26
|
+
"vue-router": "=3"
|
|
28
27
|
},
|
|
29
28
|
"dependencies": {
|
|
30
|
-
"@module-federation/bridge-shared": "0.0.0-next-
|
|
29
|
+
"@module-federation/bridge-shared": "0.0.0-next-20240902075042"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
32
|
"@vitejs/plugin-vue": "^5.0.4",
|
package/src/create.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { defineAsyncComponent, h } from 'vue';
|
|
2
|
-
import { useRoute } from 'vue-router';
|
|
3
|
-
|
|
4
2
|
import RemoteApp from './remoteApp.jsx';
|
|
5
3
|
import { LoggerInstance } from './utils.js';
|
|
6
|
-
import
|
|
4
|
+
import { useRoute } from 'vue-router';
|
|
7
5
|
|
|
8
6
|
declare const __APP_VERSION__: string;
|
|
9
7
|
|
|
@@ -34,7 +32,6 @@ export function createRemoteComponent(info: {
|
|
|
34
32
|
});
|
|
35
33
|
|
|
36
34
|
const module: any = await info.loader();
|
|
37
|
-
await hook.lifecycle.beforeBridgeRender.emit({});
|
|
38
35
|
const moduleName = module && module[Symbol.for('mf_module_id')];
|
|
39
36
|
const exportFn = module[exportName];
|
|
40
37
|
|
package/src/provider.ts
CHANGED
|
@@ -11,7 +11,6 @@ export function createBridgeComponent(bridgeInfo: any) {
|
|
|
11
11
|
return {
|
|
12
12
|
__APP_VERSION__,
|
|
13
13
|
render(info: RenderFnParams) {
|
|
14
|
-
bridgeInfo?.beforeRender?.(info);
|
|
15
14
|
LoggerInstance.log(`createBridgeComponent render Info`, info);
|
|
16
15
|
const app = Vue.createApp(bridgeInfo.rootComponent);
|
|
17
16
|
rootMap.set(info.dom, app);
|
|
@@ -43,14 +42,11 @@ export function createBridgeComponent(bridgeInfo: any) {
|
|
|
43
42
|
app.use(router);
|
|
44
43
|
app.mount(info.dom);
|
|
45
44
|
}
|
|
46
|
-
bridgeInfo?.afterRender?.(info);
|
|
47
45
|
},
|
|
48
46
|
destroy(info: { dom: HTMLElement }) {
|
|
49
|
-
bridgeInfo?.beforeDestroy?.(info);
|
|
50
47
|
LoggerInstance.log(`createBridgeComponent destroy Info`, info);
|
|
51
48
|
const root = rootMap.get(info?.dom);
|
|
52
49
|
root?.unmount();
|
|
53
|
-
bridgeInfo?.afterDestroy?.(info);
|
|
54
50
|
},
|
|
55
51
|
};
|
|
56
52
|
};
|
package/src/remoteApp.tsx
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ref, onMounted, onBeforeUnmount, watch, defineComponent } from 'vue';
|
|
2
|
-
import { dispatchPopstateEnv } from '@module-federation/bridge-shared';
|
|
3
2
|
import { useRoute } from 'vue-router';
|
|
4
|
-
|
|
5
3
|
import { LoggerInstance } from './utils';
|
|
6
|
-
import
|
|
4
|
+
import { dispatchPopstateEnv } from '@module-federation/bridge-shared';
|
|
7
5
|
|
|
8
6
|
export default defineComponent({
|
|
9
7
|
name: 'RemoteApp',
|
|
@@ -54,19 +52,16 @@ export default defineComponent({
|
|
|
54
52
|
},
|
|
55
53
|
);
|
|
56
54
|
|
|
57
|
-
onMounted(
|
|
55
|
+
onMounted(() => {
|
|
58
56
|
renderComponent();
|
|
59
|
-
await hook.lifecycle.afterBridgeRender.emit({});
|
|
60
57
|
});
|
|
61
58
|
|
|
62
|
-
onBeforeUnmount(
|
|
63
|
-
await hook.lifecycle.beforeBridgeDestroy.emit({});
|
|
59
|
+
onBeforeUnmount(() => {
|
|
64
60
|
LoggerInstance.log(`createRemoteComponent LazyComponent destroy >>>`, {
|
|
65
61
|
...props,
|
|
66
62
|
});
|
|
67
63
|
watchStopHandle();
|
|
68
64
|
(providerInfoRef.value as any)?.destroy({ dom: rootRef.value });
|
|
69
|
-
await hook.lifecycle.afterBridgeDestroy.emit({});
|
|
70
65
|
});
|
|
71
66
|
|
|
72
67
|
return () => <div ref={rootRef}></div>;
|
package/src/lifecycle.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getInstance } from '@module-federation/runtime';
|
|
2
|
-
import helper from '@module-federation/runtime/helpers';
|
|
3
|
-
|
|
4
|
-
const registerPlugin = helper.global.registerPlugins;
|
|
5
|
-
const pluginHelper = helper.global.pluginHelper;
|
|
6
|
-
const host = getInstance()!;
|
|
7
|
-
const pluginSystem = new pluginHelper.PluginSystem({
|
|
8
|
-
beforeBridgeRender: new pluginHelper.AsyncWaterfallHook('beforeBridgeRender'),
|
|
9
|
-
afterBridgeRender: new pluginHelper.AsyncWaterfallHook('afterBridgeRender'),
|
|
10
|
-
beforeBridgeDestroy: new pluginHelper.AsyncWaterfallHook(
|
|
11
|
-
'beforeBridgeDestroy',
|
|
12
|
-
),
|
|
13
|
-
afterBridgeDestroy: new pluginHelper.AsyncWaterfallHook('afterBridgeDestroy'),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
registerPlugin<typeof pluginSystem.lifecycle, typeof pluginSystem>(
|
|
17
|
-
host.options.plugins,
|
|
18
|
-
[pluginSystem],
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export default pluginSystem;
|