Skip to content

fix(js): ingest mjs cjs mts cts module extension variants - #810

Merged
vitali87 merged 3 commits into
mainfrom
fix/js-module-extension-variants
Jul 19, 2026
Merged

fix(js): ingest mjs cjs mts cts module extension variants#810
vitali87 merged 3 commits into
mainfrom
fix/js-module-extension-variants

Conversation

@vitali87

Copy link
Copy Markdown
Owner

Found dogfooding the flow edges: files with the .mjs, .cjs, .mts, and .cts extensions were not parsed at all. JS_EXTENSIONS stopped at .js/.jsx and TS_EXTENSIONS at .ts, so whole ESM packages, dual-package libraries, and modern config files (eslint.config.mjs and friends) were invisible to the graph: no Module or Function nodes, no CALLS, no IMPORTS, no IO or flow edges. The extensions were already listed in JS_TS_MODULE_EXTENSIONS for tsconfig path stripping, which made the gap easy to miss.

What changed

  • JS_EXTENSIONS gains .mjs/.cjs, TS_EXTENSIONS gains .mts/.cts, and JS_TS_ALL_EXTENSIONS covers all eight, so extensionless relative imports (import './util') also probe the new candidates during module resolution.
  • JS_TS_MODULE_EXTENSIONS gains .mts/.cts so tsconfig path targets strip them like the rest.

Tests

RED first (46f7c7a): four failing specs covering .mjs and .cjs function/call ingestion, .mts/.cts TypeScript variants, and extensionless import resolution to a .mjs file. GREEN in 8089173. Full suite: 5214 passed.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for additional JavaScript and TypeScript file extensions (.mjs, .cjs, .mts, and .cts) across the codebase, updating constants, documentation, and adding corresponding tests. The reviewer suggested adding .d.mts and .d.cts to JS_TS_MODULE_EXTENSIONS to ensure declaration files are correctly resolved and not incorrectly stripped.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread codebase_rag/constants/languages.py
@greptile-apps

greptile-apps Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds support for JavaScript and TypeScript module extension variants. The main changes are:

  • Adds .mjs and .cjs to JavaScript source discovery.
  • Adds .mts and .cts to TypeScript source discovery.
  • Extends JS/TS module resolution and tsconfig path stripping for the new variants.
  • Adds tests for parsing these files and resolving an extensionless import to .mjs.
  • Updates the language support docs and README tables.

Confidence Score: 5/5

Safe to merge with minimal risk.

The change is narrow and centralized around extension constants, docs, and focused tests. No correctness or security issues were identified in the changed paths.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • The exact pytest invocation for js-module-extension-variants was executed, capturing the working directory and the uv output that revealed a pymgclient build failure with exit code 1.
  • A blocker summary was reviewed, showing that the test cannot proceed due to a pymgclient build failure and the absence of a suitable cmake.
  • The blocker status was confirmed as blocked based on the summary of the build failure and missing cmake.
  • The artifact list was inspected to confirm which artifacts were produced during this validation.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
README.md Updates the supported-language table to document JavaScript and TypeScript module extension variants.
codebase_rag/constants/languages.py Adds .mjs/.cjs to JavaScript parsing, .mts/.cts to TypeScript parsing, and includes those variants in JS/TS module resolution and tsconfig path stripping.
codebase_rag/tests/test_js_module_extension_variants.py Adds tests for .mjs, .cjs, .mts, .cts, and extensionless imports resolving to .mjs.
docs/architecture/language-support.md Updates architecture documentation to list the newly supported JavaScript and TypeScript module extensions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Source file discovered] --> B{Extension}
B -->|.js .jsx .mjs .cjs| C[JavaScript LanguageSpec]
B -->|.ts .mts .cts| D[TypeScript LanguageSpec]
B -->|.tsx| E[TSX LanguageSpec]
C --> F[Parse functions/imports/calls]
D --> F
E --> F
G[Relative or tsconfig import target] --> H[Strip/probe JS_TS module extensions]
H --> I[Resolve module qualified name]
F --> J[Graph nodes and relationships]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Source file discovered] --> B{Extension}
B -->|.js .jsx .mjs .cjs| C[JavaScript LanguageSpec]
B -->|.ts .mts .cts| D[TypeScript LanguageSpec]
B -->|.tsx| E[TSX LanguageSpec]
C --> F[Parse functions/imports/calls]
D --> F
E --> F
G[Relative or tsconfig import target] --> H[Strip/probe JS_TS module extensions]
H --> I[Resolve module qualified name]
F --> J[Graph nodes and relationships]
Loading

Reviews (2): Last reviewed commit: "fix(js): strip d.mts and d.cts declarati..." | Re-trigger Greptile

@vitali87

Copy link
Copy Markdown
Owner Author

@greptile review

@sonarqubecloud

Copy link
Copy Markdown

@vitali87
vitali87 merged commit 5411000 into main Jul 19, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant