Repository navigation
Conversation
codeSplitting group chunk
57fd9b0 to
fa6206a
Compare
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
…time host assertion `debug_assert_runtime_host_keeps_evaluation_order` re-sorts the imports of each importer of the runtime host with the keys of `assign_chunk_exec_orders`, but it keyed an entry chunk on its entry module. When an entry chunk holds modules that execute before its entry module, the re-sorted list differed from the real one even though the host moved nothing, and debug builds panicked. Share the entry chunk key through `entry_chunk_exec_order`.
…ntry module A `codeSplitting` group with `includeDependenciesRecursively: false` can take an entry module and leave its dependencies in the entry chunk, which then imports the group chunk. Keyed on those dependencies, the entry chunk sorted before the group chunk in the imports of other chunks, and when the two chunks import each other the group chunk's modules ran before those dependencies. An entry chunk whose entry module is in another chunk keys on its entry module.
…just the entry's exports When a `codeSplitting` group that captures a dynamic entry moves into the entry chunk, every binding that other chunks import from the group becomes an export of the entry chunk, and `import()` of the entry gives it as an extra key. As Rollup's `canModuleBeFacade` does, fold the group only when every binding that other chunks import from it is an export of the entry module; otherwise keep the facade-elimination path and its simulated namespace. `bindings_imported_from_other_chunks` predicts these bindings from the imports of the modules instead of running the cross-chunk link pass. The folded chunk also takes over the group's `chunk_reason_type`, so the runtime placement does not make it the runtime host for other consumers, as it does not choose the group chunk. The helpers that those consumers import would otherwise be keys of the namespace. `issue_5276_2`, `dynamic_import_host_exporting_then` and `dynamic_import_host_exporting_aliased_then` use their original inputs again, and their output is the same as on main. `facade_elimination_with_shared_cjs_dep` uses its original input too: `en_US` folds, and `ar_EG`, whose group holds a CommonJS module that `en_US` also imports, keeps the simulated namespace.
|
I pushed a commit on top of this PR, after the two commits from #11506. The group is folded into the dynamic entry only when other chunks import nothing from it but the entry module's exports, as Rollup's The folded chunk keeps the group's chunk reason, so the runtime is not moved into it for other chunks.
This needs to land after #11506. |
✅ Deploy Preview for rolldown-rs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
this 'stacks' on ##11506, so only the last commit is new.
I noticed this - while trying to group Nuxt layouts - that when a group captures the target of a dynamic
import(), the resulting chunk loses its facade:without the group, the layout chunk has
isDynamicEntry: trueandfacadeModuleId: '/.../layout.js'. with it, it hasisDynamicEntry: false,facadeModuleId: null, andmoduleIdsgainsrolldown/runtime.js, because the importer now goes throughimport('./layout.js').then((n) => n.t)and the chunk builds the namespace with__exportAll.in Vite this means the chunk is no longer in the manifest under its source file, so things like modulepreload and CSS links for it go missing.
I think this is the facade elimination in
find_facade_chunk_merge_ops, which folds the empty dynamic entry chunk into the group chunk and simulates its namespace.so this PR goes the other way when the group chunk holds no other entry module: the group's modules move into the dynamic entry chunk (keeping the group's name), just like what already happens for a user-defined entry whose module lands in a group. (rollup does the same for
manualChunksin the simple case with manual chunk name + dynamic entry as facade).a few existing fixtures would otherwise have stopped going through facade elimination, so I added a second dynamic entry for each....
let me know if you have any better ideas on how to fix it, and feel free to close and fix differently, or just push to this PR 🙏