A Variation on ES Modules

Andreas Rossberg rossberg at google.com
Wed Dec 19 09:26:34 PST 2012

On 19 December 2012 16:24, Kevin Smith <khs4473 at gmail.com> wrote:

> I've worked up a concrete variation on the modules syntax:
> https://gist.github.com/4337062
> I believe that it presents a clean, simple model and coding experience.
>  Comments welcome!

Thank you! I agree with almost everything you suggest (and especially, what
you say about anonymous exports), and your syntax pretty much exactly
matches my preferences.

I'm fine with considering syntactic module declarations separately (note,
however, that you probably cannot define mutually recursive modules without
them). What you _do_ want to have IMO, though, is module aliases

  module Short = Long.Qualified.Module.Name

Referring to nested modules can be pretty tedious if you don't have a way
to abbreviate names. (You can do that with 'let' or 'const', but then you
lose all static checking.)

OTOH, one more other feature I could consider dropping for the time being
is the ability to export "from" a ModuleSpecifier. I'm not convinced that
this is a common enough use case to warrant specialised extra syntax -- you
can already express it by pairing an export with an import. (In fact,
allowing the "export" keyword in front of imports seems like the more
consistent way to support re-exporting.)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121219/227c369c/attachment.html>

More information about the es-discuss mailing list