I have a big project, I try to refactor to ES6 modules right now.
To make further development easier, I wanted to introduce index files, which just export all modules within the directory:
index.js:
export { default as ModuleA } from './moduleA'
export { default as ModuleB } from './moduleB'
export { default as ModuleC } from './moduleC'
moduleA.js:
import { ModuleB } from './index'
moduleB.js:
import { ModuleC } from './index'
ModuleC.doSomething()
moduleC.js:
export default {
doSomething: () => {}
}
Starting point is ModuleA
.
The problem is, that in ModuleB
ModuleC
is undefined, so doSomething
can't be executed.
I suspect some issues with circular dependencies, since moduleB
tries to access the index again, which parses moduleB
before moduleC
.
Is it just not possible to do this, or is there another solution?