node-dependency-tree icon indicating copy to clipboard operation
node-dependency-tree copied to clipboard

Unable to resolve index.tsx dependencies

Open Sharabesh opened this issue 5 years ago • 4 comments

I'm having trouble running this package over dependencies that include in index.tsx file as I'm getting the error:

tree skipping an empty filepath resolution for partial: components/lib +29ms

My index.tsx in components/lib just consists of export * from ___ lines.

I saw this similar issue here: https://github.com/pahen/madge/issues/128 but it didn't seem to have a solution. Any ideas on this?

In the debug output i'm seeing:

 tree deduped list of nonExistent partials:  [ 
  'components/lib',
  ...
  '../..' ]

Sharabesh avatar May 09 '20 05:05 Sharabesh

hey! I don't use TS sadly, so I'd need a failing test in order to concretely understand what's not working. Any help is appreciated.

mrjoelkemp avatar Jun 16 '20 02:06 mrjoelkemp

I’m having the same problem while trying to determine the dependency tree of a .d.ts files. Dependencies to folders don’t resolve to the respective index.d.ts file. Would be nice to somehow configure the file extension. The nonExistent list is also not helpful in this case because it only contain relative paths but without the information from which path it was imported.

lo1tuma avatar Jan 23 '21 13:01 lo1tuma

I was able to resolve my issue with .d.ts files. Although I don’t have a tsconfig file for them, there is the possibility to provide a tsconfig object instead of a file, so the following tsconfig makes sure that index files are resolved correctly:

dependencyTree.toList({ filename: myFile, directory: myDir, tsConfig: { compilerOptions: { module: 'CommonJS' } } });

lo1tuma avatar Jan 24 '21 16:01 lo1tuma

I'm working on a project where I use only tsc arguments on CLI (as in no tsconfig file), the following worked for me:

const tree = dependencyTree.toList(
  {
    filename,
    tsConfig: {
      compilerOptions: {
        allowSyntheticDefaultImports: true,
        module: 'commonjs',
      }
    },
    directory: './src',
    nonExistent: non,
  },
);

jeanlescure avatar Feb 23 '21 23:02 jeanlescure