pahen / madge

Create graphs from your CommonJS, AMD or ES6 module dependencies
MIT License
9.09k stars 318 forks source link

Mixing javascript and typescript imports doesn't work with compilerOptions.paths #304

Open igrayson opened 2 years ago

igrayson commented 2 years ago

Hello! This is a continuation of https://github.com/pahen/madge/issues/207. This is more of an FYI for madge users, as the fix should happen in filing-cabinet.

This problem occurs with a tsconfig.json that looks like this:

// ./tsconfig.json
{
  "compilerOptions": {
    "module": "CommonJS", // important to set, madge defaults to AMD.
    "allowJs": true,
    "paths": { "@/*": ["src/at/*"] },
  }
}

and a project layout that looks like this:

// ./src/at/b/index.ts or ./src/at/b.ts
export const foo = 'bar';
// ./src/a.js
import { foo } from '@/b';
console.log(foo);

And to reproduce:

$ madge --ts-config tsconfig.json --warning src/a.js
Processed 1 file (420ms) (1 warning)

a.js

✖ Skipped 1 file

@/b
igrayson commented 2 years ago

See https://github.com/dependents/node-filing-cabinet/pull/103

ninjz commented 1 year ago

@igrayson were you able to come up with a solution for this?