Skip to content

fix(enhanced): match version filters against the owning package - #5118

Merged
ScriptedAlchemy merged 4 commits into
mainfrom
worktree-agent-af375ba0e5d7cc1c0
Oct 9, 2026
Merged

ScriptedAlchemy merged 4 commits into
mainfrom
worktree-agent-af375ba0e5d7cc1c0

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Description

ConsumeSharedPlugin compares the full request with the package name when applying version filters. For a prefix share such as lib/, lib/sub does not match lib, so the filter is skipped.

Derive the owning package name and find its version with getDescriptionFile. This makes include.version and exclude.version work for package subpaths and suffix matches. Aliases can supply packageName; existing fallback-version handling is preserved.

Validation previously recorded: the regression fails on main and passes with the fix; 24 sharing config cases and 315 sharing unit tests pass. Reported CI passes; Metro and tree-shaking E2E are skipped.

Related Issue

No linked issue.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

@changeset-bot

changeset-bot Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1973e96

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 48 packages
Name Type
@module-federation/enhanced Patch
@module-federation/modern-js-v3 Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/rstest Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
@module-federation/playground Patch
remote5 Patch
remote6 Patch
website-new Patch
@module-federation/devtools Patch
@module-federation/cli Patch
create-module-federation Patch
@module-federation/dts-plugin Patch
@module-federation/error-codes Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/metro Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rock Patch
@module-federation/retry-plugin Patch
@module-federation/rspack Patch
@module-federation/runtime-core Patch
@module-federation/runtime-tools Patch
@module-federation/runtime Patch
@module-federation/sdk Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/treeshake-frontend Patch
@module-federation/treeshake-server Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/bridge-react Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-vue3 Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/esbuild Patch
@module-federation/observability-plugin Patch
@module-federation/utilities Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T00:52:01.425983Z 6525443 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Report

6 package(s) changed, 37 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/enhanced 817.3 kB -479 B (-0.1%) 672 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/cli 2.3 kB -3 B (-0.1%) 2.4 kB -32 B (-1.3%)
@module-federation/core 1.0 kB -1 B (-0.1%) 1.0 kB -33 B (-3.0%)
@module-federation/devtools 30.3 kB no change 30.3 kB -25 B (-0.1%)
@module-federation/enhanced 2.7 kB +12 B (+0.4%) 2.8 kB -44 B (-1.5%)
@module-federation/metro-plugin-rnc-cli 416 B +2 B (+0.5%) 435 B -26 B (-5.6%)
@module-federation/node 9.1 kB +5 B (+0.1%) 9.2 kB -29 B (-0.3%)

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 22.3 kB -14 B (-0.1%) 23.8 kB -16 B (-0.1%) +1.6 kB -2 B

Total dist (raw): 23.40 MB (-479 B (-0.0%))
Total ESM gzip: 111.7 kB (no change)
Total web bundle (gzip): 253.4 kB (+15 B (+0.0%))
Total node bundle (gzip): 255.6 kB (-189 B (-0.1%))
Tracked ./bundler entry gzip: 563 B (no change)
Tracked ./bundler web bundle (gzip): 4.9 kB (no change)
Tracked ./bundler node bundle (gzip): 4.9 kB (no change)

Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as ./bundler are measured separately so ENV_TARGET-driven tree-shaking is visible. Bare imports are externalized to keep package-level sizes consistent, and assets are emitted as resources.

@pkg-pr-new

pkg-pr-new Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/@module-federation/devtools@1973e96

@module-federation/cli

pnpm add https://pkg.pr.new/@module-federation/cli@1973e96

create-module-federation

pnpm add https://pkg.pr.new/create-module-federation@1973e96

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/@module-federation/dts-plugin@1973e96

@module-federation/enhanced

pnpm add https://pkg.pr.new/@module-federation/enhanced@1973e96

@module-federation/error-codes

pnpm add https://pkg.pr.new/@module-federation/error-codes@1973e96

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@1973e96

@module-federation/managers

