Make buildExportAll generate pure ES5 code.

The untransformed `let` keyword causes problems for older parsers. I
understand using `let` instead of `var` ensures each getter function has
its own binding for the KEY variable, but the same can be accomplished
(with less code) using a `.forEach` callback function, and this way
there's no need to worry about generating a unique name for the `key`
variable.
This commit is contained in:
Ben Newman
2016-03-02 00:08:50 -05:00
parent f4197cc77b
commit 9acd33b93a
6 changed files with 30 additions and 49 deletions

View File

@@ -4,17 +4,15 @@ define(["exports", "foo"], function (exports, _foo) {
Object.defineProperty(exports, "__esModule", {
value: true
});
for (let _key in _foo) {
if (_key === "default") continue;
Object.defineProperty(exports, _key, {
Object.keys(_foo).forEach(function (key) {
if (key === "default") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _foo[_key];
return _foo[key];
}
});
}
});
Object.defineProperty(exports, "foo", {
enumerable: true,
get: function () {