-
-
Couldn't load subscription status.
- Fork 4.7k
Description
Describe the problem
When creating demos for component libraries, it would be handy if we could write generalized code that receives a component by arguments/properties and can extract the component name out of it.
Pardon me if this is already possible. I don't recall ever reading about this, if it exists today.
Describe the proposed solution
Have the Svelte compiler add the componentName property to the function or function's prototype. The name would come from... ? See options.
Simple Option
Use the file's name.
Not-So-Simple Option
Because the component is a default export, it really can be named anything. Furthermore, if it ever becomes possible to export components grouped in POJO objects (I opened an issue for this a long time ago), for documentation/demo purposes it could be a compound name like Card.Header.
Because of this, maybe the best option would be to add a per-component compiler option to set the desired name. If the option is not specified, then it would default to the simple option above.
Importance
nice to have