Open
Description
Related plugins
Describe the bug
When you create a component with reactivity the component will have a field __name
that basically boils down to filename.match(/([^/\\]+)\.\w+$/
(relevant source from vuejs/vue).
But I noticed that if the <script setup>
is empty or missing then the __name
field is absent.
However, the other meta fields __file
are always present.
Understanding this is entirely internal behaviour, the inconsistency is annoying and leaves a gap that could otherwise still be useful to developers (specifically devtools and other meta tools).
As immediate remedy the __name
field could be set whereever __file
is provided already.
Reproduction
https://stackblitz.com/edit/vitejs-vite-6zx8jk?file=src%2FApp.vue
Steps to reproduce
- Have a component with an empty
<script setup>
section, and no<script>
section. - Print out the
__name
and__file
fields of the component. - Notice that
__file
is provided, but__name
is not.
System Info
System:
OS: macOS 14.2.1
CPU: (10) arm64 Apple M1 Pro
Memory: 534.39 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
pnpm: 8.10.2 - /opt/homebrew/bin/pnpm
Browsers:
Brave Browser: 120.1.61.109
Safari: 17.2.1
npmPackages:
@vitejs/plugin-vue: ^4.5.0 => 4.5.0
vite: ^5.0.0 => 5.0.2
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.