Background
There have been several attempts already in the history of ECMAScript to bring XML(ish) like syntax to the language:
- E4X which tried to add native XML support to the language
- JSX which fuels an incredibly amount of libraries and frameworks out there, and it became so de-facto standard that projects like bun or deno support it out of the box.
"E4X is dead, long life JSX" is kinda the daily JS developer motto, but there are issues with JSX, issues I've recently explored in details until the point I've created the fastest runtime out there, that outperform even template literals based libraries, but it works out of the box for SSR purposes too, thanks to a specialized JSX transformer that carries more info than other regular JSX transformers.
Most noticeable issues are:
-
JSX assumes by default a global
React.createElement
and a globalReact.Fragment
- every env or tool requires instrumentation to understand if the JSX in the code is react type, or any other, including special comments such as
/* @jsxPragma A */
and/* @jsxFragment B */
. This creates conflicts among libraries where those two functions or references mean a different thing - differently from template literals tags, JSX doesn't understand uniqueness of its outer template reference, and it doesn't provide any hint around its properties or children
Most noticeable features though:
- JSX demonstrated over many years it provides an awesome DX
- differently from E4X, JSX is not strictly coupled with the DOM, so that many projects, libraries, or framework, are using it to even fulfill SSR constraints or requirements, but definitively not confined to SSR, even 3D
- as DSL for XML(ish) like trees, JSX can represent schemas, DOM, dependencies, and so on, without really needing to be coupled to the React namespace default dependency, or any out of scope dependency at all
Proposal
I've created an optimal JSX specialized version through the help of Babel developers, which not only smoked all other JSX plain runtime based libraries, it made me confident JSX doesn't need to do, or be, what it is now, and there's much more to improve and/or simplify, so that the eventual render(jsx, where)
callback could be finally library independent, as opposite as being React expected global namespace by default.
This proposal is being maintained by myself in this gist and I've tried hard to simplify it to its minimum terms, also describing in a nutshell what this proposal concretely brings to the mainstream world as benfit.
Summary
I really don't care about any naming convention I've used in that proposal, as I have zero strong feelings around any of the choices I've made, I only know those choices work for real, produce blazing fast solutions for both DOM related libraries and SSR one, and it solves all the gotchas around both previous attempts to have XML(ish) syntax backed in the library, so I hope to find any champion in here to move this proposal forward to, at least, a stage zero, and I'm willing to answer literally any question around this topic, as that's what I've been focusing on during last weeks and it wasn't neither easy, nor simple, but the final proposal outcome looks like a game changer in the industry to me.
Thank you!
P.S. all benefits around this proposal has been written down in this gist comment