Do Anonymous Exports Solve the Backwards Compatibility Problem?

Andreas Rossberg rossberg at google.com
Wed Dec 19 12:05:28 PST 2012


On 19 December 2012 20:18, James Burke <jrburke at gmail.com> wrote:

> exports assignment is not about backcompat specifically, although it
>  helps. Exports assignment is more about keeping the anonymous natures
> of modules preserved. In ES modules, modules do not name themselves if
> it is a single module in a file. The name is given by the code that
> refers to that code.
>

I don't buy this, because the name for the export would just be a local
name. You can still bind it to whatever you want on the import side. That's
what we have lexical scoping for.

For all levels below, the module has to pick names anyway. I seriously fail
to see the point of trying so hard for this one special case.



> Assigning a single exports also nudges people to make small modules
> that do one thing.
>

It rather nudges people into exporting an object as a module, instead of
writing a real module. The only "benefit" of that is that they lose all
static checking.

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


More information about the es-discuss mailing list