Proposal: importing selected chucks of a module into an object

Jordan Harband ljharb at gmail.com
Tue May 24 19:23:15 UTC 2016


This is usually part of the reason why small modules are recommended,
rather than large object bags of things (including many named exports).
Have you considered putting each thing you want to import as the default
export of a separate file?

On Tue, May 24, 2016 at 9:20 PM, Norbert de Langen <
Norbert.de.Langen at macaw.nl> wrote:

> I think there’s a preference reason for this but also optimization reasons.
>
> For humans it becomes crystal clear exactly what parts are dependent on. I
> personally like this.
>
> When importing the entire module the module code needs to be run to figure
> out what parts are not needed. Eliminating the possibility of tree-shaking
> I believe.
>
> On 24-05-16 21:06, "Tab Atkins Jr." <jackalmage at gmail.com> wrote:
>
> >On Tue, May 24, 2016 at 11:59 AM, Norbert de Langen
> ><Norbert.de.Langen at macaw.nl> wrote:
> >> It would be nice to have this option:
> >>
> >> ```
> >> import { parse } as xmlLib from 'xml-lib';
> >> import { parse } as jsonLib from 'json-lib';
> >> import { parse } as htmlLib from 'html-lib';
> >>
> >> // usage
> >> xmlLib.parse();
> >> jsonLib.parse();
> >> htmlLib.parse();
> >> ```
> >
> >This begs the question, tho - why do you only need to import selected
> >chunks? If you're pulling in the module as a namespace object, how
> >does having the *rest* of the module available harm you?
> >
> >~TJ
>
> _______________________________________________
> 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/20160524/706c227c/attachment.html>


More information about the es-discuss mailing list