title: Typescript can't find external module when referenced by two different files
body: <p>I may be missing something obvious, but Typescript's module resolver for commonjs isn't working as expected.</p>
  
  <p>Given the following directory structure and files:</p>
  
  <pre><code>./first/shared.ts
  ./first/second/class_a.ts
  ./first/second/class_b.ts
  ./third/class_c.ts
  </code></pre>
  
  <p>Where:</p>
  
  <ul>
  <li>class_a references shared.ts</li>
  <li>class_b references class_a.ts and class_c.ts</li>
  <li>class_c references shared.ts</li>
  </ul>
  
  <p>Specifically:</p>
  
  <pre><code>shared.ts:
  class Shared{}
  export = Shared;
  
  class_a.ts:
  import Shared = require('../shared');
  class A{}
  export = A;
  
  class_b.ts:
  import A = require('./class_a');
  import C = require('../../third/class_c');
  class B {}
  export = B;
  
  class_c.ts:
  import Shared = require('../first/shared');
  class C {}
  export = C;
  </code></pre>
  
  <p>All compile except class_b.ts, using the following compiler invocation:</p>
  
  <pre><code>tsc --module commonjs class_a.ts
  </code></pre>
  
  <p>Compiling class_b.ts fails with the error that it can't find shared.ts:</p>
  
  <pre><code>../../third/class_c.ts(1,25): error TS2307: Cannot find external module '../first/shared'.
  </code></pre>
  
  <p>Note that if you reverse the order of imports in class_b.ts, you get a different error:</p>
  
  <pre><code>class_a.ts(1,25): error TS2307: Cannot find external module '../shared'.
  </code></pre>
  
  <p>It seems the compiler is finding shared.ts the first time it is imported, but not the second time.</p>
  
  <p>I'm using tsc 1.4.1.0.</p>
  
  <p>Anything obvious I'm missing, here?</p>