Skip to content

feat: list import identifiers in dep tree #147

Closed
@AndersDJohnson

Description

@AndersDJohnson

Hello! This is an awesome library! I was wondering how the maintainers would feel about the idea of adding a feature/option that would allow the dependency graph to include the names of the identifiers being imported.

This might be a change to some of the detective packages as well, and perhaps only make sense in the case of JS/TS.

E.g., from:

{
  '/Users/anders/code/deps/src/examples/app/App.jsx': {
    '/Users/anders/code/deps/src/examples/app/components/Header.jsx': {
      '/Users/anders/code/js-usage/src/examples/app/components/Title.jsx': {}
    },
    '/Users/anders/code/js-usage/src/examples/app/components/Footer.jsx': {}
  }
}

To a structure with metadata like:

{
 path:  '/Users/anders/code/deps/src/examples/app/App.jsx',
 children: [
    {
      identifiers: ['Header'],
      path: '/Users/anders/code/deps/src/examples/app/components/Header.jsx',
      children: [
        {
          identifiers: ['Title'],
          path: '/Users/anders/code/deps/src/examples/app/components/Title.jsx'
        }
      ]
    },
    {
      identifiers: ['Footer'],
      path: '/Users/anders/code/deps/src/examples/app/components/Footer.jsx'
    }
  }
}

If it's an import without identifiers, we could say identifiers would be either empty array [] or not defined at all.

If it's a default import, I suppose we could give something like identifiers: ['default'] or just omit identifiers in this case as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions