unplugin / unplugin-vue-components

📲 On-demand components auto importing for Vue
https://www.npmjs.com/package/unplugin-vue-components
MIT License
3.65k stars 341 forks source link

Directory prefix doesn't appear to work #774

Closed timothymarois closed 1 week ago

timothymarois commented 1 week ago

Describe the bug

When using this config:

Components({
   directoryAsNamespace: true,
   collapseSamePrefixes: true,
   dirs: [
       './resources/js/Layouts/**',
       './resources/js/Components/**',
   ],
   imports: [
   {
       '@inertiajs/vue3': ['Head', 'Link'],
   },
   ],
   dts: true,
   deep: true,
   resolvers: [
       PrimeVueResolver()
   ]
}),

Components testing with:

/Components/Example/Container.vue and /Components/Other/Container.vue.

These options appear to have no effect. I have checked the components.d.ts file, and it still only includes one of the components with the same name; the other component gets ignored.

directoryAsNamespace: true,
collapseSamePrefixes: true,

error

[unplugin-vue-components] component "Container"(....vue) has naming conflicts with other components, ignored.

How it imports just the single item, adds no prefix or additional component

WHAT IT DOES:

Container: typeof import('./resources/js/Components/Example/Container.vue')['default']

WHAT IT SHOULD DO:

ExampleContainer: typeof import('./resources/js/Components/Example/Container.vue')['default'],
OtherContainer: typeof import('./resources/js/Components/Other/Container.vue')['default']

Everything else works except this config.

Reproduction

/

System Info

Vue 3, basic setup.

Used Package Manager

npm

Validations

timothymarois commented 1 week ago

Found the issue:

Changing this dir, instead of wild as described above, removing the wild and now it works.

dirs: [
    './resources/js/Components/'
],

Strange it does it this way, but solved it after a lot of testing. Can close for now.