I think `import` should be as dumb as possible and you should look for
another way to do this and it is probably [WHATWG Loader](
https://github.com/whatwg/loader).

Another problem is that you are supposed to point to a single module when
you `import` and you point to multiple modules when you glob. How do these
multiple modules get merged into one?

If making an "index.js" for your "features" directory is such a trouble,
then investigate the WHATWG Loader spec to see if it allows you to:

1- Intercept an import and get its path.

2- If the path contains a glob, load multiple modules and merge them.

3- Provide the merged module as the result of the import.

Of course, you still won't be able to glob in a browser. For that, you can
glob when you build your app and ship it with the results.

To be honest, just keep an index manually.

Here is another [example](
https://gist.github.com/AlicanC/9b8c12a49a3fc3382f0d3a134b2e491a) anyways.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to