gabotechs / dep-tree

Tool for helping developers keep their code bases clean and decoupled. It allows visualising a code base complexity using a 3d force-directed graph of files and the dependencies between them.
https://github.com/gabotechs/dep-tree
MIT License
1.4k stars 35 forks source link

Fails to Resolve Modules from 'main' Field in package.json #60

Closed Stan-Stani closed 5 months ago

Stan-Stani commented 5 months ago

I've discovered an issue with resolving modules that use the 'main' field in package.json to specify the entry point.

In my project, I have a structure where the directory "/subFile" contains a "subFile.tsx" file and a package.json file. The package.json file specifies the main field as subFile.tsx.

{
  "main": "subFile.tsx"
}

When I import this module with import subFile from './subFile', the expected behavior is that Node.js and TypeScript will look for a package.json in the subFile directory and use the file specified in the main field.

However, those files don't show up in the dependency graph.

Please consider adding support for resolving the main field in package.json files.

gabotechs commented 5 months ago

Thank you for reporting this!

It's definitely something that should be supported, I'll tackle this soon

gabotechs commented 5 months ago

I've just released a fix for this under the 0.17.7 tag. I've added some tests for ensuring this, but I don't have a real codebase that uses this feature for verifying that the released version completely solves the issue.

Could you please try it out and see if you find any problem?

Stan-Stani commented 5 months ago

Definitely. It'll be Monday when I get back to work!

Stan-Stani commented 5 months ago

Looks good! (Apart from showing how tightly coupled we are... 😅) image