Repository navigation
Description
Summary
On clean v0.9.103, a constructor call resolves to its class when the module is required directly. If an index.js file re-exports that class and the consumer uses destructuring to require it from the barrel, the calls edge disappears.
This affects a real ESLint pattern: createSourceCode obtains SourceCode through source-code/index.js. The same graph was extracted in one batch, so this is not an incremental-update case.
Reproduction
Run from a clean v0.9.103 checkout with the JavaScript tree-sitter extra installed. The script creates all three JavaScript files itself:
from pathlib import Path
from tempfile import TemporaryDirectory
from graphify.extract import extract
cases = {
"direct": "const SourceCode = require('./source');\nfunction create() { return new SourceCode(); }\n",
"barrel": "const { SourceCode } = require('./index');\nfunction create() { return new SourceCode(); }\n",
}
for name, caller in cases.items():
with TemporaryDirectory() as tmp:
root = Path(tmp)
files = {
"source.js": "class SourceCode {}\nmodule.exports = SourceCode;\n",
"index.js": "const SourceCode = require('./source');\nmodule.exports = { SourceCode };\n",
"consumer.js": caller,
}
for filename, source in files.items():
(root / filename).write_text(source, encoding="utf-8")
graph = extract([root / f for f in files], cache_root=root / "cache", root=root, parallel=False)
nodes = {n["id"]: n for n in graph["nodes"]}
calls = [(nodes[e["target"]]["label"], Path(nodes[e["target"]]["source_file"]).name)
for e in graph["edges"] if e["relation"] == "calls"
and nodes.get(e["source"], {}).get("label") == "create()"
and e["target"] in nodes]
print(name, sorted(calls))Observed (extractor progress and warnings omitted):
direct [('SourceCode', 'source.js')]
barrel []
Expected: both cases emit create() -> SourceCode with the target in source.js.
Related
#4688 was closed after improving resolution of CommonJS imports and exports. This is a remaining call-resolution case through a destructured re-export; the reproduction above does not claim the original extends case is still broken. #4621 is the earlier binding-shadowing report.
Environment
Clean v0.9.103, Windows 11, Python 3.12. No operating-system dependency has been established.
Activity
github-actions commentedon Nov 5, 2026
Thanks for opening this issue, @sub4biz. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
fix: resolve calls through destructured CommonJS barrel requires
fix: resolve calls through destructured CommonJS barrel requires