6to5/6to5 — pull request #307 by douglasduteil (2014-12-17 02:34:50+00:00)
Title: feat(system-module): rewrite

> Following #209 #213 and 136bddab33686133f3c05bedd2773d0877a43a22
>
> Here is my rewrite of the --module system transform.

#### This PR still fails 3 tests !
@guybedford @sebmck > Can you clarify some behave for me ?

---

- [ ] @sebmck > When transforming a exported constant in [`test/fixtures/transformation/es6-modules-system/exports-variable/actual.js#L6`](https://github.com/6to5/6to5/blob/v1.15.0/test/fixtures/transformation/.es6-modules-system/exports-variable/actual.js#L6):

```js
export const foo6 = 3;
// is transformed to
const foo6 = 3;
```

**Is it normal ?**

> For me,
> The "normal" transformation through
>
```js
SystemFormatter.prototype.import =
SystemFormatter.prototype.export = function (node, nodes) {
nodes.push(node);
};
```
> must change
```js
export const foo6 = 3;
// to
export var foo6 = 3;
```
> before the `SystemFormatter.prototype.transform` occur.

---

- [ ] @guybedford > When transforming exported default class in [`test/fixtures/transformation/es6-modules-system/exports-default/actual.js#L6`](https://github.com/6to5/6to5/blob/v1.15.0/test/fixtures/transformation/.es6-modules-system/exports-default/actual.js#L6):

```js
export default class {}

// You expect :

System.register("actual", [], function (_export) {
"use strict";

var __moduleName = "actual";

var _anonymous;
return {
setters: [],
execute: function () {
_export("default", _anonymous = function _anonymous() {});
}
};
});

// However I'm generating :

System.register("actual", [], function (_export) {
"use strict";

var __moduleName = "actual";

function _anonymous() {}

return {
setters: [],
execute: function () {
_export("default", _anonymous);
}
};
});

```

**Is it still bad ?**

> BTW Adding method in the class generates
```js
export default class Bar{ get foo(){} }
>
// to
>
System.register("actual", [], function (_export) {
"use strict";
>
var __moduleName = "actual";
>
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
>
return {
setters: [],
execute: function () {
_export("default", (function () {
var Bar = function Bar() {};
>
_classProps(Bar, null, {
foo: {
get: function () {}
}
});
>
return Bar;
})());
}
};
});
```
> Here I don't think `Bar` will be available in the rest of the code... **Does it's matter ?**

---

- [ ] @guybedford > When transforming exported a named function in [`test/fixtures/transformation/es6-modules-system/hoist-function-exports/actual.js#L3`](https://github.com/6to5/6to5/blob/v1.15.0/test/fixtures/transformation/.es6-modules-system/hoist-function-exports/actual.js#L3):

```js
export function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
}

// You expect :

System.register("actual", ["./evens"], function (_export) {
"use strict";

var __moduleName = "actual";
var isEven;

function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
}
_export("nextOdd", nextOdd);

return {
setters: [function (m) {
isEven = m.isEven;
}],
execute: function () {}
};
});

// However I'm generating :

System.register("actual", ["./evens"], function (_export) {
"use strict";

var __moduleName = "actual";
var isEven;

function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
}

return {
setters: [function (m) {
isEven = m.isEven;
}],
execute: function () {
_export("nextOdd", nextOdd);
}
};
});
```

**What is this `_export` here ?**

---

Thanks

@douglasduteil.