I am developing a React & Reflux
app, which is bundled by webpack
with babel-loader
(v6), and I am experiencing es6 modules dependencies issues
For example, I have a component that use the reflux .connect()
mixin :
import MyStore from '../stores/my-store';
const Component = React.createClass({
mixins: [Reflux.connect(MyStore)]
});
When I import all modules individually in each file like this, everything's fine.
I then tried to improve my code by using deconstructed import statements :
...in a component :
//import One from '../js/one';
//import Two from '../js/two';
//import Three from '../js/three';
import { One, Two, Three } from '../js'; // Instead
...and in js/index.js
:
import One from './one';
import Two from './two';
import Three from './three';
export { One, Two, Three };
App source code files are more concise using the above technique, because I can import all components in one import
line.
But when I use this, some dependencies end up beeing undefined
when I use them
If I use the same updated example...
//import MyStore from '../stores/my-store';
import { MyStore } from '../stores'; // Instead
const Component = React.createClass({
mixins: [Reflux.connect(MyStore)]
});
...MyStore
parameter ends up undefined
in Reflux.connect
method.
I tried to troubleshoot in the debugger, but I'm not really aware of what's going on with the __webpack_require__(xxx)
statements in the generated bundle. There must be a circular dependency that babel-loader
or webpack require could not figure out when there are the index.js
files re-exporting individual modules.
Do you know any tool that can help me figure this out? I tried madge
but it does not work with es6 modules, and I could not find anything that would tell me where anything is wrong