Proposal for standardized JSX
There has been no push for JSX standardization.
Partly this seems to be because everyone is fine with status quo.
But JSX has proven immensely practical and will eventually be standardized.
Current JSX transformations are bad
It's obvious why the initial global-based solution is bad, so I won't go into that.
But the import-based solution is equally unfit for standardization:
- What path should it use?
- How would it work without tooling?
- It doesn't allow multiple implementations per file.
The status quo for JSX assumes tooling, and inherently forfeits a path to standardization.
Simple Proposal
JSX expressions are transformed into JS object literal expressions:
- Tag is placed under
Symbol.for("JSX")
. - All children are placed in a
"children"
field. - All other properties remain as-is.
Live Demo
- Best viewed on desktop
- Babel implementation
Benefits
- Extremely simple
- Plain JS objects
- No globals
- No auto-imports
- No pragmas
- Supports framework interop
- Easy to implement