Is there a problem to use a random `output.uniqueName` in Webpack?

Viewed 10

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

string

A unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. It defaults to output.library name or the package name from package.json in the context, if both aren't found, it is set to an ''.

output.uniqueName will 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(),
    // ...
  },
};
0 Answers
Related