I woud like to put forward BABLR as the API layer for a JSSugar/JS0 divide. I've spent years polishing this proposal to standards-quality, and now I believe it is there. What I have created is a natural successor to Babel, and a mechanism that allows JS syntax to be extended in practice.
This proposal is designed to resolve or supercede several other outstanding proposals, including JSSugar, JSX/ESX, as well as the Type Annotations proposal.
This proposal won't look much like other proposals though. Its APIs are defined not in terms of spec text but in terms of a reference implementation. That reference implementation is bootstrapped, meaning that it creates new formalisms and defines them formally in terms of... its own formalisms. These formalisms also are also then used to define Javascript. We've created the first fully extensible parser since Acorn, and we show off this parser extension ability by creating separate and fully independent definitions of es3, es5, es6, and the more modern variants each of which extends from the previous definition of the language.
Here is an example of an es3 parse of the expression foo.bar = baz
accessible version of above image content
The CLI is expressing its output in a language called CSTML, which (like HTML) lets us talk about the content of trees without talking about exactly how they are stored in memory. CSTML is the Concrete Syntax Tree Markup Language, and like HTML it is a means of embedding structural metadata into a stream of plain text. It's just that instead of doing this by hand, we let a parser embed the metadata, most ofbviously open and close tags to show the boundaries of particular parse tree nodes. The text stream embedded inside the metadata is highlighted in green.
You'll also notice the most distinctive feature about CSTML compared to HTML or XML: it has a special kind of tag called a "shift tag" which looks like ^^^ that ensures we can still have streaming output from a parser even in languages like JS with infix notations. The shift tag means "take the node above, and put it into the gap below", where a gap is written as <//>.
The ability to stream input into a worker and stream parsed syntax out is what in practice allows us to spin up a worker and use it to do on-the-fly transformation of syntax as a preprocessing step.
In the long run this system also creates a clear path to implementing optimizations which have heretofore been impossible, most importantly the ability to efficiently load trees of ES modules. Trees of individual ESModules face a major perf penalty (in terms of wall clock time spent) because the current parser must wait to receive the complete binary content of a document before it can emit any parse results, which include the parse results which indicate the next batch of imports.
A BABLR parser can and does emit parsed imports before the rest of the content of the module is received at all, meaning that it can eliminate the dead wall clock time making it much more pleasant to work with applications where the scripts are not pre-bundled. The same streaming ability is also critical for efficient feeding of input and output through a worker-isolated syntax transformer.
A complete formal description of CSTML can be found in the CSTML grammar.
I'm happy if not eager to answer any questions!
