ES6 modules (sorry...)

Juan Ignacio Dopazo jdopazo at yahoo-inc.com
Mon Jun 16 06:28:13 PDT 2014




>
>
>On Monday, June 16, 2014 12:33 AM, Axel Rauschmayer <axel at rauschma.de> wrote:
>
>
>**Single-export modules.** Still missing is support for single-export modules, which could be added as follows (the keyword `default` instead of the asterisk works just as well, in my opinion).


You're being confused by CommonJS. ES6 modules don't have "single-export modules". All modules can have multiple exports. And all modules can have a specially named export called "default" which allows you to skip the curly brackets.

Example:

// foo.js
export default function () { // anonymous function
  console.log(42);
}

// bar.js
import answer from 'foo'; // I can give whatever name I want to the default export
answer(); // 42


Juan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140616/2ea2993b/attachment.html>


More information about the es-discuss mailing list