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?

2 Answers 2

22

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

https://npmjs.org/package/madge

Sign up to request clarification or add additional context in comments.

2 Comments

This SO post appeared below that link in my Google search and I still trusted going here first. Now I feel silly.
I googled his title word for word, and this SO page was the first result.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.