title: How to properly add jquery plugins to jquery object in webpack?
body: <p><strong>TL;DR</strong>
  What is the proper way of extending jQuery object with plugins, exposing it globally and using external AMD libs with ES6 modules in webpack?
  Is webpack the right tool for the task, or would SystemJs suit the situation of refactoring a legacy app to ES6 modules better?</p>
  
  <p>I am trying to wrap my head around working with webpack and ES6 modules. I have a legacy mostly jquery app that I am currently converting. I am facing the following challenges:</p>
  
  <ol>
  <li>finding best practices in the webpack/babel-loader workflow</li>
  <li>figuring out which loader/plugin to use for which purpose</li>
  <li>getting AMD resources like jquery and jquery plugins to play nice with the rest of the modules.</li>
  <li>exposing jquery globals, extended with all the plugins and jquery-ui</li>
  </ol>
  
  <p>I have relied on the following resources:
  This great answer explains a lot, though it does not mention the exports loader, which I am mostly relying on:    <a href="https://stackoverflow.com/a/28989476/2613786">https://stackoverflow.com/a/28989476/2613786</a></p>
  
  <p><a href="http://webpack.github.io/docs/shimming-modules.html" rel="nofollow noreferrer">http://webpack.github.io/docs/shimming-modules.html</a> - the documentation lists many possibilities, but i lack the experience to decide which one is the right one. It seems to be preferred to use the ProvidePlugin instead of the expose-loader. Sadly I didn't get it to work with an extended jQuery object. Neither did it work for the use of module functions invoced in <code>&lt;script&gt;</code> tags.</p>
  
  <p>I still struggle to find programatic solutions and decide which webpack plugin is the right one for the job. Some advice or examples from an experienced webpack user are greatly appreciated.</p>
  
  <p>In my <code>webpack.config.js</code> i have the following loaders to expose jquery and transpile with babel:</p>
  
  <pre><code>module: {
      loaders: [
          { 
              test: /\.js$/, 
              exclude: /node_modules/,
              loader: 'babel-loader',
              query: {modules: 'common'}
          },
          {
              test: /jquery\.js$/,
              exclude: /node_modules/,
              loader: 'expose?jQuery',
          },
          {
              test: /jquery\.js$/,
              exclude: /node_modules/,
              loader: 'expose?$',
          },
          {
              test: /[\/\\]vendor[\/\\]jquery.sparkline\.js$/,
              loader: "imports?define=&gt;false"
          }
      ]
  },
  amd: { jQuery: true },
  // plugins: [
  //     new webpack.ProvidePlugin({
  //        $: 'jquery',
  //        jQuery: 'jquery',
  //        'window.jQuery': 'jquery',
  //        'root.jQuery': 'jquery'
  //    })
  // ], ...
  </code></pre>
  
  <p>In my entry.js file I include jquery in the following way:</p>
  
  <pre><code>import 'expose?jQuery!expose?$!./vendor/jquery';
  import './jquery/jquery-ui';
  import './vendor/jquery.sparkline';
  </code></pre>
  
  <p>I had to comment out the ProvidePlugin, when i use it, the jQuery is not extended with custom plugins anymore, any idea why that is the case? 
  Does it have to do with the plugins using ES6 module syntax? </p>
  
  <p>I had to add <code>loader: "imports?define=&gt;false"</code> for <code>jquery.sparkline.js</code> to get it to be recogniced. Is this really necessary, or is there a better way to do it?</p>
  
  <p>Concerning jquery-ui i had to find an old version that did not use AMD define to get it to add to the jquery object. What would be the right way to do it?</p>
  
  <p>Any help and advice is greatly appreciated, a reason to switch to SystemJs and Jspm might also be a solution.</p>