<h1 dir="auto">Bug report</h1>
<p dir="auto">Both "module" export and "import" export of exports field are resolved in duplication.</p>




<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">3rd party lib swr's output assets are resolved in different cases:</p>
<ul dir="auto">
<li>When swr is imported, it resolves to <code class="notranslate">swr/dist/index.esm.js</code></li>
<li>Then subpath import <code class="notranslate">swr/infinite</code> is imported, which is relying on <code class="notranslate">swr</code></li>
<li>Then swr is resolved in 2nd time, but now <code class="notranslate">swr/dist/index.mjs</code> is resolved</li>
</ul>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<p dir="auto"><a href="https://github.com/beeebox/webpack-esm-duplicated-resolve">https://github.com/beeebox/webpack-esm-duplicated-resolve</a></p>
<p dir="auto">yarn start<br>
browser should open on localhost:3000<br>
open devtools and search "swr"<br>
you'll see <code class="notranslate">swr/dist/index.esm.js</code> and <code class="notranslate">swr/dist/index.mjs</code> are both resolved there</p>






<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto"><code class="notranslate">swr/dist/index.mjs</code> or <code class="notranslate">swr/dist/index.esm.js</code> is resolved only all the time</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version: v5.70.0<br>
Node.js version: v14.17.0<br>
Operating System: MacOS 12.0.1<br>
Additional tools:</p>
<h1 dir="auto">Bug report</h1>
<p dir="auto">I have submitted this question in stackoverflow, but I haven't received any reply。</p>
<p dir="auto"><a href="https://stackoverflow.com/questions/65642712/webpack-5-cannot-reuse-caches-in-different-file-structures" rel="nofollow">https://stackoverflow.com/questions/65642712/webpack-5-cannot-reuse-caches-in-different-file-structures</a></p>
<p dir="auto"><strong>What is the current behavior?</strong></p>
<ol dir="auto">
<li>
<p dir="auto">I use the file cache of Webpack5 through the following configuration, and set the cache files in a public folder</p>
</li>
<li>
<p dir="auto">In the case of the file directory structure unchanged, build again. At this time, caching can be applied successfully, greatly reducing the build time</p>
</li>
<li>
<p dir="auto">I copied the entire project code to the same directory as testbuild</p>
</li>
<li>
<p dir="auto">Under the new directory testBuild, execute the build and find that the previously generated cache is not applied. It generates new ones</p>
</li>
<li>
<p dir="auto">Supplementary Note: This test is to simulate the real CI construction process, and my goal is to significantly reduce the build time on CI construction</p>
</li>
</ol>
<p dir="auto"><code class="notranslate">cache: { type: 'filesystem', cacheDirectory: path.resolve(paths.cachePath,'prod-cache'), }</code></p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<p dir="auto">Because of the problem of office environment, I can't code to GitHub warehouse. All I can offer is a few configuration fragments</p>
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">In the case of the same code, different file directories can reuse the file cache</p>
<p dir="auto"><strong>Other relevant information:</strong></p>
<p dir="auto">webpack version: 5.11.0<br>
Node.js version: v10.15.3<br>
Operating System: window 10<br>
Additional tools:</p>