Marius Gundersen gundersen at
Fri Jun 20 01:48:28 PDT 2014

> ES6 favors the single/default export style, and gives the sweetest syntax
to importing the default. Importing named exports can and even should be
slightly less concise.

It seems like ES6 favors single import (`import singleThing from "module"`)
but prefers multiple export (`export var a = 5;`), with single/default
export being a special case of named/multiple export. In the spec[1] there
are 5 ways to export named things, but only one way to export a default
value. The focus in the spec is therefore on multiple export, while single
export is a special case using a keyword to differentiate itself. This
means that a module which exports only a single (named) thing is not a
single-export module, and cannot be imported using the single-import syntax:

export class A{
import A from "moduleA"; //wont work, even though moduleA only has a single

This will likely lead to confusion, since the ES6 module system does not
actually favor single export modules, but default export modules. If the
ES6 module system is trying to push developers towards single exporting
modules, then the syntax for export should prefer single export, without
requiring a keyword for it to actually be a single export module. Multiple
export should be the special case, requiring a keyword or new syntax, and
throwing if a module exports multiple times without the extra keyword.

Unfortunately I don't have any suggestions for how this syntax could work
without deviating very far from the current spec. It seems easier to get
the spec to favor multiple export (which, to me, it looks like it was
originally designed to favor). I don't have any preference either way, I
just want it to favor one, both on the export and import side.

Marius Gundersen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list