Repository navigation
fix(enhanced): match version filters against the owning package - #5118
Conversation
🦋 Changeset detectedLatest commit: 1973e96 The changes in this PR will be included in the next version bump. This PR includes changesets to release 48 packages
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Bundle Size Report6 package(s) changed, 37 unchanged. Package dist + ESM entry
Bundle targets
Consumer scenarios
Total dist (raw): 23.40 MB (-479 B (-0.0%)) Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as |
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/esbuild
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/metro-plugin-rock
@module-federation/modern-js
@module-federation/modern-js-v3
@module-federation/native-federation-tests
@module-federation/native-federation-typescript
@module-federation/nextjs-mf
@module-federation/node
@module-federation/observability-plugin
@module-federation/playground
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/rstest
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/storybook-addon
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/typescript
@module-federation/utilities
@module-federation/webpack-bundler-runtime
@module-federation/bridge-react
@module-federation/bridge-react-webpack-plugin
@module-federation/bridge-shared
@module-federation/bridge-vue3
@module-federation/inject-external-runtime-core-plugin
commit: |
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.
d575ac1 to
1973e96
Compare
Description
ConsumeSharedPlugincompares the full request with the package name when applying version filters. For a prefix share such aslib/,lib/subdoes not matchlib, so the filter is skipped.Derive the owning package name and find its version with
getDescriptionFile. This makesinclude.versionandexclude.versionwork for package subpaths and suffix matches. Aliases can supplypackageName; 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
Checklist