Babel plugin that transforms CommonJS require/exports syntax into ES2015 import/export statements. Version 4.0.1 is stable but not actively maintained; the package saw its last release in 2017. It supports most popular CommonJS patterns, including those generated by Babel's own CJS transform. Unlike similar tools (cjs-to-es6, lebab), it operates as a Babel plugin, making it easy to integrate into existing Babel pipelines. The transformation is lossy in some edge cases (e.g., dynamic requires or module.exports reassignment) and does not handle all CJS idioms.
npm install babel-plugin-transform-commonjs-es2015-modulesVerified import paths — ran on the pinned version, not inferred.
Shows basic configuration and transformation of CommonJS require/exports to ES module imports/exports.
Manually refactor dynamic requires or use a different tool. Consider bundlers like Webpack that handle dynamic imports natively.
Use with Babel 6 or check if compatible with Babel 7 via shim. For newer projects, consider alternatives like lebab or manual conversion.
Review output for anonymous exports; consider using named function expressions.
Manually move requires to top level if ES module semantics are required.
Run `npm install babel-plugin-transform-commonjs-es2015-modules`
Use correct plugin name: 'transform-commonjs-es2015-modules' (without 'babel-plugin-' prefix).
Simplify the assignment or refactor to avoid member expression on module.exports.