fix: mf container entry use startup to load initial chunks#12142
fix: mf container entry use startup to load initial chunks#12142
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for the startupChunkDependencies entry option, which controls whether chunks with dependent entries should be loaded at startup. This feature allows fine-grained control over chunk loading behavior per entry point.
- Added
startupChunkDependenciesfield to entry options across Rust and TypeScript layers - Updated
StartupChunkDependenciesPluginto respect per-entry configuration with smart defaults based on chunk loading type - Registered the plugin for
JsonpandImportchunk loading types to support the new option
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/rspack/src/builtin-plugin/EntryPlugin.ts | Adds startupChunkDependencies field to JsEntryOptions (hardcoded to undefined) |
| crates/rspack_plugin_runtime/src/startup_chunk_dependencies.rs | Implements default logic and per-entry option handling |
| crates/rspack_plugin_runtime/src/lib.rs | Registers plugin for Jsonp and Import chunk loading types |
| crates/rspack_plugin_mf/src/container/container_plugin.rs | Enables startup chunk dependencies for module federation containers |
| crates/rspack_plugin_javascript/src/parser_plugin/worker_plugin.rs | Sets field to None for worker entries |
| crates/rspack_core/src/compilation/make/module_executor/execute.rs | Sets field to None for module executor |
| crates/rspack_core/src/chunk_group.rs | Adds startup_chunk_dependencies field to EntryOptions struct |
| crates/rspack_binding_api/src/options/entry.rs | Adds field to JS bindings and conversion logic |
| crates/rspack/src/builder/mod.rs | Sets field to None when building entry options |
| crates/node_binding/napi-binding.d.ts | Adds TypeScript type definition for the new field |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Binary Size-limit
❌ Size increased by 5.00KB from 48.08MB to 48.08MB (⬆️0.01%) |
CodSpeed Performance ReportMerging #12142 will not alter performanceComparing Summary
|
6eaef16 to
6a6ec81
Compare
chenjiahan
left a comment
There was a problem hiding this comment.
Should we remove this tip from our documentation?
https://rspack.rs/plugins/webpack/split-chunks-plugin#splitchunkscachegroupscachegroupchunks
Summary
Resolve the issue where the container entry of Module Federation cannot use
splitChunks.chunks = "all"in dev modesplitChunks.chunks = "all".This PR add
RuntimeGlobals::STARTUP_CHUNK_DEPENDENCIESto control wether generate a startup for the entry chunk, and use the startup to automatically load the splitted initial chunks for container entry.The startup_chunk_dependencies runtime code already used by CommonJsChunkLoadingPlugin and ImportsScriptChunkLoadingPlugin, this PR just also applies that to the rest ChunkLoadingPlugin (jsonp, and import).
Related links
Checklist