ES Modules: suggestions for improvement
Wes Garland
wes at page.ca
Tue Jun 26 13:54:54 PDT 2012
On 26 June 2012 16:45, Kevin Smith <khs4473 at gmail.com> wrote:
> Hi Isaac,
>
> I share some of your concerns as well. I like the idea of "import" just
> returning an object, which can be destructured using let. I also like the
> idea of eliminating the "import *" syntax. However, I think that dynamic
> exports ("export <expression>") might not be as useful as it seems.
>
> In my modules, I use the "export <expression>" form for the following
> reasons:
>
> 1. When I want to export a single function (perhaps a constructor), and I
> don't want importers to unnecessarily repeat the function name:
>
> var MyClass = require("MyClass").MyClass; // Boo!
> var MyClass = require("MyClass"); // Better!
>
var { MyClass } = require("MyClass"); // Best!
Best of both worlds! My code is full of this.
Wes
--
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120626/dd1d2258/attachment.html>
More information about the es-discuss
mailing list