6

How to detect circular dependencies from a project built using requir.js?

For instance

/* File: MyView.js */
define(['backbone','views/myview','object_x'], function(BB,V,X){
   ...
});

/* File: Object_X.js */
define(['backbone','jquery','views/myview','object_x'], function(BB,$,V,X){
   ...
});

what I mean is that as the project gets bigger, manually inspecting each file becomes a hassle.

Edit: How about detecting redundant dependencies?

user1406062
  • 833
  • 5
  • 15

2 Answers2

22

I Googled your title word-for-word, and this was the first result...

https://npmjs.org/package/madge

ken
  • 3,650
  • 1
  • 30
  • 43
3

Use r.js to optimize the code. During build process it will list files that were included while building.

If you want to do more dependency graph analysis the semi-private onResourceLoad API may be helpful.

Tomas Kirda
  • 8,347
  • 3
  • 31
  • 23