node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org ยป

cjs2es6export

cjs2es6export

Convert a subset of CommonJS/NodeJS module.exports assignments to ECMAScript 6 module export declarations.

Usage:

var cjs2es6export = require('cjs2es6export');

var src = "module.exports = function() { return 42; };"
var newSrc = cjs2es6export(src); // "export default function() {\n return 42;\n};;"

Currently only direct assignment to module.exports (translated to default export) is supported.

See also cjs2es6import

License

MIT