For explaining this issue. I have created a sample project. I am using purescript. I am doing a dynamic import and webpack is generating 2 bundles.
If I comment the dynamic import and use a static import, I am getting a bundle size around 12 KB. But, with dynamic split, webpack is generating 2 bundle, one is of 200 Bytes and other one 29 KB.
I am not sure why 20 KB is getting added in the first bundle after split.
Can someone help me in figuring out, What is increasing the bundle size ?
Could it be webpacks runtime for lazy loading modules?
No, the webpack runtime code for lazy loading is not that large. Seems like, webpack is creating an array of modules and putting all modules that are shared by multiple bundles (Like : Aff). So, terser cannot eliminate dead code and uglify JS effeciently .
This is just a threory, Not exactly sure.
This issue is only coming with webpack.
Rollup is able to split the bundle with 1 Kb or 2 Kb overhead. But, I am not sure about using Rollup bundle split in production.
@ajbarber Bundle analyzer was showing increase of few Kb in all modules. Thats add upto 20 Kb.
Not helpful.
You can check sample project link. I attached in main thread.