Skip to content

fix(mf): resolve version from parent package for secondary entry points#13636

Open
davidfestal wants to merge 4 commits intoweb-infra-dev:mainfrom
davidfestal:fix/provide-shared-secondary-entry-point
Open

fix(mf): resolve version from parent package for secondary entry points#13636
davidfestal wants to merge 4 commits intoweb-infra-dev:mainfrom
davidfestal:fix/provide-shared-secondary-entry-point

Conversation

@davidfestal
Copy link
Copy Markdown

Summary

  • Fix ProvideSharedPlugin to resolve the version from a parent package when a secondary entry point's package.json has no version field (e.g. @mui/material/styles, @emotion/react/jsx-runtime)
  • Add a new find_parent_package_version method that walks up the directory tree from the description file, bounded by node_modules, and validates the relationship by checking the shared key matches <parent_name>/<relative_path>
  • Add test case share-plugin-secondary-entry-point covering scoped packages with secondary entry points

Fixes #13635

Context

When sharing secondary entry points like @mui/material/styles, the nearest package.json is at node_modules/@mui/material/styles/package.json which has no version. The version lives in the parent node_modules/@mui/material/package.json. Before this fix, ProvideSharedPlugin emitted a warning and failed to provide the shared module with a version.

This complements #8388 (which addressed ConsumeSharedPlugin for monorepo hoisting) by fixing the same class of problem in ProvideSharedPlugin.

Upstream references:

Test plan

  • Added configCases/sharing/share-plugin-secondary-entry-point test with a scoped package (@scope/pkg) that has a secondary entry point (styles/) whose package.json has no version
  • Existing sharing tests continue to pass (no behavioral change for packages that already have version in their own package.json)
  • CI green

Made with Cursor

Copilot AI review requested due to automatic review settings April 7, 2026 17:40
@davidfestal davidfestal requested a review from ahabhgk as a code owner April 7, 2026 17:40
@github-actions github-actions bot added the release: bug fix release: bug related release(mr only) label Apr 7, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b9bd904f2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

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 fixes Module Federation sharing in ProvideSharedPlugin for packages that use “secondary entry points” (subpath exports) whose nearest package.json lacks a version, by falling back to the parent package’s version (e.g. @mui/material/styles@mui/material).

Changes:

  • Add parent-package version lookup for secondary entry points when version is missing in the nearest package.json.
  • Update ProvideSharedPlugin to use the parent version instead of warning/failing when the relationship is validated.
  • Add a new sharing config case share-plugin-secondary-entry-point to cover a scoped package with a versionless secondary entry point.

Reviewed changes

Copilot reviewed 3 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/rspack_plugin_mf/src/sharing/provide_shared_plugin.rs Adds parent package.json traversal + version fallback when a secondary entry point has no version.
tests/rspack-test/configCases/sharing/share-plugin-secondary-entry-point/rspack.config.js New config case enabling sharing for @scope/pkg and @scope/pkg/styles.
tests/rspack-test/configCases/sharing/share-plugin-secondary-entry-point/index.js New runtime test importing the root and secondary entry point.
tests/rspack-test/configCases/sharing/share-plugin-secondary-entry-point/node_modules/@scope/pkg/package.json Fixture parent package with name + version.
tests/rspack-test/configCases/sharing/share-plugin-secondary-entry-point/node_modules/@scope/pkg/index.js Fixture root entry implementation.
tests/rspack-test/configCases/sharing/share-plugin-secondary-entry-point/node_modules/@scope/pkg/styles/package.json Fixture secondary entry point without version.
tests/rspack-test/configCases/sharing/share-plugin-secondary-entry-point/node_modules/@scope/pkg/styles/index.js Fixture secondary entry implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@davidfestal davidfestal force-pushed the fix/provide-shared-secondary-entry-point branch 2 times, most recently from 2dc9c6c to f08c013 Compare April 7, 2026 17:53
@davidfestal davidfestal requested a review from Copilot April 7, 2026 17:54
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

Copilot reviewed 3 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@davidfestal davidfestal force-pushed the fix/provide-shared-secondary-entry-point branch 2 times, most recently from d268b1a to 3ec7587 Compare April 8, 2026 11:35
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 9, 2026

Merging this PR will degrade performance by 1.21%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 26 untouched benchmarks
⏩ 10 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation rust@concatenate_module_code_generation 137 ms 135.6 ms +1.06%
Simulation rust@persistent_cache_restore@basic-react-development 26.1 ms 26.4 ms -1.21%

Comparing davidfestal:fix/provide-shared-secondary-entry-point (d9eb58a) with main (5c34571)

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

When a secondary entry point (e.g. `@mui/material/styles`) has its own
`package.json` without a `version` field, ProvideSharedPlugin now walks
up the directory tree to find the parent package's version instead of
emitting a warning. This matches the behavior expected for packages that
use the secondary entry point pattern (MUI, Emotion, Apollo Client, etc).

The fix validates the relationship by checking that the shared key
exactly equals `<parent_name>/<relative_path>` and stops at the
`node_modules` boundary.

Fixes: webpack/webpack#15864
Ref: webpack/webpack#13457

Made-with: Cursor
Signed-off-by: David Festal <dfestal@redhat.com>
@davidfestal davidfestal force-pushed the fix/provide-shared-secondary-entry-point branch from 3ec7587 to 9c14987 Compare April 9, 2026 13:16
@davidfestal davidfestal requested a review from Copilot April 9, 2026 13:21
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

Copilot reviewed 4 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(mf): ProvideSharedPlugin should resolve version from parent package for secondary entry points

3 participants