fix(mf): respect request changes in shared plugins#12863
Conversation
Update ConsumeSharedPlugin and ProvideSharedPlugin to use data.request instead of the original dependency request. This ensures that modifications made to the request in hooks like beforeResolve are correctly handled.
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression in Module Federation where shared dependencies were not correctly matched when custom resolvers modified the request in hooks like beforeResolve. The fix ensures that both ConsumeSharedPlugin and ProvideSharedPlugin use the modified data.request instead of the original dependency request.
Changes:
- Updated
ConsumeSharedPluginto usedata.requestinstead ofdep.request()in the factorize hook - Updated
ProvideSharedPluginto usedata.requestinstead ofcreate_data.raw_requestin the module hook - Added test coverage for shared modules with custom request resolution
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rspack_plugin_mf/src/sharing/consume_shared_plugin.rs | Changed to use data.request instead of dep.request() to respect request modifications from hooks |
| crates/rspack_plugin_mf/src/sharing/provide_shared_plugin.rs | Changed to use data.request instead of create_data.raw_request to respect request modifications from hooks |
| tests/rspack-test/configCases/container-1-0/change-data-request/x.js | Added test module for shared module testing |
| tests/rspack-test/configCases/container-1-0/change-data-request/rspack.config.js | Added shared module configuration and custom resolver hook for myX |
| tests/rspack-test/configCases/container-1-0/change-data-request/bootstrap.js | Added test assertion for shared module resolution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 128bytes from 48.34MB to 48.34MB (⬆️0.00%) |
Merging this PR will not alter performance
Comparing Footnotes
|
Deploying rspack with
|
| Latest commit: |
840c36a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d0afd104.rspack-v2.pages.dev |
| Branch Preview URL: | https://fix-change-request-for-consu.rspack-v2.pages.dev |
Summary
Update ConsumeSharedPlugin and ProvideSharedPlugin to use
data.requestinstead of the original dependency request. This ensures that modifications made to the request in hooks like beforeResolve are correctly handled.Related links
fix #11437
Checklist