Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: list import identifiers in dep tree #147

Closed
AndersDJohnson opened this issue Jul 15, 2022 · 3 comments
Closed

feat: list import identifiers in dep tree #147

AndersDJohnson opened this issue Jul 15, 2022 · 3 comments

Comments

@AndersDJohnson
Copy link

AndersDJohnson commented Jul 15, 2022

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.

@AndersDJohnson AndersDJohnson changed the title feat: provide tokens with dep graph feat: give import tokens in dep graph Jul 15, 2022
@AndersDJohnson AndersDJohnson changed the title feat: give import tokens in dep graph feat: list import tokens in dep tree Jul 15, 2022
@mrjoelkemp
Copy link
Collaborator

Hey! Given the effort and complexity of changes, it would be better to fork the relevant dependencies and put that feature in its own library. Minor fixes or improvements by the community are accepted, but not significant changes. Thanks for the idea contribution.

Will close this as a wontfix. Thanks again.

@AndersDJohnson
Copy link
Author

No worries @mrjoelkemp, I understand it's not an easy undertaking and hard enough to maintain as-is. I'll likely start working on smaller pieces and maybe end up just publishing forks. Starting here: dependents/detective-typescript#47

@AndersDJohnson
Copy link
Author

@mrjoelkemp I think I found a relatively lightweight way to solve it: dependents/detective-typescript#48. Supporting a generic callback like that (and enough metadata to indicate position in tree to integrators) should eliminate the need for a lot of other feature requests.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants