Skip to content

fix: inject global entry to async entrypoints#12096

Merged
ahabhgk merged 2 commits intomainfrom
fix-mf-worker
Nov 6, 2025
Merged

fix: inject global entry to async entrypoints#12096
ahabhgk merged 2 commits intomainfrom
fix-mf-worker

Conversation

@ahabhgk
Copy link
Copy Markdown
Contributor

@ahabhgk ahabhgk commented Nov 5, 2025

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...

  1. Global entry that created by devServer now will also added into Worker runtime
  2. Global entry that created by ModuleFederationPlugin will also added into Worker runtime
  3. Existing plugins that using global entry (new EntryPlugin(..., { name: undefined }).apply(compiler), addEntry(..., { name: undefined }), or addInclude(..., { 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 exists

Related links

fix #7417
fix #12015
fix #12072

Checklist

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

Copilot AI review requested due to automatic review settings November 5, 2025 12:23
@netlify
Copy link
Copy Markdown

netlify bot commented Nov 5, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 2639b17
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/690b4350e2f1160008461c8d

@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 5, 2025
Copy link
Copy Markdown
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 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 Trigger for 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 5, 2025

📦 Binary Size-limit

Comparing 2639b17 to chore: release v1.6.1 (#12092) by Hana

❌ Size increased by 3.13KB from 47.86MB to 47.86MB (⬆️0.01%)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 5, 2025

📝 Ecosystem CI detail: Open

suite result
modernjs ✅ success
rstest ❌ failure
rsdoctor ✅ success
examples ✅ success
nuxt ✅ success
rslib ❌ failure
rspress ✅ success
rsbuild ✅ success
lynx-stack ❌ failure
plugin ❌ failure
devserver ❌ failure

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 5, 2025

CodSpeed Performance Report

Merging #12096 will not alter performance

Comparing fix-mf-worker (2639b17) with main (11814b5)

Summary

✅ 17 untouched

@ahabhgk ahabhgk enabled auto-merge (squash) November 5, 2025 15:07
@ahabhgk ahabhgk merged commit 6b7fb5f into main Nov 6, 2025
89 of 91 checks passed
@ahabhgk ahabhgk deleted the fix-mf-worker branch November 6, 2025 01:34
@chenjiahan
Copy link
Copy Markdown
Member

Can we document this behaviour?

@chenjiahan
Copy link
Copy Markdown
Member

@copilot submit a PR to document this behavior, adding to:

  • website/docs/en/plugins/webpack/entry-plugin.mdx
  • website/docs/zh/plugins/webpack/entry-plugin.mdx

Copilot AI added a commit that referenced this pull request Nov 6, 2025
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>
chenjiahan added a commit that referenced this pull request Nov 10, 2025
* 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>
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

4 participants