Skip to content

[Bug]: (Compatibility) Chunk rename during generateBundle stage is ignored #5440

@maxpatiiuk

Description

@maxpatiiuk

Reproduction link or steps

  1. Clone the repository:

    git clone https://github.com/maxpatiiuk/rolldown-generate-bundle
    cd rolldown-generate-bundle
  2. Install rolldown and rollup dependencies:

    npm install
  3. Build

    npx rolldown -c
    npx rollup -c
  4. See that dist-rollup/ contains index-renamed.js (expected). See that dist-rolldown/ contains index.js (unexpected).

What is expected?

Changes to the chunk file name during generateBundle stage should be reflected.

What is actually happening?

Changes to the chunk file name during generateBundle stage are ignored.

System Info

System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 112.75 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.16.0 - ~/.local/state/fnm_multishells/2948_1753488629234/bin/node
    Yarn: 1.22.19 - ~/.local/state/fnm_multishells/2948_1753488629234/bin/yarn
    npm: 10.9.2 - ~/.local/state/fnm_multishells/2948_1753488629234/bin/npm
    pnpm: 8.9.0 - ~/.local/state/fnm_multishells/2948_1753488629234/bin/pnpm
  Browsers:
    Chrome: 138.0.7204.169
    Safari: 18.5
  npmPackages:
    rolldown: ^1.0.0-beta.29 => 1.0.0-beta.29

Any additional comments?

TLDR:

Discovered while testing compatibility of my framework with rolldown-vite.
I don't yet know the chunk file name at the config() stage - I know it by the generateBundle() stage, so I rename the chunks during generateBundle().

I am a web component framework author. The frameworks creates an entrypoint for each web component based on the web component tag name. The tag name is written inside the component source code.

During the config() stage I run readdir() to find the list of web component entrypoint files and pass such list to lib.entries in Vite (which is then passed to Rollup/Rolldown as input).

During transform stage, I collect information about each web component, including the tag name.

Later, during the generateBundle stage, I rename each chunk (and its references) to use the web component tag name instead of the original source code file name.

If this is not possible in Rolldown, I would either need to rename the files after Rolldown prints them to disk (tricky as that may conflict with other plugins) or reachitect the framework to parse each file and extract the tag name during the config() stage.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions