title: How to configure webpack 4 to prevent chunks from list of entry points appearing in any other bundle?
body: <p>I am working on a large project and trying to land webpack 3 -> 4 update. This app has somewhere around 1,000 entry points, and about 10 of those are considered "global" or "core" and guaranteed to be on every page. These core bundles contain a mix of vendor and non-vendor code. I need to configure webpack to build all of these assets so that any chunks appearing in any of these bundles will not appear in any other bundle regardless of the size of the chunk, without creating new assets that need to be added to the page.</p>
  
  <p>With webpack 3, we have been using CommonsChunkPlugin to accomplish this. Here's a simple example:</p>
  
  <pre><code>new webpack.optimize.CommonsChunkPlugin({
    name: 'a-global-bundle',
    minChunks: Infinity,
  }),
  </code></pre>
  
  <p>Now with webpack 4 and the removal of CommonsChunkPlugin, it isn't clear to me how to accomplish this sort of optimization. </p>
  
  <p>I'd like to be able to give webpack a list of entry points and any chunks that appear in any of those will not appear in any other bundle, but I'm not sure how to do this. I've read through <a href="https://github.com/webpack/webpack.js.org/pull/1863/files" rel="noreferrer">some forthcoming documentation on <code>splitChunks</code></a> but I haven't been able to piece together a solution.</p>
  
  <p>I've set up a small repo as a starting point to tinker with: <a href="https://github.com/lencioni/webpack-splitchunks-playground" rel="noreferrer">https://github.com/lencioni/webpack-splitchunks-playground</a></p>
  
  <p>One interesting direction I'm trying out is configuring <code>cacheGroups</code> with a group for each of these entry points and implementing the <code>test</code> option with a function that does this check. However, the documentation is pretty sparse on this, so I'm not really sure what the right way to write this test function would be or even if this will work at all.</p>