Skip to content

Commit

Permalink
Fix resource loader importing components
Browse files Browse the repository at this point in the history
  • Loading branch information
silverbackdan committed May 8, 2023
1 parent d2fcd56 commit d77ac94
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 69 deletions.
62 changes: 0 additions & 62 deletions playground/cwa/components/Nailing it with Nuxt

This file was deleted.

6 changes: 4 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ export const options:CwaModuleOptions = ${JSON.stringify(options, undefined, 2)}
// component dirs to be configured by application
dirs.unshift({
path: resolve(join(nuxt.options.srcDir, 'cwa', 'pages')),
prefix: 'CwaPages'
prefix: 'CwaPages',
global: true
})
dirs.unshift({
path: resolve(join(nuxt.options.srcDir, 'cwa', 'components')),
prefix: 'CwaComponents'
prefix: 'CwaComponents',
global: true
})
})
}
Expand Down
11 changes: 6 additions & 5 deletions src/runtime/templates/components/core/ResourceLoader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
</template>
<script setup>
import { computed, onMounted, watch } from 'vue'
import { computed, onMounted, watch, getCurrentInstance } from 'vue'
import { useNuxtApp } from '#app'
import { CwaResourceApiStatuses } from '../../../storage/stores/resources/state'
import { CwaAuthStatus } from '../../../api/auth'
import * as components from '#components'
const { $cwa } = useNuxtApp()
Expand Down Expand Up @@ -74,11 +73,13 @@ const resolvedComponent = computed(() => {
return props.uiComponent
}
if (!Object.keys(components).includes(uiComponent.value)) {
const instance = getCurrentInstance()
if (typeof instance?.appContext.components !== 'object' || !(uiComponent.value in instance.appContext.components)) {
return
}
// eslint-disable-next-line import/namespace
return components[uiComponent.value]
return uiComponent.value
})
onMounted(() => {
Expand Down

0 comments on commit d77ac94

Please sign in to comment.