
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
babel-plugin-transform-commonjs-es2015-modules
Advanced tools
CommonJS to ES2015 modules (export/import) transformation plugin for Babel
CommonJS to ES2015 modules (export/import) transformation plugin for Babel
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).
// in:
var foo = require('bar');
// out:
import foo from 'bar';
// in:
var foo = require('bar').foo;
// out:
import { foo } from 'bar';
// in:
var foo = require('bar').baz;
// out:
import { baz as foo } from 'bar';
// in:
module.exports = require('foo');
// out:
export * from 'foo';
// in:
module.exports = foo;
// out:
export default foo;
// in:
module.exports.foo = require('bar');
// out:
export { default as foo } from 'bar';
// in:
module.exports.foo = bar;
// out:
export var foo = bar;
// in:
exports.foo = require('bar');
// out:
export { default as foo } from 'bar';
// in:
exports.default = foo;
// out:
export default foo;
// in:
exports.foo = bar;
// out:
export var foo = bar;
$ npm install babel-plugin-transform-commonjs-es2015-modules
.babelrc
(Recommended).babelrc
{
"plugins": ["transform-commonjs-es2015-modules"]
}
$ babel --plugins transform-commonjs-es2015-modules script.js
require("babel-core").transform("code", {
plugins: ["transform-commonjs-es2015-modules"]
});
FAQs
CommonJS to ES2015 modules (export/import) transformation plugin for Babel
The npm package babel-plugin-transform-commonjs-es2015-modules receives a total of 589 weekly downloads. As such, babel-plugin-transform-commonjs-es2015-modules popularity was classified as not popular.
We found that babel-plugin-transform-commonjs-es2015-modules demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.