Socket
Socket
Sign inDemoInstall

babel-plugin-transform-commonjs-es2015-modules

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-transform-commonjs-es2015-modules

CommonJS to ES2015 modules (export/import) transformation plugin for Babel


Version published
Weekly downloads
476
decreased by-26.32%
Maintainers
1
Install size
11.8 kB
Created
Weekly downloads
 

Readme

Source

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 = 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;

Installation

$ npm install babel-plugin-transform-commonjs-es2015-modules

Usage

.babelrc

{
  "plugins": ["transform-commonjs-es2015-modules"]
}

Via CLI

$ babel --plugins transform-commonjs-es2015-modules script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-commonjs-es2015-modules"]
});

Keywords

FAQs

Last updated on 25 Oct 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc