vuejs / vue-class-component

ES / TypeScript decorator for class-style Vue components.
MIT License
5.81k stars 429 forks source link

Any issue with not naming classes? #555

Closed shadow-light closed 2 years ago

shadow-light commented 2 years ago

For a long while I've been exporting my classes without names, e.g.

@Component({})
export default class extends Vue {
    ....
}

But Vite plugins currently don't take this into account and it causes build failure as they are expecting classes to have a name.

Just wanted to check if there is any value in giving classes a name and whether I should update them all to do so, or whether the plugins should be corrected to support this. Do the names make debugging easier via console etc? Is there any other value to them?

Kolobamanacas commented 2 years ago

Do the names make debugging easier via console etc?

Not via console but with DevTools. Giving component a name allows you to clearly distinguish it in components tree.

2021-08-13_21-06-23

Please also notice, that in order to achieve this you would need not only name a class, but also pass "name" property with class name string to Component's (or Options's for Vue 3) params list.

shadow-light commented 2 years ago

Thanks, yea I noticed that a bit later. I ended up making a Vite plugin that automatically sets the class name based on the file name which is working well and shows up in dev tools too.

Thanks for clarifying