title: Using require.js packages to manage large applications
body: <p>We would like to create an app layout that consists of one main module that requires packages. Each package (including the main module) has its own dependencies to third party libraries and other local packages. Therefore in each package's main.js, we have a require.config section like the following:</p>
  
  <pre><code>require.config({
    packages: ["package2"],
    context: 'package1',
    shim: {
      'underscore': {
        exports: '_'
      }
    },
  
    paths: {
      underscore: '../lib/underscore-1.4.3'  
    }
  });
  </code></pre>
  
  <p>As you can see the config defines paths and packages. The top level main.js looks like this:</p>
  
  <pre><code>require.config({
    packages: ["package1"]
  });
  </code></pre>
  
  <p>The project has a directory structure like so...</p>
  
  <pre><code>├── package1
  │   ├── package1.jade
  │   ├── package1.js
  │   └── main.js
  ├── lib
  │   ├── backbone-0.9.10.js
  │   └── underscore-1.4.3.js
  ├── package2
  │   ├── package2.js
  │   ├── main.js
  └── main.js
  </code></pre>
  
  <p>The goal is we can have sets of "packages" that packages and pages can depend on not just modules.  In a perfect work the dependency graph of the project would look something like this:</p>
  
  <pre><code>   +------------+           +-------------+
     |  package1  +--+     +--+  package2   +--+
     +------------+  |     |  +-------------+  |
                     |     |                   |
                     v     v                   v
                  +--------------+       +--------------+
                  |  package3    |       |  package4    |
                  +----------+---+       +--------------+
                             |
                             |             +-------------+
                             +------------&gt;|   common    |
                                           +-------------+
  </code></pre>
  
  <p>And inside of each package as well we would have a project structure.  Creating a modular architecture for our JS.  Is this style possible with require.js and it's packages, or are we thinking about packages wrong?  If so is there a js dependency managment library that will help us accomplish this architecture?</p>
  
  <p>we threw together a sample structure on github, <a href="https://github.com/austinbv/require_js_package_sample" rel="noreferrer">https://github.com/austinbv/require_js_package_sample</a></p>
  
  <p>lastly we have asked the same on the require mailing list <em><a href="https://groups.google.com/forum/?fromgroups=#!topic/requirejs/bNj4mXNWq-8" rel="noreferrer">https://groups.google.com/forum/?fromgroups=#!topic/requirejs/bNj4mXNWq-8</a></em> but have not seen much intrest so we came here.  If the list updates I will be sure to update my question.</p>