fix: inject global entry to async entrypoints#12096
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for Web Workers in Module Federation by implementing global entry dependencies handling and adding comprehensive E2E tests. The changes enable workers to properly load shared modules through Module Federation and support HMR for worker code.
- Adds global entry dependencies processing in the code splitter to ensure federation runtime modules are available in worker chunks
- Updates the EmbedFederationRuntimeModule stage to
Triggerfor proper execution ordering - Adds E2E tests for Module Federation workers and worker HMR scenarios
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/tsconfig.json | Disables JS type checking for E2E tests to avoid TypeScript errors in JavaScript test files |
| tests/e2e/cases/worker/worker-hmr/* | Adds test case for worker Hot Module Replacement functionality |
| tests/e2e/cases/worker/mf-worker/* | Adds test case for Module Federation shared module loading in workers |
| crates/rspack_plugin_mf/src/container/embed_federation_runtime_module.rs | Updates runtime module stage to Trigger for correct execution order |
| crates/rspack_core/src/build_chunk_graph/code_splitter.rs | Adds global entry dependencies processing for worker chunks |
Comments suppressed due to low confidence (1)
tests/e2e/cases/worker/worker-hmr/rspack.config.js:1
- Unused variable path.
const path = require("path")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Binary Size-limit
❌ Size increased by 3.13KB from 47.86MB to 47.86MB (⬆️0.01%) |
CodSpeed Performance ReportMerging #12096 will not alter performanceComparing Summary
|
|
Can we document this behaviour? |
|
@copilot submit a PR to document this behavior, adding to:
|
Add documentation for global entry behavior (when name is undefined): - Global entries are now injected into both regular and async entrypoints - Includes use cases for webpack-dev-server and ModuleFederationPlugin - Added examples showing how global entries work with Workers Related to PR #12096 Co-authored-by: chenjiahan <7237365+chenjiahan@users.noreply.github.com>
* Initial plan * docs: document global entry behavior in EntryPlugin Add documentation for global entry behavior (when name is undefined): - Global entries are now injected into both regular and async entrypoints - Includes use cases for webpack-dev-server and ModuleFederationPlugin - Added examples showing how global entries work with Workers Related to PR #12096 Co-authored-by: chenjiahan <7237365+chenjiahan@users.noreply.github.com> * Update entry-plugin.mdx * Update entry-plugin.mdx --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: chenjiahan <7237365+chenjiahan@users.noreply.github.com> Co-authored-by: neverland <chenjiahan.jait@bytedance.com>
Summary
If a entry name is undefined, then the entry is global entry, before we only add global entry's dependencies and includedDependencies into Entrypoints, after this PR global entry's dependencies and includedDependencies will also added into AsyncEntrypoints (created by
new Worker()most of the time). So...new EntryPlugin(..., { name: undefined }).apply(compiler),addEntry(..., { name: undefined }), oraddInclude(..., { name: undefined })) will also be affected if the added code is not compatible with worker environment, but I don't think this kind of secret usage existsRelated links
fix #7417
fix #12015
fix #12072
Checklist