Skip to content

fix(extraction): index .mts and .cts files#394

Open
balloon72 wants to merge 1 commit into
colbymchenry:mainfrom
balloon72:codex/fix-mts-cts-indexing
Open

fix(extraction): index .mts and .cts files#394
balloon72 wants to merge 1 commit into
colbymchenry:mainfrom
balloon72:codex/fix-mts-cts-indexing

Conversation

@balloon72
Copy link
Copy Markdown

@balloon72 balloon72 commented May 25, 2026

Summary

Fixes #366 by indexing explicit TypeScript module extensions (.mts and .cts) anywhere CodeGraph already treats .ts files as TypeScript source.

Note: .mjs / .cjs were already present in the JavaScript extension map before this PR; the missing coverage here was the TypeScript ESM/CJS pair.

Changes

  • add .mts and .cts to the scanner/language extension map as TypeScript
  • include .mts, .cts, index.mts, and index.cts in TypeScript import resolution
  • update Express and NestJS framework extractors so route files using .mts / .cts are not skipped
  • extend NestJS convention detection for files like *.controller.mts and *.module.cts
  • add regression coverage for language detection, scanning, full indexing, import resolution, Express extraction, and NestJS detection/extraction

Validation

  • npm ci
  • npm run build
  • npm test -- __tests__/frameworks.test.ts __tests__/extraction.test.ts __tests__/resolution.test.ts -t "(explicit TypeScript module extensions|TypeScript ESM files with \.mts|include explicit TypeScript module extensions|routes from \.mts|HTTP routes from \.mts|controller\.mts)"

The broader targeted run npm test -- __tests__/frameworks.test.ts __tests__/extraction.test.ts __tests__/resolution.test.ts currently passes 425/426 tests on my Windows machine and fails only in the existing C/C++ include end-to-end cleanup path with EBUSY: resource busy or locked, unlink ...\\.codegraph\\codegraph.db; the new .mts / .cts coverage above passes.

@balloon72 balloon72 marked this pull request as ready for review May 25, 2026 10:36
@balloon72 balloon72 force-pushed the codex/fix-mts-cts-indexing branch from 50b7609 to 7a4c449 Compare June 1, 2026 15:14
@balloon72 balloon72 changed the title [codex] fix(extraction): index .mts and .cts files fix(extraction): index .mts and .cts files Jun 1, 2026
@balloon72
Copy link
Copy Markdown
Author

Rebased this on the latest main and squashed the branch down to one focused commit (7a4c449).

Validation on Windows:

  • npm ci
  • npm run build
  • New .mts / .cts regression coverage only: npm test -- __tests__/frameworks.test.ts __tests__/extraction.test.ts __tests__/resolution.test.ts -t "(explicit TypeScript module extensions|TypeScript ESM files with \.mts|include explicit TypeScript module extensions|routes from \.mts|HTTP routes from \.mts|controller\.mts)" ✅ (6 passed)

I also reran the broader targeted suite: npm test -- __tests__/frameworks.test.ts __tests__/extraction.test.ts __tests__/resolution.test.ts. It passes 425/426 tests here and fails only in the existing C/C++ include end-to-end cleanup path with Windows EBUSY while unlinking a temporary .codegraph/codegraph.db; the new .mts / .cts tests pass.

Also clarified the PR body that .mjs / .cjs were already mapped before this PR, while .mts / .cts were the missing TypeScript module extensions.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.mts / .mjs files are not indexed (ESM TypeScript/JS module extensions skipped by file discovery)

1 participant