Skip to content

fix(extractor): capture static CommonJS imports and exports - #715

Open
xiehuanyi wants to merge 2 commits into
Egonex-AI:mainfrom
xiehuanyi:fix/commonjs-structural-extraction-615
Open

xiehuanyi wants to merge 2 commits into
Egonex-AI:mainfrom
xiehuanyi:fix/commonjs-structural-extraction-615

Conversation

@xiehuanyi

@xiehuanyi xiehuanyi commented Oct 6, 2026 •

Copy link
Copy Markdown

Summary

Capture common top-level CommonJS require imports and named/default exports/module.exports assignments in the JavaScript and TypeScript structural extractor. Destructuring aliases/defaults, side-effect imports, static template paths, object barrels, and literal export keys are supported; dynamic paths, unrelated member calls, and shadowed CommonJS names are ignored. Node createRequire bridges from node:module/module remain recognized, including aliases and namespace imports. Mixed ES-module extraction is preserved, and the README explains the one-time fingerprint baseline change after upgrading.

Linked issue(s)

Closes #615. This fixes the direct extractor API, which still returned empty import/export arrays on current main; the import inventory improvements in #682 are preserved.

How I tested this

The issue's built TreeSitterPlugin.analyzeFile() reproduction changes from zero imports/exports to two imports and one deduplicated list export. The original 22 grammar-backed regressions include 18 failures on the original extractor and four passing negative controls. Fourteen additional JavaScript/TypeScript regressions cover shadowed require/module/exports and supported Node bridge forms, for 36 focused cases. The supplemental-import incremental fixture now uses a function-body dependency, retaining coverage for cosmetic edits while top-level requires correctly affect fingerprints.

  • pnpm lint
  • pnpm --filter @understand-anything/core test — 1,049 passing
  • pnpm test — 786 passing, 12 skipped
  • Core TypeScript build
  • Built-package API reproduction

Inline assigned named functions currently produce an export entry without a function node; that remains a known limitation.

Versioning

  • Version bumped to 2.9.8 in all six manifests listed in CLAUDE.md

Copilot AI balanced review requested due to automatic review settings October 6, 2026 08:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
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.

bug: TypeScriptExtractor ignores CommonJS, so require()/module.exports files extract with no imports or exports

2 participants