-
Notifications
You must be signed in to change notification settings - Fork 625
feat: Generators can now emit more than one output file. #865
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
base: main
Are you sure you want to change the base?
Conversation
BREAKING CHANGE: Generators no longer return a string.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…ure/multiple-outputs
…ure/multiple-outputs
853ab86 to
a7ab359
Compare
…branch 'main' of https://github.com/BuilderIO/mitosis into feature/multiple-outputs
Works when outputting to console, not so much with files.
…ure/multiple-outputs
|
Excuse me, is there any progress on this currently? |
Not that I know of. Still waiting on input from sami to proceed. |
|
@sbrow Sorry, I did not realize this was blocked on me. The PR certainly looks great to me, and is good to go on my end if you can rebase and fix any outstanding CI issues. 🙏🏽 Thank you for your patience, it's been a hectic couple of months. |
BREAKING CHANGE: Generators no longer return a string.
Description
This PR makes the changes discussed in #808, and (when completed) will also close issue #818. The basic premise is to allow generators to output to more than one file, allowing Mitosis to output Multi-file components as well as Single-file components.
Status: RFC
This will involve a relatively large refactor of all current and future generators, and so it must be thought out very carefully.
Questions
1. Do we split chunks nominally or by file extension?
html,css,js,jsx,scss, etc.component,dom,styles,stateDefininitions of above terms:
component: Emits the entire component, as output by mitosis currently.dom: Emits only the html elements of the component, including any event handlers and templating therein. Possible output extensions:.html,.vue,.jsx,.tsx, etc.styles: Emits only the css and inline style data. Possible output extensions:.css,.scss,.pcss, etc.state: Emits only the state object of the component. Output extensions limited to.js,.ts. (JSX isn't needed, because all the html is getting piped to thedomfile).2. How will generators know what chunks (if any) to split components into?
This sounds like a job for generator options. Does this mean we need a unifying interface for configuring code chunks, or should it be up to the generators to decide their API?
Example shared options interface:
3. How will file extensions be determined during compilation?
At time of writing, file extensions for output files are hard-coded in
packages/cli/src/helpers/extensions.ts. What if we want to split an Angular component intoMyComponent.component.jsandMyComponent.css? We could hard-codecssin as an option, but what if someone wants to use sass or postcss?Maybe we need a
stylesLanguageorstylesExtensionoption for such cases, to tell mitosis how we want it to treat the styles.4. How will multiple output files be displayed in the Fiddle?
To-Dos
Core
CLI
Fiddle