title: Make npm package sub-modules available
body: <p>I have a private library meant to be shared between two code bases.
  It is structured like so:</p>
  
  <pre><code>package.json
  src/
   |_stores/
       |_user.js
   |_actions/
       |_user.js
  </code></pre>
  
  <p>The project is called "foo", I would like to do imports as follows:</p>
  
  <pre><code>require('foo/stores/user');
  // OR
  import User from 'foo/stores/user';
  </code></pre>
  
  <p><strong>What is the best way to do this?</strong></p>
  
  <p>I've read <a href="https://stackoverflow.com/questions/35282101/root-directory-for-node-module">this OP</a> which suggests I can copy the package.json into a <code>lib</code> folder but but it lacks further details?</p>
  
  <h2>Things I've tried:</h2>
  
  <p>Since the code is ES2015/React/Flux I am using <code>babel</code> and <code>gulp</code> with a <a href="https://docs.npmjs.com/misc/scripts" rel="noreferrer">prepublish script</a> to build a <code>lib</code> directory on <code>npm install</code> that looks like so:</p>
  
  <pre><code>package.json
  src/
   |_stores/
       |_user.js
   |_actions/
       |_user.js
  lib/
   |_stores/
       |_user.js
   |_actions/
       |_user.js
  </code></pre>
  
  <p>But, this only makes things available via: <code>require('foo/lib/stores/user')</code> so, I changed the prepublish script to build to the parent directory causing this:</p>
  
  <pre><code>package.json
  stores/
   |_user.js
  actions/
   |_user.js
  src/
   |_stores/
       |_user.js
   |_actions/
       |_user.js
  </code></pre>
  
  <p>But, during local development (using npm link/file dependency) this gets a little messy.</p>
  
  <p>I've also tried symlinking package.json to <code>lib</code> and setting <code>main</code> to point to <code>lib</code> but this didn't appear to do anything.</p>