I got used to idea of AMD quite long time ago. That time Require.js was best (and probably only one) good implementation that supports it. It worked great for me while I was involved into Backbone.js development. So, once I jumped in to Angular.js my first wish was reuse the same experience as previously.
There was a few difficulties with that.
Why to use Require.js with Angular.js?
Some people argue about rationality of using Require and Angular together. Indeed, Angular has it’s own module system, dependency resolve system etc. I agree with that, but still my point is: Require.js comes with very handy add-on, called r.js – it’s code minimizer and optimizer.
Having grunt build system (which is de-facto standard for JS applications) you can easily integrate with your deployment scenarios.
Before deep dive, I want to share you some simple ideas of client side code organization that I think makes sense:
The problem with Angular.js optimization is that it using dependency injection mechanism, which resolves the services to inject by it’s name. If optimizer would change the name of function parameters, when application would not work. Fortunately, there is workaround for that.
Posted by Alexander Beletsky. If you liked that material, please consider to follow my twitter account for further updates. If you have comments or questions, do not hesitate to contact my email or raise issue on github.