Skip to content

vslinko/es6-modules-commonjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages