fix(extraction): index CommonJS export assignments as functions - #1771
Merged
Merged
Conversation
`exports.getItems = async (req, res) => {…}` and `module.exports.x =
function () {…}` — the Express controller style — produced no symbol: the
arrow's parent is an assignment, not a declarator, so it stayed anonymous,
its calls attributed to the file, and `node`/`callers` answered "Symbol
not found" for a route-wired handler. Resolve the name from the export
property, mark it exported, in both the wasm walker and the kernel.
…orts-handlers # Conflicts: # CHANGELOG.md # __tests__/fixtures/kernel-parity/torture.js
This was referenced Sep 8, 2026
This was referenced Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1675.
Lands / conflict-resolves upstream #1678 onto current
main(post-#1770 / #1684).Problem
exports.getItems = async (req, res) => {…}andmodule.exports.deleteItem = function (req, res) {…}— the common Express/CommonJS controller style — produced no function node. The arrow's parent is anassignment_expression, not avariable_declarator, soextractFunctionleft it<anonymous>, walked its body at file scope (calls attributed to the file), andcodegraph node getItems/callersanswered "Symbol not found" for a route-wired handler.Change
extractFunction(wasm walker) andextract_function(kernel) resolve the name from the export property when the function is the whole right-hand side ofexports.NAME = …/module.exports.NAME = …, and mark the node exported. Any other member assignment (handlers.onSave = () => {}) is untouched.torture.jsgains the shapes sokernel-tsjs-paritypins them.Verification (Linux)
main: handlers → no function nodes.__tests__/commonjs-exports.test.tspasses with wasm (CODEGRAPH_DISABLE_KERNEL=1) and kernel (CODEGRAPH_KERNEL_EXPECT=1).CODEGRAPH_KERNEL_EXPECT=1__tests__/kernel-tsjs-parity.test.ts: 17 passed.Re-index JavaScript projects after upgrading.
Credit: @danusha2345 via #1678.