title: Browserify with jQuery >= 2 produces "jQuery requires a window with a document"
body: <p>I'm using browserify to bundle my front-end javascript using CommonJS-style dependencies. For example, I have:</p>
  
  <pre><code>$ = require('jquery/dist/jquery');  // v2.1.0-beta2                                                                                                                                                                       
  _ = require('underscore');                                                                                                                                                                                 
  Backbone = require('backbone');
  </code></pre>
  
  <p>However, when browserify bundles the dependencies I run into the following console error:</p>
  
  <pre><code>Error: jQuery requires a window with a document
  </code></pre>
  
  <p>Looking at the jQuery code, I see it's trying to use <code>this</code> for the global <code>window</code>.</p>
  
  <pre><code>(function( window, factory ) {
  ....
  }(this, function( window ) {
  </code></pre>
  
  <p>Since browserify wraps all dependencies, <code>this</code> is an <code>object</code>, not the <code>window</code>.</p>
  
  <p>What's interesting is jQuery >= 2 should be CommonJS compatible. However, the problem is how browserify wraps the dependencies. Has anyone solved this problem?</p>