Import wildcards on the right side of the statement

Matthew Robb matthewwrobb at gmail.com
Thu Apr 21 11:43:36 UTC 2016


This could be made to work as a feature in the server side. Basically you
are asking the server to give you a virtual rollup module where the body is
basically just a bunch of export * from 'x';. Where even that gets sticky
though is when dealing with default exports.
On Apr 21, 2016 7:11 AM, "kdex" <kdex at kdex.de> wrote:

> A browser couldn't possibly resolve globs at runtime without you providing
> some additional information to the runtime environment, so I don't see how
> this could be implemented.
> It's not really about browsers, anyway; the ES environment knows nothing
> about files, either. (meaning that `require` is something on top of v8 and
> doesn't belong to the language at all.)
>
> Even if you were to resolve these globs *somehow*; this could have huge
> impacts on performance, since the result of a glob is dynamic. Also, wasn't
> the `import` syntax supposed to
> be statically analyzable anyway?
>
> One could, however, try to make this work with a babel transform that
> transforms globs into multiple `import` statements.
> Then again, I neither think that a syntax shouldn't depend on its
> underlying file system nor that this would solve a case where you'd have:
>
> ```js
> import * as SingleBinding from "./some/glob/**/*.js";
> ```
>
> A cleaner pattern would be to import one single module that, itself,
> imports only the modules that it needs.
>
> On Donnerstag, 21. April 2016 09:36:51 CEST Francisco Méndez Vilas wrote:
> > Hi all,
> >
> > This is my very first proposal here, so please let me know if i'm not
> > following some rules.
> >
> > I want to make a proposal around the "import" syntax, it is, for
> instance:
> >
> > import * from 'shared/features/**/reducers';
> >
> > or
> >
> > import * from many 'shared/features/**/reducers';
> >
> > This came to my mind when developing an isomorphic Redux application
> where
> > i had to import all reducers of each feature. My tree structure looks
> more
> > or less like that:
> >
> > + shared
> >   + features
> >      + todos
> >        + actions
> >        + components
> >        + reducers
> >          - TodoReducer.js
> >          - index.js
> >      + users
> >        + actions
> >        + components
> >        + reducers
> >          - UserReducer.js
> >          - index.js
> >
> > If i have to import every "index.js" below each "reducers" directory, i
> > have two options, either manually import each of them or prepare a script
> > to walk through the tree and import them. Both of the approaches are
> really
> > weird.
> >
> > I really would like to have that feature in the language. What do you
> think?
> >
> > Cheers,
> > Francisco Méndez Vilas
> >
> _______________________________________________
> 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/20160421/b241a7b1/attachment-0001.html>


More information about the es-discuss mailing list