babel-plugin-transform-commonjs-es2015-modules
CommonJS to ES2015 modules (export/import) transformation plugin for Babel
Use Case
Converting the CommonJS-formatted scripts in node_modules
to ES2015 Modules syntax. Then Babel can transform to other formats such as AMD, UMD, or SystemJS.
Should support most popular CommonJS patterns. Especially code generated by Babel (so this should work with Browserify's Babelify).
See Also
Supported Syntax
// in:var foo = ;// out:; // in:var foo = foo;// out:; // in:var foo = baz;// out:; // in:moduleexports = ;// out:; // in:moduleexports = foo;// out:; // in:moduleexportsfoo = ;// out:; // in:moduleexportsfoo = bar;// out:var foo = bar; // in:exportsfoo = ;// out:; // in:exportsdefault = foo;// out:; // in:exportsfoo = bar;// out:var foo = bar;
Installation
$ npm install babel-plugin-transform-commonjs-es2015-modules
Usage
.babelrc
(Recommended)
Via .babelrc
Via CLI
$ babel --plugins transform-commonjs-es2015-modules script.js
Via Node API
;