Do Anonymous Exports Solve the Backwards Compatibility Problem?
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss