Comments (12)
…which should make it easy to fix 😁
The latest release of madge, v6.1.0 is from June '23.
dependency-tree
has been updated to v10.0.9 in October '23.
So, I assume that simply making a new release would solve the problem… <= @pahen
from madge.
I can confirm that upgrading dependency-tree >= 10 fixes the issue! Madge 6.1.0. Since I'm using pnpm I did the following in my package.json:
"overrides": {
"madge>dependency-tree@<10": "10"
}
I went from 1000s of skipped files to 7!
from madge.
+1
Adding "/index" to some path resolves madge skipping files
I have file extract.test.ts
with imports:
import { ... } from "../../model"
import { ... } from "./extract"
And my madge result with --json
for this file is:
{
"call.ts": [],
"extract.test.ts": [
"extract.ts"
],
"extract.ts": [
"call.ts"
]
}
But if I change model import for ../../model/index
:
{
"../../model/***.ts": [],
"../../model/index.ts": [
"../../model/***.ts",
],
"call.ts": [],
"extract.test.ts": [
"../../model/index.ts",
"extract.ts"
],
"extract.ts": [
"call.ts"
]
}
from madge.
Is there anything else you did to get it to work?
Since I am only at the "experiment and play" step, I brutally edited madge.js
in my node_modules
to accept a DependencyTree
parameter instead of using its own, installed 10.0.9 locally, and injected it that way.
Not my proudest hack 🙈
And definitely won't work once I try to actually use this… Or when try to use madge from command line rather than a script.
from madge.
same here, index.ts files seems to be ignored: all imports of dirs with index.ts are skipped(
is there any way to fix it?
from madge.
Facing the same issue and digging a bit.
I think it is a problem with dependency-tree
, likely dependents/node-dependency-tree#118, which Madge uses to get its dependencies. At least the "skipping" message comes from there.
Trying to dig further into dependency-tree
to see whether this is just an option to pass or a deeper issue…
from madge.
OK, I think this is a dependency-tree
problem that was fixed in v10, madge
is still running v9 and thus has the problem.
- Adding a
console.log
statement to see the result of the call toDependencyTree
at https://github.com/pahen/madge/blob/master/lib/tree.js#L121, I do not get the dependency:{ '/mnt/c/Projects/a11y/alfa/packages/alfa-css/src/calculation/index.ts': {} }
- Calling, with the same config,
DependencyTree
directly, and showing the result,- with v10.0.1 to v10.0.9 (somehow, v10.0.0 crashes), I get the dependency:
{ '/mnt/c/Projects/a11y/alfa/packages/alfa-css/src/calculation/index.ts': { '/mnt/c/Projects/a11y/alfa/packages/alfa-css/src/calculation/math-expression/index.ts': { '/mnt/c/Projects/a11y/alfa/packages/alfa-css/src/calculation/math-expression/math.ts': [Object] } } }
- same with v9.0.0 (no other v9.* version) of
dependency-tree
, I do not get the dependency:{ '/mnt/c/Projects/a11y/alfa/packages/alfa-css/src/calculation/index.ts': {} }
- with v10.0.1 to v10.0.9 (somehow, v10.0.0 crashes), I get the dependency:
I'm not really able to see which update of dependency-tree
did the trick, but it seems to be the root cause…
https://github.com/dependents/node-dependency-tree/releases/tag/v10.0.0
from madge.
@Jym77, I ran into this same issue and I used package.json#pnpm.overrides to enforce [email protected]
to be used by madge and it still did not work for me :( Import identifiers that had implicit "index" files still showed up as warnings in madge because they could not be resolved.
Example output of madge with dependency-tree@10:
pnpx madge --warning --circular ./src/**/*
WARN 1 deprecated subdependencies found: [email protected]
Packages: +179
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 178, reused 178, downloaded 0, added 179, done
Processed 57 files (1.2s) (15 warnings)
✔ No circular dependency found!
✖ Skipped 15 files
drizzle-orm/postgres-js
drizzle-orm
postgres
@aws-sdk/rds-signer
@aws-sdk/client-secrets-manager
drizzle-orm/pg-core
@aws-lambda-powertools/logger
drizzle-kit
drizzle-orm/postgres-js/migrator
../adapters/secondary
./types
zod
../base
./adapters/secondary
Then if I update all import specifiers with /index:
pnpx madge --warning --circular ./src/**/*
> @lh/[email protected] check-circular-dependencies /Users/stickb/Code/dos/lighthouse/core
> madge --circular --warning src/**/*
Processed 40 files (1s) (10 warnings)
✖ Found 1 circular dependency!
1) adapters/secondary/db-adapter.ts > modules/new-user/index.server.ts > modules/new-user/update-new-user.usecase.ts > modules/new-user/new-user.repo.ts > adapters/secondary/index.ts
✖ Skipped 10 files
postgres
@aws-sdk/rds-signer
@aws-sdk/client-secrets-manager
drizzle-kit
drizzle-orm/postgres-js
drizzle-orm/postgres-js/migrator
drizzle-orm
zod
drizzle-orm/pg-core
@aws-lambda-powertools/logger
Is there anything else you did to get it to work?
from madge.
For yarn, the workaround in package.json
is:
"resolutions": {
"dependency-tree": "^10.0.9"
}
from madge.
Thanks for workaround!
npm:
"overrides": {
"madge": {
"dependency-tree": "^10"
}
},
from madge.
FYI, updating to madge 7.0.0 fixed this for me (no need for custom resolution anymore). The correct dependency-tree is now a dependency 🎉
from madge.
FYI, updating to madge 7.0.0 fixed this for me (no need for custom resolution anymore). The correct dependency-tree is now a dependency 🎉
Nice :)
from madge.
Related Issues (20)
- "skipped" files that are from node_modules?
- require statement is not detected by madge
- Option to draw graph of npm packages instead of modules
- glob cli <src...> parameters
- fix output.sh syntax
- trying to understand madge's circular dependency results for an Angular project HOT 1
- option to get dependents, recursively
- Feature request: topological sort for dependencies
- ts config alias does not work at all HOT 8
- Not able to call madge from esm codebase. HOT 2
- Wrong result HOT 1
- Release a madge version to solve "Not all imports in TypeScript are detected" HOT 6
- Allow changing color for npm_modules
- Add option to show only the node module name instead of full file path
- Support package.json "imports" field ("#hash"-style imports)
- support .css/less url
- Calculate dependency require path
- Include images in the tree
- Update typescript version for v7 HOT 2
- Madge is not detecting the right version of Typescript and incorrect warning HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from madge.