@babel/traverse
Advanced tools
Comparing version 7.25.9 to 7.26.3
@@ -7,2 +7,3 @@ "use strict"; | ||
exports._call = _call; | ||
exports._forceSetScope = _forceSetScope; | ||
exports._getQueueContexts = _getQueueContexts; | ||
@@ -112,2 +113,16 @@ exports._resyncKey = _resyncKey; | ||
} | ||
function _forceSetScope(current) { | ||
var _current$scope; | ||
let path = current.parentPath; | ||
if ((current.key === "key" || current.listKey === "decorators") && path.isMethod() || current.key === "discriminant" && path.isSwitchStatement()) { | ||
path = path.parentPath; | ||
} | ||
let target; | ||
while (path && !target) { | ||
target = path.scope; | ||
path = path.parentPath; | ||
} | ||
current.scope = current.getScope(target); | ||
(_current$scope = current.scope) == null || _current$scope.init(); | ||
} | ||
function setScope() { | ||
@@ -114,0 +129,0 @@ var _this$opts2, _this$scope; |
@@ -14,3 +14,3 @@ "use strict"; | ||
const Referenced = exports.Referenced = null; | ||
const BlockScoped = exports.BlockScoped = null; | ||
const BlockScoped = exports.BlockScoped = ["FunctionDeclaration", "ClassDeclaration", "VariableDeclaration"]; | ||
const Var = exports.Var = ["VariableDeclaration"]; | ||
@@ -17,0 +17,0 @@ const User = exports.User = null; |
@@ -71,6 +71,6 @@ "use strict"; | ||
key | ||
} = path; parentPath; ({ | ||
} = path; parentPath; { | ||
parentPath, | ||
key | ||
} = parentPath)) { | ||
} = parentPath) { | ||
if (parentPath.isFunctionParent()) return false; | ||
@@ -77,0 +77,0 @@ if (parentPath.isWhile() || parentPath.isForXStatement() || parentPath.isForStatement() && key === "body") { |
@@ -9,2 +9,3 @@ "use strict"; | ||
var _index = require("../index.js"); | ||
var _traverseForScope = require("./traverseForScope.js"); | ||
var _binding = require("./binding.js"); | ||
@@ -636,4 +637,10 @@ var _globals = require("globals"); | ||
this.data = Object.create(null); | ||
const programParent = this.getProgramParent(); | ||
if (programParent.crawling) return; | ||
let scope = this; | ||
do { | ||
if (scope.crawling) return; | ||
if (scope.path.isProgram()) { | ||
break; | ||
} | ||
} while (scope = scope.parent); | ||
const programParent = scope; | ||
const state = { | ||
@@ -646,5 +653,2 @@ references: [], | ||
if (path.type !== "Program" && (0, _visitors.isExplodedVisitor)(collectorVisitor)) { | ||
for (const visit of collectorVisitor.enter) { | ||
visit.call(state, path, state); | ||
} | ||
const typeVisitors = collectorVisitor[path.type]; | ||
@@ -657,3 +661,3 @@ if (typeVisitors) { | ||
} | ||
path.traverse(collectorVisitor, state); | ||
(0, _traverseForScope.default)(path, collectorVisitor, state); | ||
this.crawling = false; | ||
@@ -660,0 +664,0 @@ for (const path of state.assignments) { |
@@ -56,7 +56,5 @@ "use strict"; | ||
for (const type of types) { | ||
if (visitor[type]) { | ||
mergePair(visitor[type], fns); | ||
} else { | ||
visitor[type] = fns; | ||
} | ||
var _visitor$type; | ||
(_visitor$type = visitor[type]) != null ? _visitor$type : visitor[type] = {}; | ||
mergePair(visitor[type], fns); | ||
} | ||
@@ -108,3 +106,3 @@ } else { | ||
if (!TYPES.includes(nodeType)) { | ||
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"7.25.9"}`); | ||
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"7.26.3"}`); | ||
} | ||
@@ -111,0 +109,0 @@ const visitors = visitor[nodeType]; |
{ | ||
"name": "@babel/traverse", | ||
"version": "7.25.9", | ||
"version": "7.26.3", | ||
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes", | ||
@@ -19,7 +19,7 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
"dependencies": { | ||
"@babel/code-frame": "^7.25.9", | ||
"@babel/generator": "^7.25.9", | ||
"@babel/parser": "^7.25.9", | ||
"@babel/code-frame": "^7.26.2", | ||
"@babel/generator": "^7.26.3", | ||
"@babel/parser": "^7.26.3", | ||
"@babel/template": "^7.25.9", | ||
"@babel/types": "^7.25.9", | ||
"@babel/types": "^7.26.3", | ||
"debug": "^4.3.1", | ||
@@ -29,3 +29,3 @@ "globals": "^11.1.0" | ||
"devDependencies": { | ||
"@babel/core": "^7.25.9", | ||
"@babel/core": "^7.26.0", | ||
"@babel/helper-plugin-test-runner": "^7.25.9" | ||
@@ -32,0 +32,0 @@ }, |
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
Sorry, the diff of this file is not supported yet
680848
63
5699
Updated@babel/code-frame@^7.26.2
Updated@babel/generator@^7.26.3
Updated@babel/parser@^7.26.3
Updated@babel/types@^7.26.3