How does Mitosis work?

How does Mitosis work?

You've seen how Mitosis can compile a component to React, Vue, Qwik, and tons of other frameworks... but how?

The secret is in seeing that all frameworks inevitably have to support the same few core things. A tree of components, binding inputs to expressions, binding outputs to logic, and handling state, context, and effects. To be blunt, that's about the gist of what all frameworks (and thus really all sites and apps) must do.

We start by using a strict subset of JSX. And don't be mistaken, this is not vdom. It's just using JSX as a templating system, because who wants yet another templating language...

No alt text provided for this image

Then, we parse it to a declarative JSON tree. We serialize code expressions as strings that can be manipulated and outputted to various frameworks, and all elements are a clean tree of parents, siblings, and children (much like DOM trees)

No alt text provided for this image

Finally, we stringify that data in the various flavors per framework. We can do simple manipulation of expressions as well, e.g. converting `state.name` to just `name` for Angular, which is easy to do with babel transforms

No alt text provided for this image

And that's the gist! Any Qs? Ama!

And you can learn more about the project here: https://github.com/builderio/mitosis

Jacky Cheng

We design and deliver custom internal software and AI agents in days—not months. Trusted by 100+ project managers and founders to streamline workflows and cut operational costs by 50%.

2 年

Steve, thanks for sharing!

回复

要查看或添加评论,请登录

Steve Sewell的更多文章

  • React Server Components, Visualized

    React Server Components, Visualized

    I've been digging into React Server Components via Shopify Hydrogen, and I'm very impressed & excited Here is a visual…

    1 条评论

社区洞察

其他会员也浏览了