dependency-cruiser icon indicating copy to clipboard operation
dependency-cruiser copied to clipboard

Question: dependency-cruiser API gives a different result when `baseDir` is changed

Open harrisonzhu-db opened this issue 1 month ago • 2 comments

Summary

I'm migrating my package that uses dependency-cruiser from one location to another. Using the exact same code, my cruise output gives the following in its summary

old package location (works):

{
  violations: [],
  error: 0,
  warn: 0,
  info: 0,
  ignore: 0,
  totalCruised: 580,
  totalDependenciesCruised: 2045,
  optionsUsed: {
    baseDir: '/Users/harrison.zhu/universe2/experimental/harrisonzhu/safex-lint',
    combinedDependencies: false,
    exclude: { path: '.*node_modules' },
    exoticRequireStrings: [],
    externalModuleResolutionStrategy: 'node_modules',
    metrics: false,
    moduleSystems: [ 'es6', 'cjs', 'tsd', 'amd' ],
    preserveSymlinks: false,
    tsPreCompilationDeps: false,
    args: '../../../redash/managed_redash/packages/app/src/open-marketplace/OpenMarketplace.tsx'
  }
}

new package location (does not work):

{
  violations: [],
  error: 0,
  warn: 0,
  info: 0,
  ignore: 0,
  totalCruised: 3,
  totalDependenciesCruised: 2,
  optionsUsed: {
    baseDir: '/Users/harrison.zhu/universe2/js/scripts',
    combinedDependencies: false,
    exclude: { path: '.*node_modules' },
    exoticRequireStrings: [],
    externalModuleResolutionStrategy: 'node_modules',
    metrics: false,
    moduleSystems: [ 'es6', 'cjs', 'tsd', 'amd' ],
    preserveSymlinks: false,
    tsPreCompilationDeps: false,
    args: '../../redash/managed_redash/packages/app/src/open-marketplace/OpenMarketplace.tsx'
  }
}

everything is the same here except the baseDir and args. But resolving baseDir/args resolves to the same absolute path, so I'm not sure why there would be a difference in outputs, since I would hope that the operation of cruise is agnostic of where the script is located.

Context

Moving from a traditional yarn setup to a yarn pnp directory.

Environment

  • Version used: 12.2.2
  • Node version: 20.13.1
  • Operating System and version: Mac OS Sonoma

harrisonzhu-db avatar May 23 '24 22:05 harrisonzhu-db