I have just encountered an issue in which two Webpack 5 instances were conflicting in my page. I finally discovered that both were using the same output.uniqueName.
From the docs:
output.uniqueName
stringA unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. It defaults to
output.libraryname or the package name frompackage.jsonin the context, if both aren't found, it is set to an''.
output.uniqueNamewill be used to generate unique globals for:
output.chunkLoadingGlobal
Changing one of them manually fixed my issue.
However, I am looking for a more automated solution, since I will have lots of projects, and I don't want to manually keep track of this and risk conflicts.
My question: is there anything wrong in assigning a random string to output.uniqueName in the webpack config, like shown below? Of course, this name will change on different executions of the same project, but is this a problem?
// webpack.config.js
module.exports = {
// ...
output: {
uniqueName: generateRandomString(),
// ...
},
};