Skip to content

[Bug]: .cjs files are not indexed (EXTENSION_TO_LANGUAGE has .mjs but no .cjs) #1117

Open

Description

@enjay27

code-review-graph version

2.3.9 (also present on staging at d72e8fb)

Operating system

Windows (the extension map is the same on every OS)

Python version

3.13.14

AI platform

Claude Code

Output of code-review-graph status

Nodes: 2
Edges: 1
Files: 1
Languages: javascript

Steps to reproduce

git init repro && cd repro
printf 'function helper() { return 1; }\nmodule.exports = { helper };\n' > util.cjs
printf "const { helper } = require('./util.cjs');\nfunction run() { return helper(); }\n" > main.cjs
printf 'function same() { return 1; }\n' > same.js
git add . && code-review-graph build && code-review-graph status

Expected vs actual behavior

Expected: three files indexed. That means util.cjs::helper, main.cjs::run, the require import, and the run → helper call.

Actual: Full build: 1 files, 2 nodes, 1 edges. Only same.js is indexed.

parser.EXTENSION_TO_LANGUAGE maps .js, .jsx and .mjs to javascript but has no .cjs entry. So detect_language returns None and every build skips the file. The resolver already knows .cjs specifiers (#866 maps them to .cts sources), but a .cjs file itself is never parsed.

Additional context

CommonJS .cjs files are common in packages whose default is ESM, for example Node scripts and git or editor hooks. In such a repository those files get no graph. A one-line fix with tests is ready; I'll open a PR against staging that links this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions