0

Is it possible to specify libraries you actually want duplicated across bundles when using webpack splitchunk??

Context:

I am working with a large monorepo with multiple packages and entry points. The current webpack configuration uses

{ optimization: { splitChunks: { chunks: "all" } } }

with multiple entry points across the monorepo. It produces a vendor file for each package in the monorepo as well as a large vendors~boot file with all common dependencies to prevent duplication across each bundle.

Each section of the app will load the main vendors bundle, and the bundles related to the package that its currently in.

There are a couple of large libraries used in small areas of the application which I want to allow to be duplicated. I don't want those libraries split out into the common chunk and loaded everywhere. so basically i want certain libraries duplicated which to my knowledge is exactly what splitchunks prevents.

  • Any chance you ever found a solution to this? I'm in almost exactly the same position; our monorepo needs to keep 3 areas completely ring fenced so if they use the same library, they have a duplicated reference in their own "lib" bundle. – slashwhatever Sep 28 '21 at 14:49
  • @slashwhatever - actually i did find somewhat of a solution but by no means perfect and kinda situational to lerna. using a lerna config option in the specific sub packages called 'noHoist' and ensuring those packages have slightly different minor versions of the library that i wanted to be duplicated. – maxwellutd Sep 29 '21 at 20:31

0 Answers0