Splitting increases total size of output, because of import/export statement overhead
- Dominant language
- Go
- Stars
- 40.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
Hi! I am trying to use the `splitting: true` flag to break our monolithic bundle up into dynamic imports.
While this is functional, the total size of the emitted split code is substantially larger than the monolithic bundle, which is negating a lot of the benefit of chunking in the first place
For example,
* Non split `main.min.js` is 15MB
* Split `main.split.min.js` + all of the ~50 chunks is 18MB
I _think_ this is because of the overhead of the `import/export` statements that are emitted? In some of the largest chunks, there are 1195 lines of imported modules at the top of the file, and 560 exported modules. Multiply this by the ~50 chunks, and I think this is contributing to the size overhead
```
import {
....
} from "./chunk-xxxxx.js"
...
export {
...
};
```
Would it be possible to replace these verbose statements with an `import * as x from "./chunk-xxx.js` instead? There would still be overhead from adding `x.` to every usage of a module from the `x` chunk, but I feel like that would be considerably less overhead than we have now?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the reported comparison between a 15MB non-split bundle and the roughly 18MB split output with about 50 chunks. Inspect the emitted import and export statements in the largest chunks; done means splitting remains functional while substantially reducing this statement overhead.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system, performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100