ModuleImport

Axel Rauschmayer axel at rauschma.de
Thu Jun 19 10:48:57 PDT 2014


On Jun 19, 2014, at 16:17 , John Barton <johnjbarton at google.com> wrote:

> Sorry to be dense, but I would appreciate more elaboration of this sentence:
> 
> 
> On Thu, Jun 19, 2014 at 3:40 AM, Axel Rauschmayer <axel at rauschma.de> wrote:
> This is a key sentence in David’s proposal: “ES6 favors the single/default export style,
> 
> What is the "single/default" export style?  If I understand this claim, it says that a module will typically contain a single export statement, either named 'default' or not. Is there any evidence to support this? Everything I've seen contradicts this claim, assuming I understand it.

The syntax is ( https://people.mozilla.org/~jorendorff/es6-draft.html#sec-exports ):

    export default AssignmentExpression

> and gives the sweetest syntax to importing the default. Importing named exports can and even should be slightly less concise.”
> 
> Could you please give an example? In my experience, "export default" is rare or at least divisive since it seems stylistically incompatible with named exports. 

I’m surprised, too. But that seems to be the feedback from people working with large module-based client-side projects and from the Node.js community: single exports are most common. I think in client-side projects, one class per module was reported as a frequent use case:

```js
// MyClass.js
export default class {
    ...
};

// main.js
import MyClass from "MyClass";
```

-- 
Dr. Axel Rauschmayer
axel at rauschma.de
rauschma.de



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


More information about the es-discuss mailing list