0.1.3 • Published 11 years ago
es6-modules-commonjs v0.1.3
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-commonjsUsage
$ 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 $fileSetup
First, install the development dependencies:
$ npm installThen, try running the tests:
$ npm test