@babel/helper-define-polyfill-provider
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -173,2 +173,16 @@ "use strict"; | ||
} = (0, _normalizeOptions.validateIncludeExclude)(providerName, polyfillsNames, providerOptions.include || [], providerOptions.exclude || [])); | ||
let callProvider; | ||
if (methodName === "usageGlobal") { | ||
callProvider = (payload, path) => { | ||
var _ref; | ||
const utils = getUtils(path); | ||
return (_ref = provider[methodName](payload, utils, path)) != null ? _ref : false; | ||
}; | ||
} else { | ||
callProvider = (payload, path) => { | ||
const utils = getUtils(path); | ||
provider[methodName](payload, utils, path); | ||
return false; | ||
}; | ||
} | ||
return { | ||
@@ -180,6 +194,3 @@ debug, | ||
providerName, | ||
callProvider(payload, path) { | ||
const utils = getUtils(path); | ||
provider[methodName](payload, utils, path); | ||
} | ||
callProvider | ||
}; | ||
@@ -186,0 +197,0 @@ } |
@@ -6,2 +6,12 @@ "use strict"; | ||
var _utils = require("../utils"); | ||
function isRemoved(path) { | ||
if (path.removed) return true; | ||
if (!path.parentPath) return false; | ||
if (path.listKey) { | ||
if (!path.parentPath.node[path.listKey].includes(path.node)) return true; | ||
} else { | ||
if (path.parentPath.node[path.key] !== path.node) return true; | ||
} | ||
return isRemoved(path.parentPath); | ||
} | ||
var _default = callProvider => { | ||
@@ -16,16 +26,25 @@ function property(object, key, placement, path) { | ||
} | ||
function handleReferencedIdentifier(path) { | ||
const { | ||
node: { | ||
name | ||
}, | ||
scope | ||
} = path; | ||
if (scope.getBindingIdentifier(name)) return; | ||
callProvider({ | ||
kind: "global", | ||
name | ||
}, path); | ||
} | ||
return { | ||
// Symbol(), new Promise | ||
ReferencedIdentifier(path) { | ||
const { | ||
node: { | ||
name | ||
}, | ||
scope | ||
} = path; | ||
if (scope.getBindingIdentifier(name)) return; | ||
callProvider({ | ||
kind: "global", | ||
name | ||
}, path); | ||
if (path.parentPath.isMemberExpression({ | ||
object: path.node | ||
})) { | ||
// Handled in the MemberExpression visitor | ||
return; | ||
} | ||
handleReferencedIdentifier(path); | ||
}, | ||
@@ -36,8 +55,14 @@ MemberExpression(path) { | ||
const object = path.get("object"); | ||
if (object.isIdentifier()) { | ||
let objectIsGlobalIdentifier = object.isIdentifier(); | ||
if (objectIsGlobalIdentifier) { | ||
const binding = object.scope.getBinding(object.node.name); | ||
if (binding && binding.path.isImportNamespaceSpecifier()) return; | ||
if (binding) { | ||
if (binding.path.isImportNamespaceSpecifier()) return; | ||
objectIsGlobalIdentifier = false; | ||
} | ||
} | ||
const source = (0, _utils.resolveSource)(object); | ||
return property(source.id, key, source.placement, path); | ||
let skipObject = property(source.id, key, source.placement, path); | ||
skipObject || (skipObject = !objectIsGlobalIdentifier || path.shouldSkip || object.shouldSkip || isRemoved(object)); | ||
if (!skipObject) handleReferencedIdentifier(object); | ||
}, | ||
@@ -44,0 +69,0 @@ ObjectPattern(path) { |
{ | ||
"name": "@babel/helper-define-polyfill-provider", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Babel helper to create your own polyfill provider", | ||
@@ -58,3 +58,3 @@ "repository": { | ||
}, | ||
"gitHead": "9738ea2a12643376a52c9be30c20ac19426a88cb" | ||
"gitHead": "58703f07c9cff9f27d145215265042094739a175" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
218498
2531