In dojo, cyclic dependencies present a problem. If you have a cyclic dependency, one of the modules involved will be resolved to {}, an empty object. Oops. This is to prevent further recursion as the AMD loader goes down the dependency graph. Unfortunately this can lead to subtle bugs and can be difficult to track down. I remember struggling when I was first learning dojo and ran into this problem, luckily a colleague was able to describe the issue.
Anyway, in Needs More Dojo I've added the ability to scan for cyclic dependencies. So now you can run a scan on your project sources, and you get a tool window like this:
Scanning for cyclic dependencies. |
This appears as an action in the code menu that you can run. I've also added an inspection that will run in the background and highlight modules that are involved in cyclic dependency graphs like this:
Cyclic dependencies flagged as errors |
The inspection is disabled by default. I did this because I didn't want large projects getting performance hits, as the inspection has to build a graph of dependencies for each file.
Expect 0.5.1 to be released in a couple of weeks.
No comments:
Post a Comment