Merge pull request #468 from AluisioASG/core-aliasable

Whitelist constructors aliasable to core-js
This commit is contained in:
Sebastian McKenzie
2015-01-13 01:46:19 +11:00
6 changed files with 25 additions and 15 deletions

View File

@@ -8,6 +8,16 @@ var coreHas = function (node) {
return node.name !== "_" && _.has(core, node.name);
};
var ALIASABLE_CONSTRUCTORS = [
"Symbol",
"Promise",
"Map",
"WeakMap",
"Set",
"WeakSet",
"Dict",
];
exports.optional = true;
exports.ast = {
@@ -31,8 +41,8 @@ exports.ast = {
this.skip();
return t.prependToMemberExpression(node, file._coreId);
}
} else if (t.isIdentifier(node) && !t.isMemberExpression(parent) && t.isReferenced(node, parent) && node.name === "Symbol") {
// new Symbol -> new _core.Symbol
} else if (t.isIdentifier(node) && !t.isMemberExpression(parent) && t.isReferenced(node, parent) && _.contains(ALIASABLE_CONSTRUCTORS, node.name)) {
// Symbol() -> _core.Symbol(); new Promise -> new _core.Promise
return t.memberExpression(file._coreId, node);
} else if (t.isCallExpression(node)) {
// arr[Symbol.iterator]() -> _core.$for.getIterator(arr)