I'm currently working on integrating unplugin-vue-components
into my project to streamline the process of registering first-party plugin components across all my individual projects. However, I'm encountering difficulties in getting Vite
to properly identify the named/exported Vue Components within my Single File Components (SFCs)...
Here's the error output from the console:
An issue has arisen: The requested module '/flighter/resources/js/components/LinkWrapper.vue' does not have an export named 'FlighterLinkWrapper'. SyntaxError: The requested module '/flighter/resources/js/components/LinkWrapper.vue' does not have an export named 'FlighterLinkWrapper'.
Extract from my generated components.d.ts
file:
// ...
FlighterLink: typeof import('flighter/js/components/Link.vue')['FlighterLink'];
FlighterLinkWrapper: typeof import('flighter/js/components/LinkWrapper.vue')['FlighterLinkWrapper'];
FlighterMapLink: typeof import('flighter/js/components/links/Map.vue')['FlighterMapLink'];
// ...
Snippet from my vite.config.ts
file:
// ...
resolve: {
alias: [
{find: '@js/', replacement: path.resolve(__dirname, `resources/js`) + '/'},
{find: /^@?flighter\//, replacement: path.resolve(__dirname, `flighter/resources`) + '/'}
],
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json']
},
// ...
The content of my
flighter/resources/js/components/LinkWrapper.vue
file is as follows:
<script lang="ts" setup>
// ...
</script>
<script lang="ts">
export default {
name: 'FlighterLinkWrapper'
};
</script>
I have verified that the issue does not lie with the resolution of the Vue SFC itself... it seems to be related to the proper interpretation of the file or a potential mismatch in module names, if that makes sense?
My Development Stack:
Laravel 10
/InertiaJS 1
/VueJS 3
/ViteJS 4
/TailwindCSS 3
/Vitest 0.31
/VitePress 1
/Typescript
/SSR
FontAwesome Pro 6
/Ploi.io
/Qodana
/Cypress
/ImgIX
/HubSpot
/SendGrid
/SignEasy
/Stripe
TL;DR; Has anyone successfully set up unplugin-vue-components
in their projects before?