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

SFC components without or with empty script tag don't have a name #12810

Open
markbrockhoff opened this issue Feb 3, 2025 · 0 comments
Open

Comments

@markbrockhoff
Copy link

Vue version

3.5.13

Link to minimal reproduction

https://play.vuejs.org/#eNp9Us1OAjEQfpWxZ3aJQS8ESNRwkIMawVsT0+wOS6HbNv1ZSAjv7rQryMFwaabfT+eb2T2yJ2vLLiIbs8ldUcCXrkzbog4QNgi+ctJSKRoQugZlzA5ETy2WYGKwMZSwoiu5rNHJt5dKJYUGhxXKDrNcixaBp26cQVHMuE7t6PxtoYRuppwFT7THEC0pKqM9NUM6puRdG8MZOYa9hQT5HUICtlaJgHQDmNSyg1wBrMibsSGBM4DkvhKzATWkLmvZlFtvNC3hmOScpXGkQvdug6QUnI0hM4kTSpn9ImPBRRyc8WqD1e4ffOsPCePsw6FH1yFnFy4I12Do6fnyDQ9UX8jW1FGR+gb5id6omDL2sueoa4p9pctpX+njuCB1s/LzQ0Dtz0OloEl5ynrO6E94uTH6X9xR+ZB9XJ9oi98duvQmLXBUPpb3I3b6AcpFxJE=

Steps to reproduce

  1. Open the Playground
  2. Look at the JS output on the right (note that the generated component is functional and doesn't have a name)
  3. Uncomment the <script> block
  4. See the change in the way the component is defined including the name infered from its file

What is expected?

Even if the component is defined as functional component, I'd expect it to have the name inferred from it's file name.

What is actually happening?

The component is anonymous and doesn't have a name

System Info

Any additional comments?

Hi, I noticed that automatic name inference doesn't work for components without or with an empty script tag. I understand that they are rendered as functional components for efficiency reasons, still I think it would be good if they had a name. This would help with tooling like the dev tools showing the name. I quiet often see components without a script tag only used to encapsulate soem boiler plate html and styles to go along with it.

For everyone else encountering this: It's easy to add a name by calling defineOptions({name: "ComponentName"}) or literally doing anything inside the script block. Still, it would be nice if inference would work out of the box :)

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

No branches or pull requests

2 participants