fix(javascript): handle deep AST traversal and addition without stack overflow (#915)

* fix(javascript): avoid recursion and eager ancestry copies in deep ASTs

* fix(javascript): traverse static analysis and bundler ASTs iteratively
This commit is contained in:
morluto authored and GitHub committed 2026-10-07 17:40:05 +08:00
1 parent f6a58f1062
commit 62b37111e7
9 files changed
+203 -40

No files matched your search

@@ -100,9 +100,9 @@ export const collectSemanticReferences = (
const output: JavaScriptSemanticReference[] = [];
const seen = new Set<string>();
traverseJavaScriptAst(program, {
enter: (node, parent, ancestors) => {
enter: (node, parent, readAncestors) => {
if (!t.isIdentifier(node) || parent === null) return;
const role = semanticIdentifierRole(node, parent, ancestors);
const role = semanticIdentifierRole(node, parent, readAncestors());
if (role === null) return;
// A compound assignment or update reads before it writes; emit both so
// reference consumers see the read they actually execute.