`paperwork()` returns no dependencies for `.mts` and `.cts` files

Open Beginner friendly
#167 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active

Research direction

Start by tracing how paperwork() derives the file type and how getDetective selects a parser for .ts files; compare those paths with .mts and .cts. The examples in the issue reproduce the missing dependencies, including the expected outputs. Add support for those extensions and verify that the shown .mts and .cts imports are detected while existing .ts and .mjs behavior remains intact.

Written by the indexing model from the issue text.

Description

precinct.paperwork() returns [] for TypeScript files with the .mts or .cts extension, while the same content in a .ts file is parsed. Tools built on precinct (dependency-tree, madge) therefore see no dependencies in these files.

// a.mts (a.ts has the same content)
import { b } from "./b.mts";
export const a: number = b + 1;
// c.cts
const { b } = require("./b.cjs");
const c: number = b;
module.exports = { c };
// check.mjs
import { paperwork } from "precinct";
for (const f of ["a.ts", "a.mts", "c.cts", "d.mjs"]) console.log(f, paperwork(f, { includeCore: false }));

d.mjs contains import fs from "node:fs"; import x from "./x.js";.

$ node check.mjs
a.ts [ './b.mts' ]
a.mts []
c.cts []
d.mjs [ './x.js' ]

Expected: a.mts [ './b.mts' ] and c.cts [ './b.cjs' ].

With madge 8.0.0, madge("a.mts", { fileExtensions: ["mts", "ts"] }) gives {"a.mts":[]}, and a.ts gives {"a.ts":["b.mts"],"b.mts":[]}.

Tested with precinct 13.0.1 (also 12.3.2 as used by dependency-tree 11.5.0) and main (f9512ad), Node.js 26.13.0.

Cause: paperwork sets type to the extension without the dot (mts, cts), and getDetective has no case for these, so no detective runs. Mapping them to ts (or .cts with mixedImports) like .cjs is mapped to commonjs would fix it.

Credit: https://ucsbplse.github.io/

Dominant language
JavaScript
Stars
234
Forks
36
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dependents/node-precinct

All issues in dependents/node-precinct

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.