Removing Unused Dependencies with grunt-amdcheck

I’ve recently been playing with the grunt-amdcheck plugin to remove unused dependencies from AMD modules. It’s common for define statements in an AMD project to accumulate unused dependencies over time as developers refactor, and it’s a good idea to clean those up from time to time as unused dependencies can:

Make it harder to maintain your code

Cause the browser to make unnecessary asynchronous requests at run time

I added the plugin to a couple of projects and ended up removing over 20 from one and 50 from the other. Unfortunately, removing those unused dependencies did not lead to similar decreases in the number of modules loaded at runtime. This is because most of the removed dependencies were required by other modules. However, the code is now more maintainable.

If you’re using this plugin in a Dojo project that uses templated widgets, i18n, and/or xstyle, you need to remember to include the relevant paths in your excludesPaths. For example: