title: How to use requires to return constructor functions that have dependencies
body: <p>How do you correctly use <code>Require.js</code> to load a module that returns a constructor function that has require dependencies?  </p>
  
  <p>My problem seems to be a scope issue, I have seen some modules that are available within the returned constructor like "durandal/app" and I dont see how they are scoped any different than the modules I have defined.</p>
  
  <p>This example is modified from Durandal Creating a Module <a href="http://durandaljs.com/documentation/Creating-A-Module/" rel="nofollow">docs</a></p>
  
  <pre><code>define([**someothermodule**, "durandal/app"], function(**someothermodule**, app){
  var backend = function(username, password){  
      this.username = username;  
      this.password = password;  
      someothermodule.whatever(); &lt;--someothermodule is not defined
      app.whatever(); &lt;-- this is in scope
  };
  
  backend.prototype.getCustomers = function(){
      //do some ajax and return a promise
  };
  return backend;
  </code></pre>
  
  <p>});</p>
  
  <p>define([backend], function(backend){</p>
  
  <pre><code>return {
      customers:ko.observableArray([]),
      activate:function(){
          var that = this;
          var service = new backend('username', 'password');
  
          return service.getCustomers().then(function(results){
              that.customers(results);
          });
      }
  };
  </code></pre>
  
  <p>});  </p>
  
  <p>Someothermodule:</p>
  
  <pre><code>define([], function(){
  
  var whatever = function(){
      alert("whatever");
  };
  
  return {
      whatever: whatever
  };
  </code></pre>
  
  <p>});</p>