title: Requirejs: dependencies loading out of order
body: <p>So i have a couple of javascript files that I want to be ran in a specific order, and instead of doing script tags in the html page, I'd like to use requirejs so that I can modularize code. Before I started modularizing with define blocks and start refactoring code, I wanted to just set up the dependency ordering. So I have the files like this</p>
  
  <p>index.html</p>
  
  <pre><code>&lt;script src="scripts/depends/require.js"&gt;&lt;/script&gt;
  &lt;script&gt;
      (function(){
          require(['scripts/main.js', function(){}]);
      }());
  &lt;/script&gt;
  </code></pre>
  
  <p>main.js</p>
  
  <pre><code>require(['scripts/services/fileLoader.js', 'scripts/services/Options.js'], function(){
      // do stuff
  });
  </code></pre>
  
  <p>fileLoader.js</p>
  
  <pre><code>require([
      'scripts/services/alert.js',
      'scripts/services/game.js',
      'scripts/services/parser.js',
      'scripts/services/options.js'
  ], function() {
      // do stuff
  });
  </code></pre>
  
  <p>Now it's pretty obvious what I want here. I want the main to invoke fileLoader.js, and then I would like fileLoader.js to invoke each of its dependencies before it invokes its callback. Then when fileLoader.js has finished its callback then I would like for main to finish its dependencies similarly before finally invoking its callback last, which is what I thought requirejs did.</p>
  
  <p>However here is what happens. Main calls require and I can see that fileLoader.js and options.js are loaded. But then before any of the dependencies needed by fileLoader are invoked (nor its own callback which needs to be run for main to run correctly), the main.js callback is invoked. What is going on?</p>
  
  <p>tl;dr - main callback called before dependency's callback, why?</p>