madge
madge copied to clipboard
package.json name paths not included
Paths using the name of my root directory package.json aren't included in dependency calculations
package.json:
{
"name": "myproject",
"version": "0.0.1",
...
}
Upon calling
madge --orphans --basedir ./ ./
or
madge --orphans ./
it lists a file as an orphan: src/services/Logger.js
This file isn't an orphan, however its dependant is using the package name in the import:
import Logger from 'myproject/src/services/Logger'
.madgerc:
{
"detectiveOptions": {
"es6.mixedImports": "true"
},
"includeNpm": "true",
}
This still might be unsupported at the commonjs resolution layer, but your madgerc might have a bug (may or may not fix it): "es6.mixedImports": true
should be es6: { mixedImports: true }
. Let me know if that fixes the issue.
Thanks for the correction. Unfortunately it seems to have the same output.
{
"detectiveOptions": {
"es6": { "mixedImports": true }
},
"includeNpm": true
}
Thanks for confirming! Assuming that's a valid import (curious why you need to qualify that import with the package name), there must be support for that missing in the node-filing-cabinet package. That package's commonjs resolution algorithm relies on the 'resolve' package. Is there something that we're not supplying there to make this work?
You can hack filing-cabinet in your node_modules folder to see what a fix could be.
Sorry to revive this thread, but I'm wondering if there's been any development regarding this issue? I'm facing the same problem.
Here's my masgerc file:
{
"tsConfig": "./jsconfig.json",
"detectiveOptions": {
"es6": {
"mixedImports": true
}
},
"includeNpm": true
}
and here's my jsconfig file:
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"baseUrl": ".",
"paths": {
"reusables/*": ["#reusableComponents/*"],
"screens/*": ["#screens/*"],
"styling/*": ["#styling/*"],
"utils/*": ["#constants/*"],
"media/*": ["_media/*"]
}
},
"exclude": [
"node_modules",
]
}
If this bug do exist, it's similar to https://github.com/pahen/madge/issues/158 . I reckon we should solve them in a same PR.