I am experiencing wield scoping issue in ES6 with webpack and chrome
Here is my code:
'use strict'
import Reflux from 'reflux'
import Immutable from 'immutable'
import Something from 'something'
import Cursor from 'immutable/contrib/cursor'
// everything is working in this scope
export default Reflux.createStore({
init: function() {
console.log(Something) // Something Not defined
console.log(Cursor) //Cursor Not defined
console.log(Reflux) // Reflux Not defined
},
... some other code
})
so the question is, why things are defined in the scope above but not in the scope in the init function? thanks for the help
The code compiled after babel is like "use strict";
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var Reflux = _interopRequire(require("reflux"));
var Immutable = _interopRequire(require("immutable"));
var Something = _interopRequire(require("something"));
var Cursor = _interopRequire(require("immutable/contrib/cursor"));
// everything is working in this scope
module.exports = Reflux.createStore({
init: function init() {
console.log(Something); // Something Not defined
console.log(Cursor); //Cursor Not defined
console.log(Reflux);
} });