pahen / madge

Create graphs from your CommonJS, AMD or ES6 module dependencies
MIT License
8.95k stars 318 forks source link

Search Through PNPM Monorepo Packages For Circular Depndencies #428

Open bestickley opened 3 months ago

bestickley commented 3 months ago

Hello, first thank you for such a great library!

When I run next build I get this error:

pnpm build

> template-app-ui@0.1.0 build /Users/stickb/Code/dos/dos-monorepo/packages/template/app/ui
> next build

  ▲ Next.js 14.3.0-canary.37

   Creating an optimized production build ...
Failed to compile.

../core/src/config/config.server.ts + 10 modules
Cannot get final name for export 'commonEnvVarNames' of ../../../shared/lib/core/src/index.test.ts

> Build failed because of webpack errors

Which I believe to be a circular dependency error. So I tried running madge at the root of my PNPM Monorepo and I get this:

pnpx madge --warning --circular --extensions ts,tsx --exclude cdk-nextjs --include-npm packages
⠋ Finding files=============

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <5.2.0

YOUR TYPESCRIPT VERSION: 5.4.5

Please only submit bug reports when using the officially supported version.

=============
Processed 205 files (1.7s) (13 warnings)

✔ Image created at /Users/stickb/Code/dos/dos-monorepo/deps.png

✖ Skipped 13 files

shared-lib-ui
@/config/config.shared
notification-lib-ui
template-app-core/server
template-app-core/shared
shared-lib-core/edge
shared-lib-core/shared
shared-lib-core/test
shared-lib-infra
shared-lib-core/node
assistant-lib-ui
template-svc-core/shared
template-app-core/node

It looks like madge isn't resolving my internal packages. How can I get madge to dive into them? I tried --include-npm but that did not work :(

Appreciate any help!

bitofbreeze commented 1 week ago

If you're using tsconfig paths, you need to provide madge a path to your tsconfig file.