square/esnext — pull request #3 by mduvall (2014-04-30 07:00:52+00:00)
Title: Add module syntax support using es6-module-transpiler

Took a swing at getting module syntax in, this is totally a proof-of-concept/WIP. Wanted to see if it was possible initially, ended up working fine and would appreciate feedback on this.

Not a fan of translating to source to transpile module syntax and throwing back up the AST after, any thoughts on a better approach?

```js
var compile = require('./lib/index').compile,
source = "var foo = (a, b) => {}, bar = 'bar'; f(...x); export { foo, bar };";

console.log(compile(source, {
modules: true
}).code);
```

produced

```js
define(
["exports"],
function(__exports__) {
"use strict";
var foo = function(a, b) {}, bar = 'bar'; f.apply(null, Array.prototype.slice.call(x)); __exports__.foo = foo;
__exports__.bar = bar;
});
```