fix SystemJS module formatter exporting function parameters - fixes #2681

This commit is contained in:
Sebastian McKenzie 2015-10-30 17:05:26 +00:00
parent 3a7d258c5c
commit 26cb025151
4 changed files with 20 additions and 6 deletions

View File

@ -3,3 +3,5 @@ export {foo, bar};
export {foo as bar};
export {foo as default};
export {foo as default, bar};
export function foo() {}
export function foo2(bar) {}

View File

@ -17,6 +17,14 @@ System.register([], function (_export) {
_export("default", foo);
_export("bar", bar);
function foo() {}
_export("foo", foo);
function foo2(bar) {}
_export("foo2", foo2);
}
};
});
});

View File

@ -13,8 +13,6 @@ System.register(["./evens"], function (_export) {
_export("nextOdd", nextOdd);
_export("n", n);
_export("p", p = 5);
_export("p", p);
@ -32,4 +30,4 @@ System.register(["./evens"], function (_export) {
_export("isOdd", isOdd);
}
};
});
});

View File

@ -50,7 +50,7 @@ export default function ({ types: t }) {
return {
inherits: require("babel-plugin-transform-strict-mode"),
visitor: {
Program: {
exit(path) {
@ -136,7 +136,13 @@ export default function ({ types: t }) {
path.replaceWith(declar);
let nodes = [];
for (let name in declar.getBindingIdentifiers()) {
let bindingIdentifiers;
if (path.isFunction()) {
bindingIdentifiers = { [declar.node.id.name]: declar.node.id };
} else {
bindingIdentifiers = declar.getBindingIdentifiers();
}
for (let name in bindingIdentifiers) {
addExportName(name, name);
nodes.push(buildExportCall(name, t.identifier(name)));
}