<p dir="auto">This is a hypothetical but I couldn't find a good answer to it and thought might ask it here. Let's say my project requires <code class="notranslate">foo@0.0.2</code> and <code class="notranslate">bar@0.0.1</code>. In the meantime, <code class="notranslate">bar</code> requires <code class="notranslate">foo@0.0.1</code>. Which version of <code class="notranslate">foo</code> would be loaded by webpack? Would both versions be loaded? What can I do to prevent both versions from being loaded, if that is the case?</p>
<h1 dir="auto">Bug report</h1>
<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">Our webpack build produces 15 chunks (3 initial <code class="notranslate">manifest</code>, <code class="notranslate">main</code>,  <code class="notranslate">vendor</code> + the rest are dynamic chunks via <code class="notranslate">import()</code> or <code class="notranslate">require.ensure()</code>).</p>
<p dir="auto">I wanted to experiment with split chunks (<a href="https://webpack.js.org/plugins/split-chunks-plugin/#splitchunks-chunks" rel="nofollow">https://webpack.js.org/plugins/split-chunks-plugin/#splitchunks-chunks</a>) -- as explained <code class="notranslate">splitChunks.chunk</code> can be a method returning a <code class="notranslate">Boolean</code> to decide whether a given chunk should be optimized further (additional code splitting) or not.</p>
<p dir="auto">I put in place the following config:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    optimization: {
      splitChunks: {
        chunks() {
            console.dir(chunk.name)
            return false
        },"><pre class="notranslate"><code class="notranslate">    optimization: {
      splitChunks: {
        chunks() {
            console.dir(chunk.name)
            return false
        },
</code></pre></div>
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">I would expect to see all the 15 chunks names, one time each -- each callback would decide whether to optimize a given chunk or not</p>
<p dir="auto"><strong>What is the actual behavior?</strong></p>
<p dir="auto">I don't see certain chunks getting callback at all, and I see some other chunks listed twice.<br>
There's no clear pattern about which kinds of chunks are missing and which are duplicated.</p>
<p dir="auto">I.e. expected output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="chunk1
chunk2
chunk3
...
chunk15"><pre class="notranslate"><code class="notranslate">chunk1
chunk2
chunk3
...
chunk15
</code></pre></div>
<p dir="auto">Actual:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="chunk1
chunk2
chunk3
chunk4
chunk3
chunk4
chunk8
chunk9
chunk10
chunk9
chunk10"><pre class="notranslate"><code class="notranslate">chunk1
chunk2
chunk3
chunk4
chunk3
chunk4
chunk8
chunk9
chunk10
chunk9
chunk10
</code></pre></div>
<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  4.26.0<br>
Node.js version: 8.11.3<br>
Operating System: Win 10</p>
<p dir="auto">Does this look like a bug? Did someone encounter this too? Is it work digging further to find a minimum repro?<br>
Maybe I misunderstand how this is supposed to work? (the docs are scarce so I'm not fully sure)</p>