Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 tasks done
isabolic opened this issue Jun 3, 2024 · 4 comments
Open
5 tasks done

Comments

@isabolic
Copy link

isabolic commented Jun 3, 2024

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

  • 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.
Copy link

stackblitz bot commented Jun 3, 2024

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

@iyashpal
Copy link

Same here

@SimonGioffredi
Copy link

Same bug

@tryforceful
Copy link

I think you may have misunderstood the intention of this package. Its purpose is to allow exported JS functions, consts, etc. from other files to be auto-imported within Vue etc. components -- not the other way around.

To solve the issue you're having, you should use https://github.com/unplugin/unplugin-vue-components which makes Vue components available in other Vue components without requiring explicit imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants