es2015 module tranformer for amd.
because of the difference between es2015 module
and amd module
,
this plugin don't support named export
and default export
at the same time.
import * as foo from 'foo'
andimport foo from 'foo'
are equalexport foo; export default foo;
will throw: 'amd module don't supportexport default foo
and ,export foo
both, please choose one
$ npm install babel-plugin-transform-modules-amd --save-dev
.babelrc
{
"plugins": ["transform-modules-amd"]
}
$ babel --plugins transform-modules-amd script.js
require("babel-core").transform("code", {
plugins: ["transform-modules-amd"]
});