import { foo, bar } as obj from 'module

Michał Wadas michalwadas at gmail.com
Sat Dec 16 17:16:14 UTC 2017


Isn't direct eval working like this only in sloppy mode (and modules are
always strict)?

On 16 Dec 2017 6:20 am, "Jordan Harband" <ljharb at gmail.com> wrote:

> If you intend to use both Rollup and `import *`, be aware that when
> rollup's current approach, as I understand it, is either a) it statically
> knows with confidence which names off a ModuleRecord you use, and
> treeshakes the rest out; or b) it knows with confidence that you're
> reflecting on the ModuleRecord, and treeshakes nothing, or c) it's not
> certain, so it treeshakes out named exports that you may be relying on.
>
> On Fri, Dec 15, 2017 at 9:00 PM, Isiah Meadows <isiahmeadows at gmail.com>
> wrote:
>
>> And Rollup already does this (although with less dramatic renaming).
>>
>> On Fri, Dec 15, 2017, 23:40 Jérémy Judéaux <jeremy.judeaux at volune.net>
>> wrote:
>>
>>> One of the first assumptions in this discussion is that “Star imports
>>> prevent treeshaking”
>>>
>>>
>>>
>>> But thinking about it, I don’t see why tools cannot transform
>>>
>>> ```js
>>>
>>> import * as L from './lib';
>>>
>>> console.log(L.foo, L.bar());
>>>
>>> ```
>>>
>>> To
>>>
>>> ```js
>>>
>>> import {foo as $$generated$$1$$foo$$, bar as $$generated$$1$$bar$$} from
>>> './lib';
>>>
>>> console.log($$generated$$1$$foo$$, $$generated$$1$$bar$$());
>>>
>>> ```
>>>
>>> And then apply tree-shaking. As long as the code doesn’t contain
>>> something like `Object.keys(L)` it should be fine.
>>>
>>>
>>>
>>> At least that’s for the concept, maybe tools have better ways to do it.
>>>
>>> So I tried, webpack 3 + babel 7 beta. And it works. A very big function
>>> I put inside my lib.js only get exported if I use `Object.keys(L)`
>>>
>>>
>>>
>>> With treeshaking working with star imports, are there still benefits of
>>> the proposed syntax?
>>>
>>>
>>> _______________________________________________
>>> 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
>>
>>
>
> _______________________________________________
> 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/20171216/6053071e/attachment-0001.html>


More information about the es-discuss mailing list