title: Why don't relative imports with AMD work in requirejs?
body: <p>So, if you have a folder:</p>
  
  <pre><code>- demo/js/foo/foo.js
  - demo/js/foo/bar/a.js
  - demo/js/foo/bar/b.js
  </code></pre>
  
  <p>Then defining an AMD module's as:</p>
  
  <pre><code>foo.js: define(['./bar/a.js', './bar/b.js'], function(a, b) { console.log(a, b); });
  a.js: define([], function() { return {a:'a'}; });
  b.js: define([], function() { return {b:'b'}; });
  </code></pre>
  
  <p>Then if you import the module like this:</p>
  
  <pre><code>require(['./foo/foo'], function() { ... }
  </code></pre>
  
  <p>Gives:</p>
  
  <pre><code>"NetworkError: 404 Not Found - http://localhost:3005/demo/foo/bar/a.js"
  "NetworkError: 404 Not Found - http://localhost:3005/demo/foo/bar/b.js"
  Error: Script error for: foo/bar/a.js http://requirejs.org/docs/errors.html#scripterror
  Error: Script error for: foo/bar/b.js http://requirejs.org/docs/errors.html#scripterror
  </code></pre>
  
  <p>Why doesn't this work?</p>
  
  <p>I've read some obscure posts in the requirejs forum saying this is 'working as intended' because 'imports are names, they are not relative paths'. ...and that you should resolve this issue using the 'map' function.</p>
  
  <p>...</p>
  
  <p>Right! Well, I won't go in to how obvious this behavior is, or how vastly unhelpful threads like <a href="https://groups.google.com/forum/#!searchin/requirejs/relative/requirejs/Zmh7EV5fR2M/4OM-ss5g3DEJ" rel="nofollow">https://groups.google.com/forum/#!searchin/requirejs/relative/requirejs/Zmh7EV5fR2M/4OM-ss5g3DEJ</a> are; let's just get to the point.</p>
  
  <p>How <em>are</em> you supposed to make this work?</p>
  
  <p>Obviously if you import an arbitrary module using bower, and it lives in say, js/lib/obscure.js/dist/obscure.js you need to setup your config:</p>
  
  <pre><code>require.config({
      paths: {
          obscure: 'lib/obscure.js/dist/obscure'
      }
  });
  </code></pre>
  
  <p>...but this seems to mean that all 'amd importable' modules end up being massive amalgamations of one simple file with <em>all</em> the modules in it.</p>
  
  <p>Using baseUrl is not a solution, because, as above, you expect to have multiple isolated 'islands' of javascript which are installed as modules, which 1) need to refer to each other, but 2) also need to be able to refer to their own <em>internal, relative</em> modules.</p>
  
  <p>Seems extremely weird.</p>
  
  <p>Once again, how <em>are</em> you supposed to make this work in the non-trivial case?</p>
  
  <p>Edit: </p>
  
  <p>Surely you say, you're doing it wrong and just not telling us all the things you're doing. Well, see for yourself. An exact copy of this not working is now here on github: <a href="https://github.com/shadowmint/requirejs-example" rel="nofollow">https://github.com/shadowmint/requirejs-example</a></p>