gabotechs/dep-tree

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

Stan-Stani opened this issue ยท 4 comments

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.

Thank you for reporting this!

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

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?

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

Looks good! (Apart from showing how tightly coupled we are... ๐Ÿ˜…)
image