Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Madge skips imported typescript file

Tags:

madge

I want to print a Javascript dependency graph using madge. It prints all dependencies of a given file successfully. Unfortunately, it skips the imported .ts files and subsequently does not show them in the graph.

Here is my config (.madgerc):

{
    "fileExtensions": ["js", "ts"],
    "tsConfig": "./tsconfig.json",
    "graphVizOptions": {
        "G": {
            "splines": "ortho"
        }
    }
}

Here is my tsconfig.json:

{
  "compilerOptions": {
    "esModuleInterop": true,
    "allowJs": true,
    "preserveConstEnums": true,
    "module": "commonjs",
    "target": "ES2018",
    "moduleResolution": "node",
    "noEmit": true,
    "rootDir": "../"
  }
}

I run madge like so:

madge src/main/path/to/file/view-model.js --warning --debug -i ~/Desktop/graph/view-model.png

It prints:

✔ Image created at /Users/patrick/Desktop/graph/view-model.png

✖ Skipped 1 file

./transform-sponsor

transform-sponsor is imported in my Javascript file like so:

const {transformSponsors} = require('./transform-sponsor');

So my question is, why does madge skip my typescript file. Even though I specifically added a tsconfig file as explained in the documentation?

like image 297
Patrick Avatar asked Dec 05 '25 16:12

Patrick


1 Answers

Just add --extensions ts to the runned script

like image 196
Jöcker Avatar answered Dec 09 '25 15:12

Jöcker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!