title: How to run a ton of scripts in global context?
body: <p>I <em>think</em> I've got most of my 3rd party libraries working without using <a href="https://github.com/webpack/script-loader" rel="nofollow">script-loader</a>, but none of legacy scripts will work. They're all written like,</p>
  
  <pre><code>var i_am_totally_global = 6;
  
  function i_expect_to_just_run_in_the_browser() {}
  </code></pre>
  
  <p>So the only option I can think of is to just run them in the global/window context. However, if I try to create an "entry" script with something like this,</p>
  
  <pre><code>require('script!./AjaxList');
  require('script!./MozCompatibility');
  require('script!./DynamicSelect');
  require('script!./DynamicSelect2');
  require('script!./prototype');
  ...
  </code></pre>
  
  <p>Then <code>ProvidePlugin</code> won't work on them, which means they can't access my vendor libs unless I <code>script!</code> those too, but then I'm back to square one -- everything global and webpack does nothing for me.</p>
  
  <p>Isn't there a way to <a href="https://webpack.github.io/docs/shimming-modules.html#exporting" rel="nofollow">export</a> everything that was declared in the global scope, without explicitly listing out each and every single function + var?</p>
  
  <hr>
  
  <p>I found another loader, <a href="https://github.com/peerigon/legacy-loader" rel="nofollow">legacy-loader</a>, which I thought would do what I wanted. However, it can only export globals that have been added to the window object, either explicitly (<code>window.abc = xyz</code>) or implicitly (<code>abc = xyz</code>). If, however, your legacy script does <code>var abc = xyz</code> or <code>function abc() {}</code> it won't work because if you wrap that in a function, then those become local vars which are pretty much impossible to access in JavaScript.</p>
  
  <p>The only real way to do it AFAIK is to actually <em>parse</em> the JavaScript. However, Webpack is already parsing the JS so you'd hope that it could gather up these top-level local vars, but there doesn't appear to be an option for that.</p>