Do Anonymous Exports Solve the Backwards Compatibility Problem?

Kevin Smith khs4473 at gmail.com
Wed Dec 19 11:44:48 PST 2012


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

A Node-ism for which the benefit is not yet proven : )


> It is a design aesthetic that has been established in the JS
> community, both in node and in AMD modules, in real code used by many
> people. So allowing export assignment is more about paving an existing
> cowpath than a specific technical issue with backcompat.
>

But that cowpath was only created because of the problems inherent in a
dynamic, variable-copy module system, as I argue here (
https://gist.github.com/4337062).  In CommonJS, modules are about
variables.  In ES6, modules are about bindings.  The difference is subtle,
but makes all the difference.

The Zepto/jQuery example is not typical, but it's fair game.  What's going
on there?  Well, jQuery is defining an interface, presumably consisting of
a function named "jQuery".  If Zepto wants to provide the same interface,
then it should export bindings with the same name: a function named
"jQuery".  It's unreasonable to demand that a part of an interface (in this
case, the function name), be defined by the *user* of that interface.

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


More information about the es-discuss mailing list