feat: add .mjs/.astro extension support and fix IMPORTS_FROM path resolution#58
Closed
zoneghost7 wants to merge 1 commit intotirth8205:mainfrom
Closed
Conversation
…olution Extension mappings: - Add ".mjs": "javascript" — standard ES module files (test suites, configs like astro.config.mjs) were silently skipped during parsing. - Add ".astro": "typescript" — Astro framework files have TypeScript frontmatter between --- fences. The TypeScript tree-sitter grammar parses the frontmatter cleanly, extracting imports and function definitions while silently skipping the HTML template section. Import resolution fix: - IMPORTS_FROM edges previously stored raw import strings (e.g., "../../lib/data-service") as the target_qualified value. Query patterns like importers_of and find_dependents look up edges by absolute file path, so they returned zero results for all IMPORTS_FROM edges. - The fix calls _resolve_module_to_file (already used for CALLS edge resolution) when creating IMPORTS_FROM edges. Relative imports are resolved to absolute paths; unresolvable imports (node built-ins, external packages, virtual modules) fall back to the raw string. - This fixes: importers_of queries, find_dependents for incremental rebuilds, and blast radius traversal of import edges. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
tirth8205
added a commit
that referenced
this pull request
Mar 26, 2026
Adds .mjs extension mapping to JavaScript and .astro extension mapping to TypeScript for import path resolution. Co-Authored-By: zoneghost7 <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 tasks
tirth8205
added a commit
that referenced
this pull request
Mar 26, 2026
…nfigurable embeddings, MiniMax, Perl) * feat: integrate PR #43 — R language support Adds R language parsing with function extraction (both <- and = assignment), S4/R5 class detection via setClass/setRefClass, library/require/source imports, namespace-qualified calls (dplyr::filter), and testthat test detection. Co-Authored-By: michael-denyer <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #54 — Vitest/Jest test detection Adds describe/it/test block parsing for JS/TS test files, producing synthetic Test nodes with description labels. Supports modifier suffixes (describe.only, it.skip, test.each) and nested describe/it containment. Co-Authored-By: JF10R <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #53 — tsconfig path alias resolution Adds TsconfigResolver module that resolves TypeScript path aliases (e.g., @/ -> src/) from tsconfig.json compilerOptions.paths. Also resolves import targets to absolute file paths in IMPORTS_FROM edges. Co-Authored-By: JF10R <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #58 — .mjs/.astro support Adds .mjs extension mapping to JavaScript and .astro extension mapping to TypeScript for import path resolution. Co-Authored-By: zoneghost7 <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #55 — configurable embedding model Adds CRG_EMBEDDING_MODEL env var and model parameter to embedding functions, allowing users to specify any sentence-transformers compatible model. Changing the model re-embeds all nodes automatically. Co-Authored-By: eugenepro2 <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #45 — MiniMax embedding provider Adds MiniMaxEmbeddingProvider using the embo-01 model (1536 dimensions) with support for distinct task types (db/query), batching, and retry logic. Co-Authored-By: octo-patch <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #62 — Perl support Adds Perl language parsing with package detection, subroutine extraction, use/require imports, and function call tracking. Includes test fixture and comprehensive test class. Co-Authored-By: potatogim <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: michael-denyer <noreply@github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
|
Integrated into main via PR #68. Thank you for the contribution! 🎉 |
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.
Summary
Two changes to
parser.py:1. Extension mappings for
.mjsand.astrofiles.mjs→javascript: Standard ES module files (.mjs) are widely used for test suites (*.test.mjs), configs (astro.config.mjs,rollup.config.mjs), and any project preferring explicit ESM. These were silently skipped during parsing. Since.mjsis standard JavaScript with ES module semantics, mapping tojavascriptis correct..astro→typescript: Astro framework files have TypeScript frontmatter between---fences followed by an HTML template section. Tree-sitter's TypeScript grammar parses the frontmatter cleanly — extracting imports, function definitions, and call expressions — while silently skipping the template section (no parse errors). This gives useful graph coverage (imports, functions, calls) for Astro projects without requiring a dedicated Astro grammar.2. Fix IMPORTS_FROM edge path resolution
Problem:
IMPORTS_FROMedges store the raw import string astarget_qualified(e.g.,../../lib/data-service). However, query patterns likeimporters_ofandfind_dependentslook up edges by absolute file path. This mismatch causes:importers_ofreturns zero results for every file — the query searches for/abs/path/to/file.tsbut the database contains../../lib/data-servicefind_dependents()inincremental.pyfails to identify downstream files during incremental rebuilds — editing a core library file won't trigger re-parsing of its importersIMPORTS_FROMtraversal paths, only finding connections viaCALLSedgesRoot cause:
_resolve_module_to_file()is called when creatingCALLSedges (via_resolve_call_target) but is never called forIMPORTS_FROMedges.Fix: Call
_resolve_module_to_file()when creatingIMPORTS_FROMedges (lines 601-607). If resolution succeeds, store the absolute path; if it fails (node built-ins likenode:fs, external packages likereact, virtual modules likeastro:content), fall back to the raw string. This is the same graceful-fallback pattern used forCALLSedges.Before:
After:
Edge cases handled
../../lib/utils_resolve_module_to_file./Component.astro./utils(dir with index.ts)node:fsNone→ fallbacknode:fs(raw)reactNone→ fallbackreact(raw)astro:contentNone→ fallbackastro:content(raw)./deletedNone→ fallback./deleted(raw)Test plan
.mjstest files — verify.mjsfiles appear in graph stats.astrofiles are parsed, imports and functions extracted, no errorsimporters_ofquery returns correct results for files with relative importsfind_dependentscorrectly identifies downstream filesIMPORTS_FROMedgesnode:fs,react, etc.) stored as raw strings (no regression)🤖 Generated with Claude Code