better wildcard imports and exports - fixes #224

This commit is contained in:
Sebastian McKenzie
2015-01-06 11:48:23 +11:00
parent 7526ae5486
commit 2558a5e12e
7 changed files with 51 additions and 15 deletions

View File

@@ -34,7 +34,8 @@ File.helpers = [
"define-property",
"async-to-generator",
"interop-require-wildcard",
"typeof"
"typeof",
"exports-wildcard"
];
File.excludeHelpersFromRuntime = [

View File

@@ -162,9 +162,9 @@ DefaultFormatter.prototype._exportSpecifier = function (getRef, specifier, node,
};
DefaultFormatter.prototype._exportsWildcard = function (objectIdentifier) {
return util.template("exports-wildcard", {
OBJECT: objectIdentifier
}, true);
return t.expressionStatement(t.callExpression(this.file.addHelper("exports-wildcard"), [
t.callExpression(this.file.addHelper("interop-require-wildcard"), [objectIdentifier])
]));
};
DefaultFormatter.prototype._exportsAssign = function (id, init) {

View File

@@ -1,5 +1,7 @@
(function (obj) {
for (var i in obj) {
exports[i] = obj[i];
if (exports[i] !== undefined) {
exports[i] = obj[i];
}
}
})(OBJECT);
})