@module-federation/bridge-vue3 0.0.0-next-20240923065315 → 0.0.0-next-20240923073245
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 +3 -3
- package/dist/index.cjs.js +24 -24
- package/dist/index.d.ts +0 -9
- package/dist/index.es.js +524 -530
- package/package.json +3 -3
- package/src/create.ts +0 -1
- package/src/index.ts +0 -1
- package/src/lifecycle.ts +24 -13
- package/src/remoteApp.tsx +17 -11
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-20240923073245",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"vue": "=3",
|
|
26
26
|
"vue-router": "=3",
|
|
27
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
27
|
+
"@module-federation/runtime": "0.0.0-next-20240923073245"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@module-federation/bridge-shared": "0.0.0-next-
|
|
30
|
+
"@module-federation/bridge-shared": "0.0.0-next-20240923073245"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@vitejs/plugin-vue": "^5.0.4",
|
package/src/create.ts
CHANGED
package/src/index.ts
CHANGED
package/src/lifecycle.ts
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import { getInstance } from '@module-federation/runtime';
|
|
2
2
|
import helper from '@module-federation/runtime/helpers';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
const pluginHelper = helper.global
|
|
6
|
-
const host = getInstance()
|
|
7
|
-
const pluginSystem = new pluginHelper.PluginSystem({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
function registerBridgeLifeCycle() {
|
|
5
|
+
const { registerPlugins, pluginHelper } = helper.global;
|
|
6
|
+
const host = getInstance();
|
|
7
|
+
const pluginSystem = new pluginHelper.PluginSystem({
|
|
8
|
+
beforeBridgeRender: new pluginHelper.SyncHook<
|
|
9
|
+
[Record<string, any>],
|
|
10
|
+
void
|
|
11
|
+
>(),
|
|
12
|
+
beforeBridgeDestroy: new pluginHelper.SyncHook<
|
|
13
|
+
[Record<string, any>],
|
|
14
|
+
void
|
|
15
|
+
>(),
|
|
16
|
+
});
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
if (host) {
|
|
19
|
+
registerPlugins<typeof pluginSystem.lifecycle, typeof pluginSystem>(
|
|
20
|
+
host?.options?.plugins,
|
|
21
|
+
[pluginSystem],
|
|
22
|
+
);
|
|
23
|
+
return pluginSystem;
|
|
24
|
+
}
|
|
16
25
|
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { registerBridgeLifeCycle };
|
package/src/remoteApp.tsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ref, onMounted, onBeforeUnmount, watch, defineComponent } from 'vue';
|
|
2
2
|
import { dispatchPopstateEnv } from '@module-federation/bridge-shared';
|
|
3
3
|
import { useRoute } from 'vue-router';
|
|
4
|
-
|
|
5
|
-
import hook from './lifecycle';
|
|
4
|
+
import { registerBridgeLifeCycle } from './lifecycle';
|
|
6
5
|
import { LoggerInstance } from './utils';
|
|
7
6
|
|
|
8
7
|
export default defineComponent({
|
|
@@ -18,6 +17,7 @@ export default defineComponent({
|
|
|
18
17
|
const providerInfoRef = ref(null);
|
|
19
18
|
const pathname = ref('');
|
|
20
19
|
const route = useRoute();
|
|
20
|
+
const bridgeHook = registerBridgeLifeCycle();
|
|
21
21
|
|
|
22
22
|
const renderComponent = () => {
|
|
23
23
|
const providerReturn = props.providerInfo?.();
|
|
@@ -32,9 +32,12 @@ export default defineComponent({
|
|
|
32
32
|
`createRemoteComponent LazyComponent render >>>`,
|
|
33
33
|
renderProps,
|
|
34
34
|
);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
|
|
36
|
+
if (bridgeHook && bridgeHook?.lifecycle?.beforeBridgeRender) {
|
|
37
|
+
bridgeHook?.lifecycle?.beforeBridgeRender.emit({
|
|
38
|
+
...renderProps,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
38
41
|
providerReturn.render(renderProps);
|
|
39
42
|
};
|
|
40
43
|
|
|
@@ -66,12 +69,15 @@ export default defineComponent({
|
|
|
66
69
|
...props,
|
|
67
70
|
});
|
|
68
71
|
watchStopHandle();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
if (bridgeHook && bridgeHook?.lifecycle?.beforeBridgeRender) {
|
|
73
|
+
bridgeHook?.lifecycle?.beforeBridgeDestroy.emit({
|
|
74
|
+
name: props.moduleName,
|
|
75
|
+
dom: rootRef.value,
|
|
76
|
+
basename: props.basename,
|
|
77
|
+
memoryRoute: props.memoryRoute,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
(providerInfoRef.value as any)?.destroy({ dom: rootRef.value });
|
|
76
82
|
});
|
|
77
83
|
|