title: ES6 module import and dependency management
body: <p>With the use of transpilers it is already possible to use ES6 modules. One of the easiest ways is using Browserify and Babelify.
  The problem I'm having is how to handle dependency management.</p>
  
  <p>In the old days you'd just have some Bower dependencies. The build would bundle non-CDN to <em>vendor.js</em> and project specific files to <em>foobar.js</em> (or whatever).
  So then you'd be able to use the resulting code in a different project by simply <code>bower install foobar --save</code>.
  If both <em>foobar</em> and your new project had a common dependency it would be easily resolved with Bowers flat dependency.</p>
  
  <p>Now in come ES6 modules:
  Say I have a project <em>foo</em> using <em>lodash</em>. The directory structure is as follows:</p>
  
  <p><code>src/js/foo.js
  src/vendor/lodash/dist/lodash.min.js</code></p>
  
  <p>And <em>foo.js</em> starts by declaring:</p>
  
  <p><code>import * as _ from '../../vendor/lodash/dist/lodash.min.js';</code></p>
  
  <p>or (as Browserify wants since Babelify transpiles to CommonJS):</p>
  
  <p><code>import * as _ from './../../vendor/lodash/dist/lodash.min.js';</code></p>
  
  <p>If I now round up and publish my <em>foo</em> project and start a new project <em>bar</em> that uses <em>foo</em> this will be my directory structure.</p>
  
  <p><code>src/js/bar.js
  src/vendor/foo/dist/foo.js
  src/vendor/lodash/dist/lodash.min.js</code></p>
  
  <p>But that would not work since the path from <em>foo</em> to <em>lodash</em> is now broken (if I understand Browserify correctly the dot-slash in './blaat/file.js' is relative to the file it's being called from).</p>
  
  <p>Is some way to import without making any file path assumptions?</p>
  
  <p>Isn't there some way to indicate multiple source roots? (ie in the above case src/js and src/vendor ... well, ideally you'd just want to state <code>import * as _ from 'lodash';</code>)</p>
  
  <p>I've only used Browserify with Babelify on cli. Should I be using some other transpiler?</p>