ecmascript 6 - Babel 6 changes how it exports default -
before, babel add line module.exports = exports["default"]
. no longer this. means before do:
var foo = require('./foo'); // use foo
now have this:
var foo = require('./foo').default; // use foo
not huge deal (and i'm guessing should have been along). issue have lot of code depended on way things used work (i can convert of es6 imports, not of it). can give me tips on how make old way work without having go through project , fix (or instruction on how write codemod pretty slick).
thanks!
example:
input:
const foo = {} export default foo
output babel 5
"use strict"; object.defineproperty(exports, "__esmodule", { value: true }); var foo = {}; exports["default"] = foo; module.exports = exports["default"];
output babel 6 (and es2015 plugin):
"use strict"; object.defineproperty(exports, "__esmodule", { value: true }); var foo = {}; exports["default"] = foo;
notice difference in output module.exports = exports["default"]
.
edit
you may interested in blogpost wrote after solving specific issue: misunderstanding es6 modules, upgrading babel, tears, , solution
you can use this plugin old export
behavior back.
Comments
Post a Comment