import { foo, bar } as obj from 'module

Andrea Giammarchi andrea.giammarchi at gmail.com
Tue Dec 12 16:18:42 UTC 2017


FWIW I agree `import {a, b} as mod from './module.js'` makes sense and it's
handy.

I actually thought it was already possible and failed already a couple of
time with that expectation.

Regards

On Tue, Dec 12, 2017 at 1:51 PM, Isiah Meadows <isiahmeadows at gmail.com>
wrote:

> This `import { ... } as foo from "..."` proposal would be incredibly
> useful. There's been times where I frequently used a single method from an
> import, but I only used the rest maybe once or twice, and thus didn't want
> to include *everything* when importing. It's easier than doing either
> duplicate imports or a subsequent `const foo = ns.foo` after the import.
>
> -----
>
> Isiah Meadows
> me at isiahmeadows.com
>
> Looking for web consulting? Or a new website?
> Send me an email and we can get started.
> www.isiahmeadows.com
>
> On Tue, Dec 12, 2017 at 3:19 AM, Tiddo Langerak <tiddolangerak at gmail.com>
> wrote:
>
>> Thanks for pointing that out, I didn't know that (I should've tested my
>> assumptions). It seems that Webpack does the same.
>>
>> The entire motivation behind selective namespaced imports relied on that
>> assumption, so if treeshaking works with * imports then I don't think
>> there's much use for this feature.
>>
>> On 12/12/2017 09:51 AM, Ltrlg wrote:
>>
>>> 2017-12-12 8:39 GMT+01:00 Tiddo Langerak <tiddolangerak at gmail.com
>>> <mailto:tiddolangerak at gmail.com>>:
>>>
>>>     - Star imports prevent treeshaking.
>>>
>>>
>>> Treeshaking does work with star imports as long as you only have
>>> statically known usages. At least Rollup handles these situations as if it
>>> was a named import [1]
>>>
>>> [1]: https://rollupjs.org/repl?version=0.52.1&shareable=JTdCJTIyb
>>> W9kdWxlcyUyMiUzQSU1QiU3QiUyMm5hbWUlMjIlM0ElMjJtYWluLmpzJTIyJ
>>> TJDJTIyY29kZSUyMiUzQSUyMmltcG9ydCUyMColMjBhcyUyMG1hdGglMjBmc
>>> m9tJTIwJy4lMkZtYXRocy5qcyclM0IlNUNuY29uc29sZS5sb2coJTIwbWF0a
>>> C5jdWJlKCUyMDUlMjApJTIwKSUzQiUyMCUyRiUyRiUyMDEyNSUyMiU3RCUyQ
>>> yU3QiUyMm5hbWUlMjIlM0ElMjJtYXRocy5qcyUyMiUyQyUyMmNvZGUlMjIlM
>>> 0ElMjJleHBvcnQlMjBmdW5jdGlvbiUyMHNxdWFyZSUyMCglMjB4JTIwKSUyM
>>> CU3QiU1Q24lNUN0cmV0dXJuJTIweCUyMColMjB4JTNCJTVDbiU3RCU1Q24lN
>>> UNuZXhwb3J0JTIwZnVuY3Rpb24lMjBjdWJlJTIwKCUyMHglMjApJTIwJTdCJ
>>> TVDbiU1Q3RyZXR1cm4lMjB4JTIwKiUyMHglMjAqJTIweCUzQiU1Q24lN0QlM
>>> jIlN0QlNUQlMkMlMjJvcHRpb25zJTIyJTNBJTdCJTIyZm9ybWF0JTIyJTNBJ
>>> TIyY2pzJTIyJTJDJTIyZ2xvYmFscyUyMiUzQSU3QiU3RCUyQyUyMm5hbWUlM
>>> jIlM0ElMjJteUJ1bmRsZSUyMiUyQyUyMmFtZCUyMiUzQSU3QiUyMmlkJTIyJ
>>> TNBJTIyJTIyJTdEJTdEJTJDJTIyZXhhbXBsZSUyMiUzQW51bGwlN0Q=
>>>
>>> Ltrlg
>>>
>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171212/2ac749f0/attachment.html>


More information about the es-discuss mailing list