Don't bundle lazy loaded chunk specified in webpack config

Viewed 85

I have a file structure like this (simplified):

src/
  index.ts
  lazy.ts
  something.ts
webpack.config.js

In index.ts I import lazy.ts using async import. In both modules I import something.ts. Because something.ts is bundled with index.ts in the main chunk I have to tell webpack that it should use the same module cache for lazy.ts. Or did I understand something wrong? So I specified a chunk in webpack.config.js that depends on the main chunk and has the lazy.ts entry. Now I get three chunks instead of two because webpack bundles lazy.ts twice. How can I solve that?

0 Answers
Related