pahen / madge

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

Listing dependancy tree via madge always gives me the reference from barel files #426

Open karthickshanmugam0689 opened 3 months ago

karthickshanmugam0689 commented 3 months ago

Hi Madge team,

We're using madge to analyze the dependency tree within our monorepo. It works well for identifying dependencies at the package level. However, we encounter an issue when using barrel files for re-exports. Consider the following project structure

* app-1
  * src
    * App.ts
    * app1Utils.ts
* libraries
  * common-util #( package name as per package.json = @org-web/common-util)
    * src
       * index.ts
       * utils
          * helper.ts

In libraries/common-util/index.ts we have

export { helper } from './utils/helper.ts'

Inside my app-1/src/App.ts, we have

import { helper } from '@org-web/common-util';
import { app1Utils } from './app1Utils.ts';

// statements list for execution
helper(/** List of arguments */);

Running madge on app-1, currently shows

{
   'App.ts': [
      '../../libraries/common-util/src/index.ts',
      './app1Utils.ts'
   ]
}

The desired outcome is for madge to identify the actual dependency: libraries/common-util/src/utils/helper.ts. But it always resolves to index.ts file of that package. Is there a possibility with madge to even resolve this barrel files and give us the specific file reference even if it is reexported?

karthickshanmugam0689 commented 3 months ago

Hi Team, Do we have any update here? We would like to also resolve barrel files here.