Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

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

Keywords

none

install

npm i es6-modules-commonjs

Downloadsweekly downloads

4

version

0.1.3

license

none

last publish

collaborators

  • avatar
Report a vulnerability