title: Defining an imported external module with WebPack + TypeScript
body: <p>I'm trying to get WebPack set up with TypeScript and some external libraries, but having some trouble.</p>
  
  <p>I'm importing the src version of jQuery in order to let WebPack choose the required modules (this was needed to get the Boostrap-SASS loader working), so am importing the library like this in my TS:</p>
  
  <pre><code>import jquery = require( 'jquery/src/jquery.js' );
  </code></pre>
  
  <p>When compiling, this throws the error <code>cannot find external module 'jquery/src/jquery'</code>. If I create a manual .d.ts file to define the library, like so:</p>
  
  <pre><code>declare module "jquery/src/jquery"{}
  </code></pre>
  
  <p>then the compiler works, but warns:</p>
  
  <pre><code>cannot invoke an expression whose type lacks a call signature
  </code></pre>
  
  <p>Alternatively, if I change the import line to</p>
  
  <pre><code>var jquery = require( 'jquery/src/jquery' );
  </code></pre>
  
  <p>(which I think is a CommonJS style import?) then it all compiles (and runs) fine. So, questions:</p>
  
  <ul>
  <li>Is there a better way of requiring/including the source files using WebPack?</li>
  <li>What's the correct way to define the module so it doesn't lack a call sig?</li>
  <li>Should I be worried about using <code>var</code> instead of <code>import</code> or just roll with it if it's working?</li>
  </ul>
  
  <p>I've only just picked up WebPack so it's entirely possible I'm doing something stupid. Please correct me if so!</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>As I was thinking about how to phrase the question this came to me:</p>
  
  <pre><code>declare module "jquery/src/jquery" { export = $; }
  </code></pre>
  
  <p>which seems to let me use "import..." - but is that a good way to handle this?</p>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>In reply to @basarat's answer below (my comment got a bit long to be read without line breaks):</p>
  
  <p>I'm already using the jquery def from DefinitelyTyped, but it doesn't work by itself because the module I'm requiring is <strong>"jquery/src/jquery"</strong> and not just <strong>"jquery"</strong>. If I use "jquery" then the compiled dist version of jquery is loaded, which doesn't work with the Bootstrap loader.</p>
  
  <p>So the <code>declare module "jquery/src/jquery" { export = $; }</code> is, I think, extending the existing definition but using the path that I need to load it from.</p>