Fix crash loading amd modules with no dependencies

loader.js crashes when you requires a amd module with no dependencies defined. I have cherry-picked some code of master branch and I have created this patch for v1.0.0.

This way, we could use stable version with the possibility of loading amd modules with this kind of definition:

    define ("module-name", function (){});