pnpm add https://pkg.pr.new/@module-federation/managers@1973e96

@module-federation/manifest

pnpm add https://pkg.pr.new/@module-federation/manifest@1973e96

@module-federation/metro

pnpm add https://pkg.pr.new/@module-federation/metro@1973e96

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnc-cli@1973e96

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnef@1973e96

@module-federation/metro-plugin-rock

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rock@1973e96

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@1973e96

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/@module-federation/modern-js-v3@1973e96

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@1973e96

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@1973e96

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@1973e96

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@1973e96

@module-federation/observability-plugin

pnpm add https://pkg.pr.new/@module-federation/observability-plugin@1973e96

@module-federation/playground

pnpm add https://pkg.pr.new/@module-federation/playground@1973e96

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/@module-federation/retry-plugin@1973e96

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/@module-federation/rsbuild-plugin@1973e96

@module-federation/rspack

pnpm add https://pkg.pr.new/@module-federation/rspack@1973e96

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/@module-federation/rspress-plugin@1973e96

@module-federation/rstest

pnpm add https://pkg.pr.new/@module-federation/rstest@1973e96

@module-federation/runtime

pnpm add https://pkg.pr.new/@module-federation/runtime@1973e96

@module-federation/runtime-core

pnpm add https://pkg.pr.new/@module-federation/runtime-core@1973e96

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/@module-federation/runtime-tools@1973e96

@module-federation/sdk

pnpm add https://pkg.pr.new/@module-federation/sdk@1973e96

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@1973e96

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/@module-federation/third-party-dts-extractor@1973e96

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/@module-federation/treeshake-frontend@1973e96

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/@module-federation/treeshake-server@1973e96

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@1973e96

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@1973e96

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/@module-federation/webpack-bundler-runtime@1973e96

@module-federation/bridge-react

pnpm add https://pkg.pr.new/@module-federation/bridge-react@1973e96

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/@module-federation/bridge-react-webpack-plugin@1973e96

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/@module-federation/bridge-shared@1973e96

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/@module-federation/bridge-vue3@1973e96

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/@module-federation/inject-external-runtime-core-plugin@1973e96

commit: 1973e96

The include.version and exclude.version filters compare the version of the
package that owns the resolved fallback. For a prefix consume such as
'lib/' the request is 'lib/sub', so the case checks that the filter uses
the version of the 'lib' package instead of the nearest package.json name.
The include.version and exclude.version filters read the nearest
package.json to the resolved fallback and skipped the filter when its
name differed from the request. The request is the full import, so a
prefix consume such as 'lib/' matched against lib/sub, an alias, a
relative or absolute request, or a nested package.json without a name
was always consumed.

Derive the package name the way requiredVersion inference does and walk
up with getDescriptionFile until a versioned package.json with that
name is found. Both filters share one helper. When no such file exists,
the module is still consumed, as before.
A relative, absolute, or aliased consume config has no package name
unless packageName is set. Walking up to the nearest versioned
package.json for those consumes compared the host app's own version,
which dropped './src/local' under include.version '^2.0.0' where main
consumed it. Keep main's behavior there and apply the walk-up only when
the package name is known.

The config case now asserts that a relative consume with include.version
is still consumed, and that an aliased consume with packageName set is
filtered by that package's version.
… guard

The exclude branch compares exclude.fallbackVersion before it reads any
package.json, so it ran for every consume with a resolved fallback. The
package-name guard was placed above it and turned that comparison off
for relative, absolute, and aliased configs. Move the guard to just
before the package.json walk. The include branch only reaches
include.fallbackVersion after a name match, so it is unchanged.

The config case asserts that './src/local2' with exclude.version
'^1.0.0' and fallbackVersion '1.0.0' is not consumed.
@ScriptedAlchemy
ScriptedAlchemy merged commit caafd8d into main Oct 9, 2026
24 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the worktree-agent-af375ba0e5d7cc1c0 branch October 9, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants