es6-modules-commonjs

0.1.3 • Public • Published

es6-modules-commonjs

Compiles JavaScript written using ES6 modules to CommonJS syntax. For example, this:

module React from "react";
import {format} from "util";
export {React, format as fmt};

compiles to this:

var React = require("react");
var format = require("util")["format"];
module.exports["React"] = React, module.exports["fmt"] = format;

For more information about the proposed syntax, see the wiki page on modules.

Install

$ npm install es6-modules-commonjs

Usage

$ node
> var compile = require('es6-modules-commonjs').compile;

Without arguments:

> compile('module util from "util";');
'var util = require("util");'

Browserify

Browserify support is built in.

$ npm install es6-modules-commonjs  # install local dependency
$ browserify -t es6-modules-commonjs $file

Setup

First, install the development dependencies:

$ npm install

Then, try running the tests:

$ npm test

Readme

Keywords

none

Package Sidebar

Install

npm i es6-modules-commonjs

Weekly Downloads

6

Version

0.1.3

License

none

Last publish

Collaborators

  • vslinko