Skip to content

fix: mf container entry use startup to load initial chunks#12142

Merged
ahabhgk merged 4 commits intomainfrom
mf-container-entry-startup
Nov 11, 2025
Merged

fix: mf container entry use startup to load initial chunks#12142
ahabhgk merged 4 commits intomainfrom
mf-container-entry-startup

Conversation

@ahabhgk
Copy link
Contributor

@ahabhgk ahabhgk commented Nov 10, 2025

Summary

Resolve the issue where the container entry of Module Federation cannot use splitChunks.chunks = "all" in dev mode

  • In dev mode, the container entry using HMR will bundle the dev-server and HMR client as entries, and these two entries are often located in node_modules, triggering the default splitting logic.
  • There is no issue in prod mode because the container entry itself splits all dependencies asynchronously. Asynchronously split chunks, being async chunks, do not trigger splitChunks.chunks = "all".

This PR add RuntimeGlobals::STARTUP_CHUNK_DEPENDENCIES to 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

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 10, 2025 09:55
@netlify
Copy link

netlify bot commented Nov 10, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 2c79a64
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6911ecc1b938400008dba4e4

@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Nov 10, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 startupChunkDependencies field to entry options across Rust and TypeScript layers
  • Updated StartupChunkDependenciesPlugin to respect per-entry configuration with smart defaults based on chunk loading type
  • Registered the plugin for Jsonp and Import chunk 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.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2025

📦 Binary Size-limit

Comparing 2c79a64 to fix: loader order of nested rules (#12132) by nilptr

❌ Size increased by 5.00KB from 48.08MB to 48.08MB (⬆️0.01%)

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 10, 2025

CodSpeed Performance Report

Merging #12142 will not alter performance

Comparing mf-container-entry-startup (2c79a64) with main (c57e2db)

Summary

✅ 17 untouched

@ahabhgk ahabhgk force-pushed the mf-container-entry-startup branch from 6eaef16 to 6a6ec81 Compare November 10, 2025 13:02
@ahabhgk ahabhgk enabled auto-merge (squash) November 11, 2025 05:54
Copy link
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahabhgk ahabhgk merged commit f70f870 into main Nov 11, 2025
48 checks passed
@ahabhgk ahabhgk deleted the mf-container-entry-startup branch November 11, 2025 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants