-
Notifications
You must be signed in to change notification settings - Fork 321
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
Dynamic imports throwing madge off #157
Comments
Thanks for reporting the issue. I'm afraid that the fancy footwork is defeating static analysis here :) The only way for dependency-tree to recognize those imports is to evaluate the code to inline the assignments. Maybe facebook's prepack could be a good prepass filter for dependency-tree; not sure if anyone has tried that. |
So... work-arounds... simplest that has worked for me is to temporarily re-write code so that it does not use dynamic imports... Maybe there could be a codemod that does this for you just before madge receives it... but, sure is hard if the dynamic imports are determined at runtime. All the dynamic code may need to be commented out/undone, which shouldn't really take all that long. The webpack chunk names don't really map to the import paths... What do people think of a codemod? |
Of course, a codemod might work best if the arguments to This is a lot easier to handle:
Than:
The first snippet I'd think mostly anyone could write some code to find |
Looks like it was fixed in |
I think that just upgrading precinct dependency to version 8 might fix this issue. There is alreay a pull request pending #278. |
I found a workaround (https://www.npmjs.com/package/npm-force-resolutions) for now but ideally, precinct should be upgraded to upgrade detective-typescript to version 7.0.0 |
@vidal7 @bennypowers does this issue still exist on the latest version? |
Guys here is the solution for this I found: {
"detectiveOptions": {
"ts": {
"skipTypeImports": true,
"skipAsyncImports": true
},
"tsx": {
"skipTypeImports": true,
"skipAsyncImports": true
}
}
} this way it will ignore the type imports and async imports, works for me :) hope this helps. |
I've got some fancy footwork importing these modules:
Madge pukes on that ternary in the import statement:
Thanks for the cool module!
The text was updated successfully, but these errors were encountered: