Modules spec procedure suggestion (Re: Jan 31 TC39 Meeting Notes)
On Thu, Feb 7, 2013 at 1:00 PM, Claus Reinke <claus.reinke at talk21.com> wrote:
There are some existing ES.next modules shims/transpilers that could be used as a starting point.
Here is an experiment I did with a JS module syntax that allowed for a static compile time hooks for things like macros, but still allowed JS that needed to exist both in pre-ES.next and ES.next to opt into modules (think base libraries like jQuery, underscore, backbone).
It has some tests, and the modus.js file runs in ES5 browsers.
Since the modules desugar to runtime APIs after the compile time pass for macros, it means not getting the lower level variable bindings that the ES module format is targeting. This means it has similar cycle dependency support as AMD -- it can be done, but may not be as nice as ES module variable binding, and has some restrictions.
The API and syntax was just provisional, just something chosen to wire things together, and it is not a fully fleshed out system. Also, it was not done to advocate macros in particular. Macros were used to demonstrate how a static, "compile time" feature could be supported in a system that desugared to runtime API calls, and it helped that sweetjs was available for that heavier lifting.
It may be useful for others to look at as a way to prototype any official ES spec approach, even if it does not give full fidelity. In particular, the use of the sweetjs reader to do a first pass transform of the module syntax.
James
There has been a great deal of pressure from users wanting details about whether the modules spec will cover their use cases, from module library authors wanting to determine whether their most important features will be covered (so that they can retire their systems), and -more recently- from transpiler authors and users needing to know what spec to target (existing implementations being invalidated by late spec changes doesn't help, either).
It looks like this has finally "blown up" at the last meeting (excerpts included below). The main concern seems not to be with specific features but with lack of confidence and missing details.
One way to restore confidence would be to go the "executable spec" route: implement the modules spec in JS, as a transpiler.
That would force the spec to be described in implementable detail (no "to determined later"), would allow use cases to be written as tests (no "I can't tell whether the spec covers this"), and would make concrete discussions possible (no "this doesn't feel right" vs "don't worry, it'll all work out in the end") - all the usual advantages of executable specifications
There are some existing ES.next modules shims/transpilers that could be used as a starting point.
Just a suggestion, Claus