Skip to content

[Feature Request]: reduce the number of chunks by merging sideeffect free chunks #4788

@sapphi-red

Description

@sapphi-red

What problem does this feature solve?

The aim is to improve the output chunking to follow the limitation set by advancedChunks option. The aim is to improve the output chunking when the advancedChunks option is not specified.

Currently, IIUC Rolldown does not try merging sideeffect free chunks. Without doing this, many small chunks would be generated when there's multiple entries.

For example, for the following modules, Rolldown currently generates 3 entry chunks and 2 shared chunks.

flowchart LR
  page-a --> common1
  page-b --> common1
  page-b --> common2
  page-c --> common2
Loading

If common1 and common2 don't have a side effect, this can be improved to 3 entry chunks and 1 shared chunk. This is what rollup does when output.experimentalMinChunkSize is set (bundler explorer).
If page-a and page-b and page-c also don't have a side effect, this can be further improved to only 3 entry chunks (bundler explorer).

Related Rollup PRs: rollup/rollup#4705, rollup/rollup#4989

What does the proposed API look like?

Not an API change.

Metadata

Metadata

Assignees

No one assigned

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions