Andreas Köberle
Andreas Köberle

Reputation: 110892

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

Upvotes: 0

Views: 128

Answers (1)

Andreas Köberle
Andreas Köberle

Reputation: 110892

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

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

Upvotes: 1

Related Questions