I've recently upgraded to babel 6.0 and I've run into issues with exporting objects as default. It seems that whenever I export an object using export default
and then import
the object it gets placed under a default
object.
For example:
let a = {};
a.b = 'c';
export default a;
Will import as the following:
import a from './a';
a.b // undefined
a.default // { b: 'c' }
This worked properly under babel 5.0. I'm also using babel-loader
with webpack.
babel-loader
config:
{
test: /\.js|\.jsx$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
cacheDirectory: true,
plugins: ['transform-runtime'],
presets: ['es2015', 'react', 'stage-0']
}
}
I believe, as Larry Lee pointed out, this can probably be considered a duplicate of this question.