title: jQuery.ui undefined after requirejs optimization
body: <p>I have several JavaScript files in my web application which were previously loaded through <code>&lt;script&gt;</code> tags, in order of relative dependencies. Now I'm re-organizing them through require.js in order to accumulate and minify them for production.</p>
  
  <p>For starters, I'd like to simply load all files into the global (window) context, without AMD encapsulation yet:</p>
  
  <pre><code>require([
      'jquery'], function() {
      require([
          'jquery-ui'], function() {
          require([
              'jquery-ui.touch-punch',
              // [...]
          ]);
      });
  });
  </code></pre>
  
  <p>The idea here is that <code>'jquery'</code> defines a global (window context) <code>jQuery</code> variable, <code>'jquery-ui'</code> sets <code>jQuery.ui</code> and <code>'jquery-ui.touch-punch'</code> alters <code>jQuery.ui</code> (for better touch support).</p>
  
  <p>This works well when running as is, i.e. without optimization. However, after compiling into one file and minifying using the <a href="http://requirejs.org/docs/optimization.html" rel="nofollow noreferrer">RequireJS optimizer</a>, the following error occurs:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'mouse' of undefined
  </code></pre>
  
  <p>This happens on a line trying to access <code>jQuery.ui.mouse</code>.</p>
  
  <p>Inside the browser console, <code>jQuery</code> is correctly set in the window context, but <code>jQuery.ui</code> is undefined.
  However, manually executing <code>require(['jquery-ui'])</code> does set <code>jQuery.ui</code> as expected.</p>
  
  <p>It seems like jQuery UI behaves differently after optimization, but I can't see how exactly or why. What am I doing wrong?</p>