fix(js): ingest mjs cjs mts cts module extension variants - #810
Conversation
There was a problem hiding this comment.
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.
Greptile SummaryThis PR adds support for JavaScript and TypeScript module extension variants. The main changes are:
Confidence Score: 5/5Safe 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.
What T-Rex did
Important Files Changed
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]
%%{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]
Reviews (2): Last reviewed commit: "fix(js): strip d.mts and d.cts declarati..." | Re-trigger Greptile |
|
@greptile review |
|



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_EXTENSIONSgains.mjs/.cjs,TS_EXTENSIONSgains.mts/.cts, andJS_TS_ALL_EXTENSIONScovers all eight, so extensionless relative imports (import './util') also probe the new candidates during module resolution.JS_TS_MODULE_EXTENSIONSgains.mts/.ctsso 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.