3 ms·
> a parser/compiler does to represent a language is its own completely independent thing This isn't really true of JSX; I'd suggest giving it a try to see exac
by lucideer 6y ago
> a parser/compiler does to represent a language is its own completely independent thing
This isn't really true of JSX; I'd suggest giving it a try to see exactly how the system works.
To summarize, there are 3 parts of this discussion:
1. The JSX syntax (part of the JSX spec.)
2. The JSX transform (part of the JSX spec. & what parser/compiler must represent the language as)
3. The template function implemention: 100% independent and can represent nodes any way they want
In your comment you're imagining a system where 2 & 3 are coupled, whereas this isn't how the JSX world works. With JSX, 1 & 2 are coupled, only 3 is independent.
- aylmao 6y ago> 2. The JSX transform (part of the JSX spec. & what parser/compiler must represent the language as) Ah, ok I see where this misunderstanding stems from. See, this is not part of the spec. With JSX, there's a very popular transpiler (Babel's), but it's by no means the only one or even "the official one". The spec actually lists three, and mentions [1]: > "These are a set of transpilers that all conform to the JSX syntax but use different semantics on the output: [...]" JSX is most commonly used with React, so if you're making a JSX transpiler it makes sense to make your default output work with React. This is by no means part of the definition of JSX though or a spec requirement. [1] https://facebook.github.io/jsx/ https://facebook.github.io/jsx/