Issue 1:
Bug report

What is the current behavior?

behavior

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.

logs

[webpack.cache.PackFileCacheStrategy] restore cache container: 93.993068 ms

[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)

[webpack.cache.PackFileCacheStrategy] Restored pack from /home/gitlab-runner/cache/custom-cjh-test/v5Cache/prod-cache.pack, but build dependencies have changed.

[webpack.cache.PackFileCacheStrategy] resolving of build dependencies is invalid, will re-resolve build dependencies

[webpack.cache.PackFileCacheStrategy] check build dependencies: 591.095263 ms

Browserslist: caniuse-lite is outdated. Please run the following command: npx browserslist --update-db

If the current behavior is a bug, please provide the steps to reproduce.

Package programs in different folders and use the same cache

What is the expected behavior?

Even if the package directory is changed, the cache is still valid because the same pack is used

Other relevant information:

webpack version: 5.61.0

Node.js version: 14.18

Operating System: unbantu

Additional tools: gitlab:14.3.0

Additional tools:

Issue 2:
What is the current behavior?

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

I believe this is what issue #6656 was trying to say as well.

If the current behavior is a bug, please provide the steps to reproduce.

Here is an example entry for the dll config

entry: { base: [ 'bootstrap', ], jqueryui: ['jquery-ui/ui/widgets/draggable'] },

and loaded into the main configuration like so...

new webpack.DllReferencePlugin({

context: __dirname,

manifest: require('./dist/dll/base.json')

}),

new webpack.DllReferencePlugin({
context: process.cwd(),
manifest: require('./dist/dll/jqueryui.json')
}),

layout.html includes...

<script src="/dist/dll/base.dll.js"></script>

What is the expected behavior?

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.

Dynamically load the dll into the page that it requires only. Do not throw an error if all dlls are not included.

Other relevant information:

webpack version: 4.18.1

Node.js version: 8.12.0

Operating System: Win 10

Additional tools: