I have a file modules.js
that exports all default
exports from my modules by their module name (following ES6 exporting/importing in index file):
export { default as a } from './a/a'
export { default as b } from './b/b'
...
export { default as y } from './y/y'
export { default as z } from './z/z'
In my app.js
, I want to import this module bundle.
I want the exported variables from a...z to be imported from module.js
so I can use them in app.js
.
Obviously I don't want to do
import { a, b, c, d, ... , x, y, z } from './modules/modules'
as that is very verbose and whenever I would add a module in module.js
, I would also have to change the import
in app.js
.
I've tried
import * from './modules/modules'
but the variables are not available in app.js
.
Question: How do I simply import all named exports under their export name?
Example module ./modules/a/a.js
:
export default function a() {
// whatever
}