Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Option to make output in DOT use module path not resolved path if exists #117

Open
pixeldrew opened this issue Mar 22, 2019 · 1 comment
Labels
enhancement this will make dependency-cruiser sweeter
Projects

Comments

@pixeldrew
Copy link

pixeldrew commented Mar 22, 2019

Expected Behavior

Output for modules currently uses resolved path, would like the ability to use module path if it exists.

Current Behavior

Currently the path for sub modules, if using things like npm linking and webpack resolve gives you the relative path, ie ../../
This is ugly, i'd prefer to use the unresolved module path

@sverweij
Copy link
Owner

hi @pixeldrew - agree with you on the aesthetics of ../../ vs using the unresolved path names. I'll put it on the backlog as a suggestion. The solution will have to find a sensible default, though, to prevent unexpected output:

  • For aliased (i.e. mapped through tsconfig/ webpack paths, or webpack aliases) modules it makes sense to use the unresolved path name. There can be multiple aliases for the same module, although that does seem to be an edge case.
  • It's probably not a good idea for non-aliased (i.e. regular local or external) dependencies - various modules will have a different path to other modules. So the same file can end up in the dot output multiple times E.g. for the local ./hello.ts below:

./index.ts:

import * from './hello'
...

./subdir/bla.ts:

import * from '../hello'

would yield a graph with four modules instead of three (index, ./hello, ./subdir/bla and ../hello)

  • in both cases the unresolved path is a property of the dependency, and not of the target module (see diagram below) - it's just how another module sees that target module; so there'd probably be a need to pick something for aliases and attach that to the module...

ER

@sverweij sverweij added this to backlog in roadmap via automation Mar 24, 2019
@sverweij sverweij added the enhancement this will make dependency-cruiser sweeter label Mar 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement this will make dependency-cruiser sweeter
Projects
Status: backlog
roadmap
  
backlog
Development

No branches or pull requests

2 participants