-
Notifications
You must be signed in to change notification settings - Fork 619
Description
What?
Certain frameworks, (such as Angular) allow you to split your components into multiple files. It would be useful if mitosis could allow components to compile into more than one output file per target.
Why?
Although this would be a helpful feature for teams that prefer multi-file components over single-file components, there are other instances, such as Alpine.js where it can be down-right necessary. When you write an Alpine component that requires importing code, that code needs to rolled into to the js bundle. However, if the component's DOM is rendered by a static templating engine, (which is a common use for Alpine), then you won't be able to put the js and the html in the same file.
How?
The useMetadata
hook seems like the ideal place to implement this feature. I think most components would be split by html/js/css, but not all. For example, Marko also supports split components where brower-only code resides in one file, and shared code goes in the other. I'm not sure about other frameworks, but I imagine that trying to add settings for each of them could get quite complicated, so I leave the implementation details up to the fine minds at BuilderIO 😄
Conclusion
I don't think this is a high priority issue, but as I mentioned in issue #11 I do think it's a necessary feature to make certain frameworks (i.e. Alpine.js) a viable target for Mitosis.
I love mitosis and I'm excited to see it grow!