Proposal: ESX as core JS feature

I started a new thread to focus on improving template tags, so we don't need to muddle this thread with that discussion: Improve sub-lange support for template literals

That being said, I would like to still discuss briefly one thing relate to template tags, mostly because it pertains to your FAQ section.

I would like to add one option that hasn't been discussed much yet. That table is basically comparing userland syntax support (JSX), built-in syntax support (ESX), userland tagged-template support (the tagged template column), but we haven't yet discussed the implications of using a built-in template tag. I'm not necessarily arguing for or against it here, I'm mostly just wanting to bring it up as an option as well.

If we were to add "built-in template tags" to that table, we'd end up with the same checks that "Tagged Templates" have, as well as:

  • allows object spread for props/attrs - Why can't template tags support this? In JSX, you spread attributes with {...attrs}, and in template tags, you'd spread with with ...${attrs}. In JSX, you spread children by just providing a list where a child is expected. The same can be done with template tags.
  • out of the box static analisys + correctness - this can happen to a degree. It's true that syntax errors won't be thrown until you're actually running that piece of code, but, linters and editors can also help you catch syntax errors inside the template.
  • syntax highlight in most popular IDEs - if you're tagging with a built-in tag, an editor can know how to highlight it.
  • it's standardized as syntax - It doesn't get more standardized than having a standards committee do so :)
  • it can be serialized - As Bergus noted, I don't see why any of these options couldn't be serialized when you're not dealing with user-defined components.
  • "it's highly interoparable" - I don't fully understand this point to begin with. You're claiming that ESX is interoperable with JSX, but I don't see how that is. Yes, they use the same syntax, but they build into two different things, so you can't just go using ESX anywhere where JSX is expected.

This seems to cover most of the checks in this box. However, there's still an argument to be made for the fact that it's more clunky to use template tags in regards to interpolation, which you did mention in the FAQ. I believe that would be the main advantage we gain if we move from a built-in template tag to built-in syntax support. Which is fine - the purpose of syntax is to make things less clunky to use.

1 Like