You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

babel-plugin-transform-commonjs-es2015-modules

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

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

4.0.1
latest
Source
npmnpm
Version published
Weekly downloads
863
2.74%
Maintainers
1
Weekly downloads
 
Created
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

babel-plugin

FAQs

Package last updated on 25 Oct 2017

Did you know?

Socket

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