Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vslinko/es6-modules-commonjs
https://github.com/vslinko/es6-modules-commonjs
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/vslinko/es6-modules-commonjs
- Owner: vslinko
- License: mit
- Created: 2014-05-25T15:39:41.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-05-25T23:12:10.000Z (over 10 years ago)
- Last Synced: 2024-09-21T00:33:19.407Z (about 2 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# es6-modules-commonjs
Compiles JavaScript written using ES6 modules to CommonJS syntax.
For example, this:```js
module React from "react";
import {format} from "util";
export {React, format as fmt};
```compiles to this:
```js
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](http://wiki.ecmascript.org/doku.php?id=harmony:modules).## Install
```
$ npm install es6-modules-commonjs
```## Usage
```js
$ node
> var compile = require('es6-modules-commonjs').compile;
```Without arguments:
```js
> 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
```