-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File with a fake circular dependency to itself #271
Comments
Hey! Does it still happen if you set |
Hey @mrjoelkemp, thanks for chipping in! I can confirm I'm still hitting the same issue with |
Thanks for confirming. We just delegate to the typescript compiler for module path resolution: https://github.com/dependents/node-filing-cabinet/blob/master/index.js#L145-L153. Are you supplying a typescript config? If so, perhaps there's a relevant configuration option you can set. |
I run into this issue too, it appears like it's trying to use the |
The problem occurs when using The problem seems to stem from the way how compilerOptions are loaded and changed in Madge; I think the solution should be either: |
This also happened to us even though we're not using TS. I have a module on Using it as CLI on v4.0.2. |
This happens to me as well. If you have a file named |
Yea I guess madge parsed "foo" as "./foo" which is incorrect. Will look into this much later. |
I had the same problem and found out, that supplying madge the path to the tsconfig instead of the tsconfig object causes madge (or a dependency of it) to provide its dependencies a tsconfig object that does not contain strings for import { getTsconfig } from 'get-tsconfig';
const { config } = getTsconfig(tsConfigPath);
const madgeResult = await madge(path.join(__dirname, './src'), {
tsConfig: config,
}); Supplying the object instead of the path seems to not cause the aforementioned removal of those options. This not only fixed the problems mentioned in this issue, but various missing resolved dependencies to directories containing an index.ts EDIT: |
This seems to be the culprit. It causes property-values of the wrong format (numbers instead of strings) to be written over the correct ones. Maybe just pick the values that are actually needed or exclude the ones, that can already be found in the target? |
Hi 👋 I was implementing madge in a project today, and I found this issue. I followed the chain of calls and the problem is what @mx-bernhard mentioned: Let's say you have a {
"compilerOptions": {
"target": "es5",
"module": "esnext",
"moduleResolution": "node"
}
} If you run madge via CLI and send {
"compilerOptions": {
"target": 1,
"module": 99,
"moduleResolution": 2
}
} Now, the problem is that the generated object (with numbers instead of strings) is what madge sends down to its dependencies, specially Inside {
"compilerOptions": {
"target": undefined,
"module": undefined,
"moduleResolution": undefined
}
} |
For anyone interested, I just made a small workaround to be able to use CLI: Since madge uses the #!/bin/sh -e
TS_CONFIG=$(node -e "console.log(JSON.stringify(require('get-tsconfig').getTsconfig().config, null, 2))")
JSON_STRING=$(cat <<EOF
{
"_note_": "This file is autogenerated",
"tsConfig": $TS_CONFIG,
"fileExtensions": ["js", "ts", "tsx"]
}
EOF
)
echo "$JSON_STRING" > .madgerc
madge ./src -c --warning
(I really like the |
I've noticed a strange behavior with
madge
. It turns out that I have a file calledauth0.ts
, which acts as a facade for Auth0, which starts like this:import * as Auth0 from "auth0";
This is not a circular dependency, as I have installed the
auth0
package vianpm
, and it shows up in mypackage.json
. The import works as expected, giving me access to the content of theauth0
package. However, runningnpx madge -c auth0.ts
still complains:The text was updated successfully, but these errors were encountered: