-
Notifications
You must be signed in to change notification settings - Fork 700
Description
Reproduction link or steps
Reproduction on REPL
For input modules with following import relations:
flowchart TD
A[entry.js]
B[manual1.js]
C[manual2.js]
D[shared.js]
A --> B
A --> C
B --> D
C --> D
and with the following advancedChunks:
advancedChunks: {
groups: [
{
test: /manual1/,
name: 'manual1',
},
{
test: /manual2/,
name: 'manual2',
},
]the output chunks are generated in a way that the original shared.js module is included in manual1 chunk and import relation becomes following:
flowchart TD
A[entry.js]
B[manual1-xxx.js]
C[manual2-yyy.js]
A --> B
A --> C
C --> B
This behavior seems to conflict with the explanation in the documentation https://rolldown.rs/guide/in-depth/advanced-chunks where it says:
If a module is not captured by
manual chunking, it will still be put into a chunk which is created byautomatic chunkingwhile respecting the rules we explained in the code splitting guide.
Documentation further mentions a following in https://rolldown.rs/guide/in-depth/advanced-chunks#why-does-the-group-contain-modules-that-don-t-satisfy-the-constraints,
Why does the group contain modules that don't satisfy the constraints?
When a module is captured by a group, Rolldown will try to capture its dependencies recursively without considering constraints.
...
Enabling InputOptions.preserveEntrySignatures: false | 'allow-extension' will prevent the bundler from capturing the dependencies of the captured module.
so, this might be an expected default behavior though. However, I couldn't find a way to prevent this behavior either by modifying preserveEntrySignatures or advancedChunks.includeDependenciesRecursively options.
What is expected?
Output chunks may look like this. For example, this output avoids manual2-xxx.js to import manual1-xxx.js, which helps reduce cache invalidation (e.g. when changing only original manual1.js, it won't influence manual2-xxx.js output.)
flowchart TD
A[entry.js]
B[manual1-xxx.js]
C[manual2-yyy.js]
D[shared-zzz.js]
A --> B
A --> C
B --> D
C --> D
What is actually happening?
See reproduction and above comment.
System Info
replAny additional comments?
I was following the issue and PR on rollup rollup/rollup#6086 rollup/rollup#6087, which seems to be discussing the shared module chunking behavior.
Not urgent personally (previously I tried to use manualChunks for optimizing client reference chunking in rsc plugin, but now I found more robust way to go solely with automatic chunking).