Skip to content

Allow components to output multiple files per target #818

@sbrow

Description

@sbrow

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions