Skip to content

Components that are directly exported in index file that imported from a module will not be scanned #884

@sadeghbarati

Description

@sadeghbarati

Describe the bug

Here is scanning example, if you check the StackBlitz playground would be better to understand

components/ui/form/index.ts:

export { default as FormControl } from "./FormControl.vue" // scanned ✅ 
export { default as FormDescription } from "./FormDescription.vue" // scanned ✅ 
export { default as FormItem } from "./FormItem.vue" // scanned ✅ 
export { default as FormLabel } from "./FormLabel.vue" // scanned ✅ 
export { default as FormMessage } from "./FormMessage.vue" // scanned ✅ 
export { FORM_ITEM_INJECTION_KEY } from "./injectionKeys" // scanned but need to excluded by default when it's not Vue component ❌  
export { Form, Field as FormField, FieldArray as FormFieldArray } from "vee-validate" // not scanned ❌ 
// also there is a useFormField.ts which also scanned as Vue component ❌ 

components.d.ts:

/* eslint-disable */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
// biome-ignore lint: disable
export {}

/* prettier-ignore */
declare module 'vue' {
  export interface GlobalComponents {
    AppButton: typeof import('./src/components/ui/button/Button.vue')['default']
    AppForm: typeof import('./src/components/ui/form/index.ts')['default']
    AppFormControl: typeof import('./src/components/ui/form/FormControl.vue')['default']
    AppFormDescription: typeof import('./src/components/ui/form/FormDescription.vue')['default']
    AppFormItem: typeof import('./src/components/ui/form/FormItem.vue')['default']
    AppFormLabel: typeof import('./src/components/ui/form/FormLabel.vue')['default']
    AppFormMessage: typeof import('./src/components/ui/form/FormMessage.vue')['default']
    AppInjectionKeys: typeof import('./src/components/ui/form/injectionKeys.ts')['default']
    AppLabel: typeof import('./src/components/ui/label/Label.vue')['default']
    AppUseFormField: typeof import('./src/components/ui/form/useFormField.ts')['default']
  }
}

Here is the related issue form shadcn-vue: unovue/shadcn-vue#172

Which caused us to create shadcn-nuxt module
shadcn-nuxt will tell Nuxt to not scan the specified directory like ui for auto imports as we will do it manually with oxc-parser

But issue yet exists in Vue projects with unplugin-vue-components


isVNode logic from Vue can't be ported/used in unplugin-vue-components to check Vue components?


Related discussions in shadcn-vue unovue/shadcn-vue#678

Reproduction

https://stackblitz.com/edit/vitejs-vite-rwlvdb8u

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12400
    Memory: 6.09 GB / 15.75 GB
  Binaries:
    Node: 22.19.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.9.3 - C:\Program Files\nodejs\npm.CMD
    pnpm: 10.17.1 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (140.0.3485.54)
    Internet Explorer: 11.0.26100.1882

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions