<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong></p>
<ul dir="auto">
<li>behavior<br>
When using webapck5 persistent cache on gitlab Ci, it will report "${old path} / package.json invalidated because hashes different (6659fb289dbe3f4ff4d0f5bee22a6e8a! = 41c5ea20b50ed6ff92c1d79510fc1f9a)" ${old path} is the path of the last package. Obviously, webpack 5 compares the package of the old directory when restoring the cache JSON instead of the package. Of the new directory json. After I fix the directory, the cache is valid. I think persistent cache is better than package JSON should compare the current directory instead of the last packaged directory.</li>
<li>logs<br>
 [webpack.cache.PackFileCacheStrategy] restore cache container: 93.993068 ms<br>
[webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] /home/gitlab-runner/builds/oH9a6sGM/1/we-work-frontend/we-work-webapp-new/package.json invalidated because hashes differ (6659fb289dbe3f4ff4d0f5bee22a6e8a != 41c5ea20b50ed6ff92c1d79510fc1f9a)<br>
[webpack.cache.PackFileCacheStrategy] Restored pack from /home/gitlab-runner/cache/custom-cjh-test/v5Cache/prod-cache.pack, but build dependencies have changed.<br>
[webpack.cache.PackFileCacheStrategy] resolving of build dependencies is invalid, will re-resolve build dependencies<br>
 [webpack.cache.PackFileCacheStrategy] check build dependencies: 591.095263 ms<br>
Browserslist: caniuse-lite is outdated. Please run the following command: <code class="notranslate">npx browserslist --update-db</code></li>
</ul>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong><br>
Package programs in different folders and use the same cache</p>






<p dir="auto"><strong>What is the expected behavior?</strong><br>
Even if the package directory is changed, the cache is still valid because the same pack is used</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  5.61.0<br>
Node.js version: 14.18<br>
Operating System:  unbantu<br>
Additional tools: gitlab:14.3.0<br>
Additional tools:</p>
<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">I have 2 named items in my config to create dll bundles. The first one is intended as the base references for the whole site and I am including that on my main layout.html page. The 2nd one is only meant for a separate page and should be dynamically loaded by webpack. The issue is that I get an error when loading layout.html stating ....Uncaught ReferenceError: [the 2nd dll name] is not defined</p>
<p dir="auto">I believe this is what issue <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="301779833" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/6656" data-hovercard-type="issue" data-hovercard-url="/webpack/webpack/issues/6656/hovercard" href="https://github.com/webpack/webpack/issues/6656">#6656</a> was trying to say as well.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<p dir="auto">Here is an example entry for the dll config<br>
<code class="notranslate">entry: {    base: [ 'bootstrap',             ],         jqueryui: ['jquery-ui/ui/widgets/draggable'] },   </code></p>
<p dir="auto">and loaded into the main configuration like so...<br>
new webpack.DllReferencePlugin({<br>
context: __dirname,<br>
manifest: require('./dist/dll/base.json')<br>
}),</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    new webpack.DllReferencePlugin({
        context: process.cwd(),
        manifest: require('./dist/dll/jqueryui.json')
    }),"><pre class="notranslate"><code class="notranslate">    new webpack.DllReferencePlugin({
        context: process.cwd(),
        manifest: require('./dist/dll/jqueryui.json')
    }),
</code></pre></div>
<p dir="auto">layout.html includes...</p>
 &lt;script src="/dist/dll/base.dll.js"&gt;&lt;/script&gt;
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">loading layout.html does not require jqueryui.dll to be loaded as well. This is wasteful as it is not needed on this page. If I do load jqueryui.dll in layout.html it does not throw the error.</p>

<p dir="auto">Dynamically load the dll into the page that it requires only. Do not throw an error if all dlls are not included.</p>
<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  4.18.1<br>
Node.js version: 8.12.0<br>
Operating System: Win 10<br>
Additional tools:</p>