unplugin / unplugin-auto-import

Auto import APIs on-demand for Vite, Webpack and Rollup
MIT License
3.07k stars 191 forks source link

Auto imports don't work in the script setup template without the options API #507

Open isabolic opened 1 month ago

isabolic commented 1 month ago

Describe the bug

Auto imports don't work in the script setup template without the options API, I am guessing that this is because export default

Vue components are not registered inside auto-imports.d.ts without export default defineComponent({});

example is in here

CompA is registered while CompB is not

also sometimes you need to restart vite server after adding/removing export default defineComponent({});

Reproduction

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

System Info

System:
    OS: macOS 14.4
    CPU: (10) arm64 Apple M1 Pro
    Memory: 90.45 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
    pnpm: 9.1.0 - ~/.nvm/versions/node/v18.12.1/bin/pnpm
  Browsers:
    Brave Browser: 124.1.65.133
    Chrome: 125.0.6422.113
    Edge: 125.0.2535.79
    Safari: 17.4
    Safari Technology Preview: 17.4

Used Package Manager

npm

Validations

stackblitz[bot] commented 1 month ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.