Skip to content

.mjs files detected but produce 0 nodes during extraction (incomplete fix for #365) #387

Closed

Description

@shaun0927

Summary

Issue #365 was closed as fixed in v0.4.15, but the fix is incomplete. .mjs files were added to CODE_EXTENSIONS in detect.py so they appear in corpus metrics, but were not added to the _DISPATCH table in extract.py. The extractor silently skips them, producing zero nodes and edges.

Users who upgraded to v0.4.15 expecting #365 to be resolved will see .mjs files counted in the detection summary but get no architectural insight from them.

Reproduction

from pathlib import Path
from graphify.detect import CODE_EXTENSIONS
from graphify.extract import extract
import tempfile

tmpdir = Path(tempfile.mkdtemp())
mjs = tmpdir / "app.mjs"
mjs.write_text('export function hello() { return "world"; }')

print(".mjs in CODE_EXTENSIONS:", ".mjs" in CODE_EXTENSIONS)  # True

result = extract([mjs], cache_root=tmpdir)
print("Nodes:", len(result["nodes"]))  # 0 — should be >= 2
print("Edges:", len(result["edges"]))  # 0

Output:

.mjs in CODE_EXTENSIONS: True
Nodes: 0
Edges: 0

Root cause

detect.py:21 includes .mjs in CODE_EXTENSIONS:

CODE_EXTENSIONS = {'.py', '.ts', '.js', ..., '.mjs', '.ejs', ...}

extract.py:3062-3098 — the _DISPATCH table has no entry for .mjs:

_DISPATCH = {
    ".py": extract_python,
    ".js": extract_js,
    # ... no .mjs entry
}

The extraction loop at line 3109 does extractor = _DISPATCH.get(path.suffix) which returns None, then continue at line 3111 silently skips the file.

PR #372 (which included the _DISPATCH addition) was closed without merge. The direct fix applied to v0.4.15 updated detect.py but missed extract.py.

Fix

Add ".mjs": extract_js to the _DISPATCH dict in extract(). .mjs is standard ES module JavaScript and should be parsed identically to .js by tree-sitter-javascript.

Note: .ejs was also added to CODE_EXTENSIONS and has the same dispatch gap. EJS is an HTML templating engine — it may be better suited to DOC_EXTENSIONS for semantic extraction rather than AST parsing. Happy to discuss the right approach.

Activity

  1. safishamsi commented on Apr 16, 2026

    @safishamsi
    Member

    Fixed in v0.4.16. pip install --upgrade graphifyy

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions