madge icon indicating copy to clipboard operation
madge copied to clipboard

Search Through PNPM Monorepo Packages For Circular Depndencies

Open bestickley opened this issue 1 year ago • 1 comments

Hello, first thank you for such a great library!

When I run next build I get this error:

pnpm build

> [email protected] 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!

bestickley avatar Jun 15 '24 10:06 bestickley

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

candidia avatar Sep 25 '24 16:09 candidia