ModuleImport

Michał Gołębiowski m.goleb at gmail.com
Fri Jun 27 00:51:08 PDT 2014


On Thu, Jun 19, 2014 at 4:04 PM, David Herman <dherman at mozilla.com> wrote:

> On Jun 19, 2014, at 3:31 AM, Michał Gołębiowski <m.goleb at gmail.com> wrote:
>
> > Compare these 3 forms of importing all the module "lodash" bindings to
> an object _:
> > ```js
> > var _ = require("lodash"); // Node
> > import * as _ from "lodash"; // Dave's syntax
> > import "lodash" as _;
> > ```
>
> My feeling is that the clutter is small, and it's acceptable to have it be
> slightly less minimal than default export since that is the case we are
> favoring. This isn't so cluttered as to be downright *punishing*
> multi-export utility modules (it's literally only two characters longer
> than your Node code, albeit admittedly a little chattier), but it's good
> that default import is the winner.
>

IMO it's not even that much a question of taken space but of potential
confusion. People will think if they can do:
```js
import * as _ from "lodash";
```
they can do:
```js
import * from "lodash";
```
as well. Also, there are reports of thinking that the first form exports
not only the _ container object but also all individual methods as in
Python.

I'd still prefer:
```js
import "lodash" as _;
```
I think it's less confusing that other proposals and reads naturally; it
also corresponds more to other module systems. But if that's out of the
picture, sth like:
```js
import module _ from "lodash";
```
would be IMO less confusing that the proposed `* as _` form.

-- 
Michał Gołębiowski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140627/4915c2de/attachment-0001.html>


More information about the es-discuss mailing list