@module-federation/bridge-vue3 0.0.0-fix-lazy-comile-20250925082726
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 +693 -0
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/index.cjs +5 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +2528 -0
- package/dist/vite.svg +1 -0
- package/package.json +55 -0
- package/project.json +15 -0
- package/src/assets/vue.svg +1 -0
- package/src/components/HelloWorld.vue +38 -0
- package/src/create.ts +79 -0
- package/src/index.ts +3 -0
- package/src/provider.ts +109 -0
- package/src/remoteApp.tsx +115 -0
- package/src/style.css +79 -0
- package/src/utils.ts +3 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +41 -0
- package/tsconfig.node.json +11 -0
- package/vite.config.ts +30 -0
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@module-federation/bridge-vue3",
|
|
3
|
+
"author": "zhouxiao <codingzx@gmail.com>",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/module-federation/core.git",
|
|
8
|
+
"directory": "packages/bridge/vue3-bridge"
|
|
9
|
+
},
|
|
10
|
+
"version": "0.0.0-fix-lazy-comile-20250925082726",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.cjs",
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/",
|
|
20
|
+
"src/",
|
|
21
|
+
"CHANGELOG.md",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"package.json",
|
|
24
|
+
"project.json",
|
|
25
|
+
"README.md",
|
|
26
|
+
"tsconfig.json",
|
|
27
|
+
"tsconfig.node.json",
|
|
28
|
+
"vite.config.ts"
|
|
29
|
+
],
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"vue": "=3",
|
|
32
|
+
"vue-router": "=4"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@module-federation/bridge-shared": "0.0.0-fix-lazy-comile-20250925082726",
|
|
36
|
+
"@module-federation/runtime": "0.0.0-fix-lazy-comile-20250925082726",
|
|
37
|
+
"@module-federation/sdk": "0.0.0-fix-lazy-comile-20250925082726"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/react": "^18.3.11",
|
|
41
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
|
42
|
+
"@vitejs/plugin-vue-jsx": "^4.0.0",
|
|
43
|
+
"typescript": "^5.2.2",
|
|
44
|
+
"vite": "^5.4.18",
|
|
45
|
+
"vite-plugin-dts": "^4.3.0",
|
|
46
|
+
"vue": "^3.4.21",
|
|
47
|
+
"vue-router": "4.4.5",
|
|
48
|
+
"vue-tsc": "^2.0.6"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"dev": "vite",
|
|
52
|
+
"build": "vite build",
|
|
53
|
+
"preview": "vite preview"
|
|
54
|
+
}
|
|
55
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vue3-bridge",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/bridge/vue3-bridge/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": ["type:pkg"],
|
|
7
|
+
"targets": {
|
|
8
|
+
"build": {
|
|
9
|
+
"executor": "nx:run-commands",
|
|
10
|
+
"options": {
|
|
11
|
+
"commands": ["npm run build --prefix packages/bridge/vue3-bridge"]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
defineProps<{ msg: string }>();
|
|
5
|
+
|
|
6
|
+
const count = ref(0);
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<h1>{{ msg }}</h1>
|
|
11
|
+
|
|
12
|
+
<div class="card">
|
|
13
|
+
<button type="button" @click="count++">count is {{ count }}</button>
|
|
14
|
+
<p>
|
|
15
|
+
Edit
|
|
16
|
+
<code>components/HelloWorld.vue</code> to test HMR
|
|
17
|
+
</p>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<p>
|
|
21
|
+
Check out
|
|
22
|
+
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
|
|
23
|
+
>create-vue</a
|
|
24
|
+
>, the official Vue + Vite starter
|
|
25
|
+
</p>
|
|
26
|
+
<p>
|
|
27
|
+
Install
|
|
28
|
+
<a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
|
|
29
|
+
in your IDE for a better DX
|
|
30
|
+
</p>
|
|
31
|
+
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<style scoped>
|
|
35
|
+
.read-the-docs {
|
|
36
|
+
color: #888;
|
|
37
|
+
}
|
|
38
|
+
</style>
|
package/src/create.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type AsyncComponentOptions, defineAsyncComponent, h } from 'vue';
|
|
2
|
+
import { useRoute } from 'vue-router';
|
|
3
|
+
import RemoteApp from './remoteApp.jsx';
|
|
4
|
+
import { LoggerInstance } from './utils.js';
|
|
5
|
+
|
|
6
|
+
declare const __APP_VERSION__: string;
|
|
7
|
+
|
|
8
|
+
export function createRemoteAppComponent(info: {
|
|
9
|
+
loader: () => Promise<any>;
|
|
10
|
+
export?: string;
|
|
11
|
+
asyncComponentOptions?: Omit<AsyncComponentOptions, 'loader'>;
|
|
12
|
+
rootAttrs?: Record<string, unknown>;
|
|
13
|
+
}) {
|
|
14
|
+
return defineAsyncComponent({
|
|
15
|
+
__APP_VERSION__,
|
|
16
|
+
...info.asyncComponentOptions,
|
|
17
|
+
//@ts-ignore
|
|
18
|
+
loader: async () => {
|
|
19
|
+
const route = useRoute();
|
|
20
|
+
|
|
21
|
+
let basename = '/';
|
|
22
|
+
const matchPath = route?.matched?.[0]?.path;
|
|
23
|
+
if (matchPath) {
|
|
24
|
+
if (matchPath.endsWith('/:pathMatch(.*)*')) {
|
|
25
|
+
basename = matchPath.replace('/:pathMatch(.*)*', '');
|
|
26
|
+
} else {
|
|
27
|
+
basename = route.matched[0].path;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const exportName = info?.export || 'default';
|
|
32
|
+
LoggerInstance.debug(
|
|
33
|
+
`createRemoteAppComponent LazyComponent create >>>`,
|
|
34
|
+
{
|
|
35
|
+
basename,
|
|
36
|
+
info,
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const module: any = await info.loader();
|
|
41
|
+
const moduleName = module && module[Symbol.for('mf_module_id')];
|
|
42
|
+
const exportFn = module[exportName];
|
|
43
|
+
|
|
44
|
+
LoggerInstance.debug(
|
|
45
|
+
`createRemoteAppComponent LazyComponent loadRemote info >>>`,
|
|
46
|
+
{ moduleName, module, exportName, basename, route },
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (exportName in module && typeof exportFn === 'function') {
|
|
50
|
+
return {
|
|
51
|
+
render() {
|
|
52
|
+
return h(RemoteApp, {
|
|
53
|
+
moduleName,
|
|
54
|
+
providerInfo: exportFn,
|
|
55
|
+
basename,
|
|
56
|
+
rootAttrs: info.rootAttrs,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
throw new Error('module not found');
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!
|
|
68
|
+
*/
|
|
69
|
+
export function createRemoteComponent(info: {
|
|
70
|
+
loader: () => Promise<any>;
|
|
71
|
+
export?: string;
|
|
72
|
+
asyncComponentOptions?: Omit<AsyncComponentOptions, 'loader'>;
|
|
73
|
+
rootAttrs?: Record<string, unknown>;
|
|
74
|
+
}) {
|
|
75
|
+
LoggerInstance.warn(
|
|
76
|
+
'createRemoteAppComponent is deprecated, please use createRemoteAppComponent instead!',
|
|
77
|
+
);
|
|
78
|
+
return createRemoteAppComponent(info);
|
|
79
|
+
}
|
package/src/index.ts
ADDED
package/src/provider.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as Vue from 'vue';
|
|
2
|
+
import * as VueRouter from 'vue-router';
|
|
3
|
+
import { RenderFnParams } from '@module-federation/bridge-shared';
|
|
4
|
+
import { LoggerInstance } from './utils';
|
|
5
|
+
import { getInstance } from '@module-federation/runtime';
|
|
6
|
+
|
|
7
|
+
declare const __APP_VERSION__: string;
|
|
8
|
+
|
|
9
|
+
type AddOptionsFnParams = {
|
|
10
|
+
app: Vue.App<Vue.Component>;
|
|
11
|
+
basename: RenderFnParams['basename'];
|
|
12
|
+
memoryRoute: RenderFnParams['memoryRoute'];
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type ProviderFnParams = {
|
|
17
|
+
rootComponent: Vue.Component;
|
|
18
|
+
appOptions: (
|
|
19
|
+
params: AddOptionsFnParams,
|
|
20
|
+
) => { router?: VueRouter.Router } | void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function createBridgeComponent(bridgeInfo: ProviderFnParams) {
|
|
24
|
+
const rootMap = new Map();
|
|
25
|
+
const instance = getInstance();
|
|
26
|
+
return () => {
|
|
27
|
+
return {
|
|
28
|
+
__APP_VERSION__,
|
|
29
|
+
async render(info: RenderFnParams) {
|
|
30
|
+
LoggerInstance.debug(`createBridgeComponent render Info`, info);
|
|
31
|
+
const {
|
|
32
|
+
moduleName,
|
|
33
|
+
dom,
|
|
34
|
+
basename,
|
|
35
|
+
memoryRoute,
|
|
36
|
+
hashRoute,
|
|
37
|
+
...propsInfo
|
|
38
|
+
} = info;
|
|
39
|
+
const app = Vue.createApp(bridgeInfo.rootComponent, propsInfo);
|
|
40
|
+
rootMap.set(dom, app);
|
|
41
|
+
|
|
42
|
+
const beforeBridgeRenderRes =
|
|
43
|
+
await instance?.bridgeHook?.lifecycle?.beforeBridgeRender?.emit(info);
|
|
44
|
+
|
|
45
|
+
const extraProps =
|
|
46
|
+
beforeBridgeRenderRes &&
|
|
47
|
+
typeof beforeBridgeRenderRes === 'object' &&
|
|
48
|
+
beforeBridgeRenderRes?.extraProps
|
|
49
|
+
? beforeBridgeRenderRes?.extraProps
|
|
50
|
+
: {};
|
|
51
|
+
|
|
52
|
+
const bridgeOptions = bridgeInfo.appOptions({
|
|
53
|
+
app,
|
|
54
|
+
basename,
|
|
55
|
+
memoryRoute,
|
|
56
|
+
hashRoute,
|
|
57
|
+
...propsInfo,
|
|
58
|
+
...extraProps,
|
|
59
|
+
});
|
|
60
|
+
if (bridgeOptions?.router) {
|
|
61
|
+
let history;
|
|
62
|
+
let routes = bridgeOptions.router.getRoutes();
|
|
63
|
+
|
|
64
|
+
if (info.memoryRoute) {
|
|
65
|
+
history = VueRouter.createMemoryHistory(info.basename);
|
|
66
|
+
} else if (info.hashRoute) {
|
|
67
|
+
history = VueRouter.createWebHashHistory();
|
|
68
|
+
routes = routes.map((route) => {
|
|
69
|
+
return {
|
|
70
|
+
...route,
|
|
71
|
+
path: info.basename + route.path,
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
history = VueRouter.createWebHistory(info.basename);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const router = VueRouter.createRouter({
|
|
79
|
+
...bridgeOptions.router.options,
|
|
80
|
+
history,
|
|
81
|
+
routes,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
LoggerInstance.debug(`createBridgeComponent render router info>>>`, {
|
|
85
|
+
moduleName,
|
|
86
|
+
router,
|
|
87
|
+
});
|
|
88
|
+
// memory route Initializes the route
|
|
89
|
+
if (memoryRoute) {
|
|
90
|
+
await router.push(memoryRoute.entryPath);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
app.use(router);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
app.mount(dom);
|
|
97
|
+
instance?.bridgeHook?.lifecycle?.afterBridgeRender?.emit(info);
|
|
98
|
+
},
|
|
99
|
+
destroy(info: { dom: HTMLElement }) {
|
|
100
|
+
LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
|
|
101
|
+
const root = rootMap.get(info?.dom);
|
|
102
|
+
|
|
103
|
+
instance?.bridgeHook?.lifecycle?.beforeBridgeDestroy?.emit(info);
|
|
104
|
+
root?.unmount();
|
|
105
|
+
instance?.bridgeHook?.lifecycle?.afterBridgeDestroy?.emit(info);
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
onMounted,
|
|
4
|
+
onBeforeUnmount,
|
|
5
|
+
watch,
|
|
6
|
+
defineComponent,
|
|
7
|
+
useAttrs,
|
|
8
|
+
} from 'vue';
|
|
9
|
+
import { dispatchPopstateEnv } from '@module-federation/bridge-shared';
|
|
10
|
+
import { useRoute } from 'vue-router';
|
|
11
|
+
import { LoggerInstance } from './utils';
|
|
12
|
+
import { getInstance } from '@module-federation/runtime';
|
|
13
|
+
|
|
14
|
+
export default defineComponent({
|
|
15
|
+
name: 'RemoteApp',
|
|
16
|
+
props: {
|
|
17
|
+
moduleName: String,
|
|
18
|
+
basename: String,
|
|
19
|
+
memoryRoute: Object,
|
|
20
|
+
hashRoute: Boolean,
|
|
21
|
+
providerInfo: Function,
|
|
22
|
+
rootAttrs: Object,
|
|
23
|
+
},
|
|
24
|
+
inheritAttrs: false,
|
|
25
|
+
setup(props) {
|
|
26
|
+
const rootRef = ref(null);
|
|
27
|
+
const providerInfoRef = ref(null);
|
|
28
|
+
const pathname = ref('');
|
|
29
|
+
const route = useRoute();
|
|
30
|
+
const hostInstance = getInstance();
|
|
31
|
+
const componentAttrs = useAttrs();
|
|
32
|
+
|
|
33
|
+
const renderComponent = async () => {
|
|
34
|
+
const providerReturn = props.providerInfo?.();
|
|
35
|
+
providerInfoRef.value = providerReturn;
|
|
36
|
+
|
|
37
|
+
let renderProps = {
|
|
38
|
+
...componentAttrs,
|
|
39
|
+
moduleName: props.moduleName,
|
|
40
|
+
dom: rootRef.value,
|
|
41
|
+
basename: props.basename,
|
|
42
|
+
memoryRoute: props.memoryRoute,
|
|
43
|
+
hashRoute: props.hashRoute,
|
|
44
|
+
};
|
|
45
|
+
LoggerInstance.debug(
|
|
46
|
+
`createRemoteAppComponent LazyComponent render >>>`,
|
|
47
|
+
renderProps,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const beforeBridgeRenderRes =
|
|
51
|
+
(await hostInstance?.bridgeHook?.lifecycle?.beforeBridgeRender?.emit(
|
|
52
|
+
renderProps,
|
|
53
|
+
)) || {};
|
|
54
|
+
|
|
55
|
+
renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };
|
|
56
|
+
providerReturn.render(renderProps);
|
|
57
|
+
hostInstance?.bridgeHook?.lifecycle?.afterBridgeRender?.emit(renderProps);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const watchStopHandle = watch(
|
|
61
|
+
() => route?.path,
|
|
62
|
+
(newPath) => {
|
|
63
|
+
if (newPath !== route.path) {
|
|
64
|
+
renderComponent();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// dispatchPopstateEnv
|
|
68
|
+
if (pathname.value !== '' && pathname.value !== newPath) {
|
|
69
|
+
LoggerInstance.debug(
|
|
70
|
+
`createRemoteAppComponent dispatchPopstateEnv >>>`,
|
|
71
|
+
{
|
|
72
|
+
...props,
|
|
73
|
+
pathname: route.path,
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
dispatchPopstateEnv();
|
|
77
|
+
}
|
|
78
|
+
pathname.value = newPath;
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
onMounted(() => {
|
|
83
|
+
renderComponent();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
onBeforeUnmount(() => {
|
|
87
|
+
LoggerInstance.debug(
|
|
88
|
+
`createRemoteAppComponent LazyComponent destroy >>>`,
|
|
89
|
+
{
|
|
90
|
+
...props,
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
watchStopHandle();
|
|
94
|
+
|
|
95
|
+
hostInstance?.bridgeHook?.lifecycle?.beforeBridgeDestroy?.emit({
|
|
96
|
+
name: props.moduleName,
|
|
97
|
+
dom: rootRef.value,
|
|
98
|
+
basename: props.basename,
|
|
99
|
+
memoryRoute: props.memoryRoute,
|
|
100
|
+
hashRoute: props.hashRoute,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
(providerInfoRef.value as any)?.destroy({ dom: rootRef.value });
|
|
104
|
+
hostInstance?.bridgeHook?.lifecycle?.afterBridgeDestroy?.emit({
|
|
105
|
+
name: props.moduleName,
|
|
106
|
+
dom: rootRef.value,
|
|
107
|
+
basename: props.basename,
|
|
108
|
+
memoryRoute: props.memoryRoute,
|
|
109
|
+
hashRoute: props.hashRoute,
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
return () => <div {...(props.rootAttrs || {})} ref={rootRef}></div>;
|
|
114
|
+
},
|
|
115
|
+
});
|
package/src/style.css
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
line-height: 1.5;
|
|
4
|
+
font-weight: 400;
|
|
5
|
+
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
color: rgba(255, 255, 255, 0.87);
|
|
8
|
+
background-color: #242424;
|
|
9
|
+
|
|
10
|
+
font-synthesis: none;
|
|
11
|
+
text-rendering: optimizeLegibility;
|
|
12
|
+
-webkit-font-smoothing: antialiased;
|
|
13
|
+
-moz-osx-font-smoothing: grayscale;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
a {
|
|
17
|
+
font-weight: 500;
|
|
18
|
+
color: #646cff;
|
|
19
|
+
text-decoration: inherit;
|
|
20
|
+
}
|
|
21
|
+
a:hover {
|
|
22
|
+
color: #535bf2;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
body {
|
|
26
|
+
margin: 0;
|
|
27
|
+
display: flex;
|
|
28
|
+
place-items: center;
|
|
29
|
+
min-width: 320px;
|
|
30
|
+
min-height: 100vh;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
h1 {
|
|
34
|
+
font-size: 3.2em;
|
|
35
|
+
line-height: 1.1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
button {
|
|
39
|
+
border-radius: 8px;
|
|
40
|
+
border: 1px solid transparent;
|
|
41
|
+
padding: 0.6em 1.2em;
|
|
42
|
+
font-size: 1em;
|
|
43
|
+
font-weight: 500;
|
|
44
|
+
font-family: inherit;
|
|
45
|
+
background-color: #1a1a1a;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
transition: border-color 0.25s;
|
|
48
|
+
}
|
|
49
|
+
button:hover {
|
|
50
|
+
border-color: #646cff;
|
|
51
|
+
}
|
|
52
|
+
button:focus,
|
|
53
|
+
button:focus-visible {
|
|
54
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.card {
|
|
58
|
+
padding: 2em;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#app {
|
|
62
|
+
max-width: 1280px;
|
|
63
|
+
margin: 0 auto;
|
|
64
|
+
padding: 2rem;
|
|
65
|
+
text-align: center;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@media (prefers-color-scheme: light) {
|
|
69
|
+
:root {
|
|
70
|
+
color: #213547;
|
|
71
|
+
background-color: #ffffff;
|
|
72
|
+
}
|
|
73
|
+
a:hover {
|
|
74
|
+
color: #747bff;
|
|
75
|
+
}
|
|
76
|
+
button {
|
|
77
|
+
background-color: #f9f9f9;
|
|
78
|
+
}
|
|
79
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"useDefineForClassFields": true,
|
|
4
|
+
|
|
5
|
+
/* Bundler mode */
|
|
6
|
+
"allowImportingTsExtensions": true,
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"isolatedModules": true,
|
|
9
|
+
"jsxImportSource": "vue",
|
|
10
|
+
|
|
11
|
+
/* Linting */
|
|
12
|
+
"noUnusedLocals": true,
|
|
13
|
+
"noUnusedParameters": true,
|
|
14
|
+
"noFallthroughCasesInSwitch": true,
|
|
15
|
+
"declaration": true,
|
|
16
|
+
"emitDeclarationOnly": true,
|
|
17
|
+
"outDir": "dist",
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"strict": true,
|
|
20
|
+
"moduleResolution": "node",
|
|
21
|
+
"target": "esnext",
|
|
22
|
+
"module": "esnext",
|
|
23
|
+
"lib": ["esnext", "dom"],
|
|
24
|
+
"jsx": "preserve",
|
|
25
|
+
"esModuleInterop": true,
|
|
26
|
+
"allowSyntheticDefaultImports": true,
|
|
27
|
+
"sourceMap": true,
|
|
28
|
+
"baseUrl": ".",
|
|
29
|
+
"paths": {
|
|
30
|
+
"@/*": ["src/*"]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"include": [
|
|
34
|
+
"src/**/*.ts",
|
|
35
|
+
"src/**/*.tsx",
|
|
36
|
+
"src/**/*.vue",
|
|
37
|
+
"src/remoteApp.tsx",
|
|
38
|
+
"src/create.ts"
|
|
39
|
+
],
|
|
40
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
41
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import vue from '@vitejs/plugin-vue';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import dts from 'vite-plugin-dts';
|
|
5
|
+
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
6
|
+
import packageJson from './package.json';
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [
|
|
10
|
+
vue(),
|
|
11
|
+
dts({
|
|
12
|
+
rollupTypes: true,
|
|
13
|
+
bundledPackages: ['@module-federation/bridge-shared'],
|
|
14
|
+
}),
|
|
15
|
+
vueJsx(),
|
|
16
|
+
],
|
|
17
|
+
build: {
|
|
18
|
+
lib: {
|
|
19
|
+
entry: path.resolve(__dirname, 'src/index.ts'),
|
|
20
|
+
formats: ['cjs', 'es'],
|
|
21
|
+
fileName: 'index',
|
|
22
|
+
},
|
|
23
|
+
rollupOptions: {
|
|
24
|
+
external: ['vue', 'vue-router'],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
define: {
|
|
28
|
+
__APP_VERSION__: JSON.stringify(packageJson.version),
|
|
29
|
+
},
|
|
30
|
+
});
|