Skip to content

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

@karthickshanmugam0689

Description

@karthickshanmugam0689

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions