I use requireJS and currently I am struggling a bit (with cyrcular dependencies) I know this could be some kind of weak architecture, but currently that's not the point. The question I have is what is the difference between the two ways of defining a module..?
RequireJS-Way:
define(["controller/aController"], function(aController) {
return{
aFunctino : function(){
aController.doSomething();
}
}
});
CommonJS-Way:
define(function(require) {
var aController = require("controller/aController");
exports.aFunction = function(){
aController.doSomething();
}
});
1) Why is there no circular dependency problem while using the commonJS Way?
2) In the requireJS-docu I often read that require("...") is synchronous. How could this be? When will the module be loaded in the CommonJS way?
Thanks