Module syntax

Brendan Eich brendan at mozilla.com
Mon Jun 3 12:53:08 PDT 2013


I was corresponding with Axel about what's possible without ambiguity, 
and he pushed for brace elimination noting that 'default' is a reserved 
word. This led to me remembering the export = ... form, more concise 
than export default ... -- not that "more concise" must win, but it 
seems worth a brief discussion. The export = form also looks more like 
today's module.exports = ... from NPM/AMD.

/be

Axel Rauschmayer wrote:
> We may be able to have both: convenient default imports and convenient 
> non-default imports, if we bring back `export =` (which, IIRC, has 
> been proposed a while ago) and introduce `import =` as an analog. Example:
>
> module "jquery" {
>     export = {
>         ...
>     };
> }
>
> import $ = "jquery";
>
> Not completely happy with it (as both look like assignments), but it 
> complements the non-default case nicely and everything combined may be 
> the best we can do overall.
>
> Remaining changes – wiki:
>      import  {  encrypt, decrypt}  from"crypto";// binding a module's exports to variables
>      import  {  encryptas  enc}  from"crypto";// binding and renaming one of a module's exports
>      export  {  foo, bar}  from"crypto";// re-exporting specified exports from another module
> Brace-free:
>      import  encrypt, decrypt from"crypto";// binding a module's exports to variables
>      import  encryptas  enc from"crypto";// binding and renaming one of a module's exports
>      export  foo, bar from"crypto";// re-exporting specified exports from another module
> -- 
> Dr. Axel Rauschmayer
> axel at rauschma.de <mailto:axel at rauschma.de>
>
> home: rauschma.de <http://rauschma.de>
> twitter: twitter.com/rauschma <http://twitter.com/rauschma>
> blog: 2ality.com <http://2ality.com>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list