There are three common scenarios for controlling output chunks:
- Default behavior: Each entry point generates its own file. If there is shared code, it is extracted into a separate chunk.
- Unbundle mode (also known as
preserveModules): The output structure mirrors the source directory. Ideally, there are no additional files except for those in virtualDirname.
Currently, even if all files are specified as input, this ideal cannot be fully achieved: shared code is still extracted into a chunk, resulting in an output structure that does not perfectly match the source directory.
- Implemented now.
- Single file mode: Each entry produces exactly one file with no import statements, which is typically required for CDN consumption. While
inlineDynamicImports partially achieves this, shared chunk behavior must also be disabled (to simulate esbuild’s splitting behavior).
The last two one scenario currently presents the biggest challenge for migration.
Related Issues
There are three common scenarios for controlling output chunks:
preserveModules): The output structure mirrors the source directory. Ideally, there are no additional files except for those invirtualDirname.Currently, even if all files are specified asinput, this ideal cannot be fully achieved: shared code is still extracted into a chunk, resulting in an output structure that does not perfectly match the source directory.inlineDynamicImportspartially achieves this, shared chunk behavior must also be disabled (to simulate esbuild’ssplittingbehavior).shared.jsand the output format isiife, the contents ofshared.jsshould be duplicated in both output files.input. Example: https://stackblitz.com/edit/github-ehiwc7lh-pk9i7zur?file=rolldown.config.mjsThe last
twoone scenario currently presents the biggest challenge for migration.Related Issues
preserveModulesoutput option #2622 (preserveModules)inlineDynamicImports)splitting)