Skip to content

Manual grouping keeps extra dynamic-import proxy chunks compared to Rollup #9729

Description

@aminpaks

Reproduction

https://github.com/aminpaks/rolldown-dynamic-imports-extra-proxy-chunks

git clone https://github.com/aminpaks/rolldown-dynamic-imports-extra-proxy-chunks
cd rolldown-dynamic-imports-extra-proxy-chunks
pnpm install
pnpm run verify

Setup

src/main.js dynamically imports three modules:

await Promise.all([
  import('./a.js'),
  import('./b.js'),
  import('./c.js'),
]);

Both Rollup and Rolldown are configured with the same grouping intent: put a.js, b.js, and c.js into shared-abc.

Expected behavior

Rolldown matches Rollup's output shape: dynamic imports are rewritten to load the merged chunk directly.

Rollup output:

dist-rollup/
├─ main-*.js
└─ shared-abc-*.js

Actual behavior

Rolldown emits the merged chunk, but keeps one proxy chunk per original dynamic-import target:

dist-rolldown/
├─ main-*.js
├─ a-*.js           # proxy imports shared-abc
├─ b-*.js           # proxy imports shared-abc
├─ c-*.js           # proxy imports shared-abc
└─ shared-abc-*.js

Each proxy is effectively:

import {r as A} from './shared-abc-*.js';
export {A};

So import('./a.js') loads a-*.js, then a-*.js loads shared-abc-*.js.

Verify output

bundler   version  chunks  shared-abc  a/b/c proxies
--------  -------  ------  ----------  -------------
Rolldown  1.1.0    5       yes         3
Rollup    4.60.4   2       yes         0

Question

Is this proxy-preserving output intentional? If so, is there an option for users who want Rollup-like behavior where dynamic imports point directly at the merged chunk?

Metadata

Metadata

Assignees

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions