From 06823fbf1c2e763a5bf76c3990ca98fbbcd98691 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Tue, 14 May 2024 14:05:49 +0800 Subject: updated node_modules --- .../lib/visitors/usage.js | 66 +++++++++++++++++----- 1 file changed, 52 insertions(+), 14 deletions(-) (limited to 'node_modules/@babel/helper-define-polyfill-provider/lib/visitors') diff --git a/node_modules/@babel/helper-define-polyfill-provider/lib/visitors/usage.js b/node_modules/@babel/helper-define-polyfill-provider/lib/visitors/usage.js index 4a4c5472..77def9f8 100644 --- a/node_modules/@babel/helper-define-polyfill-provider/lib/visitors/usage.js +++ b/node_modules/@babel/helper-define-polyfill-provider/lib/visitors/usage.js @@ -3,6 +3,17 @@ exports.__esModule = true; exports.default = void 0; var _utils = require("../utils"); +function isRemoved(path) { + if (path.removed) return true; + if (!path.parentPath) return false; + if (path.listKey) { + var _path$parentPath$node; + if (!((_path$parentPath$node = path.parentPath.node) != null && (_path$parentPath$node = _path$parentPath$node[path.listKey]) != null && _path$parentPath$node.includes(path.node))) return true; + } else { + if (path.parentPath.node[path.key] !== path.node) return true; + } + return isRemoved(path.parentPath); +} var _default = callProvider => { function property(object, key, placement, path) { return callProvider({ @@ -12,31 +23,58 @@ var _default = callProvider => { placement }, path); } + function handleReferencedIdentifier(path) { + const { + node: { + name + }, + scope + } = path; + if (scope.getBindingIdentifier(name)) return; + callProvider({ + kind: "global", + name + }, path); + } + function analyzeMemberExpression(path) { + const key = (0, _utils.resolveKey)(path.get("property"), path.node.computed); + return { + key, + handleAsMemberExpression: !!key && key !== "prototype" + }; + } return { // Symbol(), new Promise ReferencedIdentifier(path) { const { - node: { - name - }, - scope + parentPath } = path; - if (scope.getBindingIdentifier(name)) return; - callProvider({ - kind: "global", - name - }, path); + if (parentPath.isMemberExpression({ + object: path.node + }) && analyzeMemberExpression(parentPath).handleAsMemberExpression) { + return; + } + handleReferencedIdentifier(path); }, MemberExpression(path) { - const key = (0, _utils.resolveKey)(path.get("property"), path.node.computed); - if (!key || key === "prototype") return; + const { + key, + handleAsMemberExpression + } = analyzeMemberExpression(path); + if (!handleAsMemberExpression) return; 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); }, ObjectPattern(path) { const { -- cgit v1.2.3