title: Correct way to require extensions with browserify
body: <p>What is the best way is to include an extension for a common library like jQuery or Knockout with <a href="http://browserify.org/" rel="noreferrer">Browserify</a>?</p>
  
  <p>For example, with a project like <a href="https://github.com/mbest/knockout-switch-case" rel="noreferrer"><code>knockout-switch-case</code></a>, the global <code>ko</code> (knockout) variables is not passed to the module-definition call.</p>
  
  <p>The AMD code for <em>knockout-switch-case</em> is:</p>
  
  <pre><code>(function (root, factory) {
      if (typeof define === 'function' &amp;&amp; define.amd) {
          // AMD. Register as an anonymous module.
          define(['knockout'], factory);
      } else {
          // Browser globals
          factory(root.ko);
      }
  }(this, function(ko) {
  </code></pre>
  
  <p>where it expects <code>ko</code> (knockout) to be a global on <code>root</code>, which would ordinarily be <code>window</code> but when using Browserify it is <code>Object {}</code>.</p>
  
  <p>I have tried with the example using <a href="https://github.com/thlorenz/browserify-shim" rel="noreferrer"><code>browserify-shim</code></a> with something like this, but it did not work as expected (though it did work for <a href="https://github.com/SteveSanderson/knockout.mapping/blob/master/build/output/knockout.mapping-latest.debug.js" rel="noreferrer">knockout-mapping</a>, which has a better module-dance):</p>
  
  <pre><code>  knockout:
      path: VENDOR_PATH + '/knockout.js'
      exports: 'ko'
      depends:
        jquery: '$'
  </code></pre>
  
  <p>I feel as though I must be overlooking something that must be quite obvious, as I expect this would be a fairly common module definition pattern for including any jQuery, Knockout or any other extension for a library that relies on a global. Or perhaps this is an issue fairly specific to something <em>knockout-switch-case</em> is doing.</p>
  
  <p>In any case, thoughts and comments sincerely appreciated.</p>