Skip to content

fix(extraction): index CommonJS export assignments as functions - #1771

Merged
colbymchenry merged 3 commits into
mainfrom
forge/fix-1675-commonjs-exports
Sep 8, 2026
Merged

colbymchenry merged 3 commits into
mainfrom
forge/fix-1675-commonjs-exports

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Fixes #1675.

Lands / conflict-resolves upstream #1678 onto current main (post-#1770 / #1684).

Problem

exports.getItems = async (req, res) => {…} and module.exports.deleteItem = function (req, res) {…} — the common Express/CommonJS controller style — produced no function node. The arrow's parent is an assignment_expression, not a variable_declarator, so extractFunction left it <anonymous>, walked its body at file scope (calls attributed to the file), and codegraph node getItems / callers answered "Symbol not found" for a route-wired handler.

Change

  • extractFunction (wasm walker) and extract_function (kernel) resolve the name from the export property when the function is the whole right-hand side of exports.NAME = … / module.exports.NAME = …, and mark the node exported. Any other member assignment (handlers.onSave = () => {}) is untouched.
  • Both arms move together; torture.js gains the shapes so kernel-tsjs-parity pins them.

Verification (Linux)

  • Reproduced on main: handlers → no function nodes.
  • After fix: __tests__/commonjs-exports.test.ts passes 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.

danusha2345 and others added 3 commits September 3, 2026 15:25
`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
Resolve CHANGELOG conflict: keep #1675 CommonJS export entry and #1684
quoted Python annotation entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CommonJS exports.X = async () => {} route handlers aren't indexed as symbols

1 participant