Skip to content

Commit e06ff9a

Browse files
committed
feat: load Catalog remote with SFC compatibility
1 parent 4080da3 commit e06ff9a

1 file changed

Lines changed: 30 additions & 14 deletions

File tree

src/views/Catalog.vue

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
11
<script setup lang="ts">
2-
import { defineAsyncComponent } from "vue";
3-
const Catalog = defineAsyncComponent(
4-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
5-
// @ts-ignore
6-
() => import("catalog/Catalog")
7-
);
8-
</script>
9-
10-
<template>
11-
<div>
12-
<Catalog v-if="!!Catalog" />
2+
import { shallowRef, onMounted, h, defineComponent } from "vue";
3+
import { applyDocumentMeta } from "../utils/applyDocumentMeta";
4+
import { createRemoteAppComponent } from "@module-federation/bridge-vue3";
135
14-
<router-link class="btn" to="/player">Player</router-link>
15-
<router-link class="btn" to="/">Landing</router-link>
6+
const innerComp = shallowRef<any>(null);
167
8+
onMounted(() => {
9+
const remoteModule = createRemoteAppComponent({
10+
loader: () => import("catalog/Catalog"),
11+
asyncComponentOptions: {
12+
loadingComponent: defineComponent({
13+
name: "LoadingComponent",
14+
setup() {
15+
return () => h("div", "Loading catalog...");
16+
},
17+
}),
18+
}
19+
});
1720
18-
</div>
21+
innerComp.value = defineComponent({
22+
name: "CatalogRemoteWrapper",
23+
setup() {
24+
applyDocumentMeta({
25+
title: "Moduflix - Início",
26+
description: "Application with Vue.js",
27+
});
1928
29+
return () => h(remoteModule);
30+
},
31+
});
32+
});
33+
</script>
34+
<template>
35+
<component :is="innerComp" v-if="innerComp" />
2036
</template>

0 commit comments

Comments
 (0)