Search code examples
webpackcode-splitting

Webpack code splitting adds module twice


I use webpacks dynamic code splitting, which works quite well so far. But I have one module (mC) with a large dependency that is required from two other modules (mA & mB). With code splitting there are two bundles created both with the same content of largeLib. And for each of modules on of the bundles is loaded. I would expect that only one module is created and used by both mA and mB

 mA    mB
   \  / 
    \/ 
    mC
    |
  largeLib

Solution

  • Adding an specific name to the import solves the problem for me:

     import(/* webpackChunkName: "handsOnTable" */ 'react-handsontable'),