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@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to