1

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

Christian
  • 6,961
  • 10
  • 54
  • 82
  • If there is no circular dependency when *not* using the CommonJS style, then why should there *be one* when using it? The rest is fully answered by the question I linked to. – Louis Apr 24 '14 at 10:13

0 Answers0