fix(module-federation): strip version suffix from npm dependency names for bun compatibility - #34960
Merged
leosvelperez merged 3 commits intoJul 17, 2026
Conversation
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
👷 Deploy request for nx-dev pending review.Visit the deploys page to approve it
|
theescodes
force-pushed
the
fix/module-federation-bun-dependency-names
branch
from
March 25, 2026 17:52
7903b1d to
92db7c0
Compare
…s for bun compatibility
theescodes
force-pushed
the
fix/module-federation-bun-dependency-names
branch
from
April 1, 2026 18:32
9c1d129 to
1eea8b7
Compare
Contributor
|
View your CI Pipeline Execution ↗ for commit 364ab9e
☁️ Nx Cloud last updated this comment at |
FrozenPandaz
pushed a commit
that referenced
this pull request
Jul 20, 2026
…s for bun compatibility (#34960) ## Current Behavior When using Bun as the package manager, the Nx project graph includes version numbers in external node dependency targets (e.g., `npm:@ngrx/store@21.0.1`), whereas npm uses `npm:@ngrx/store` (without version). The `collectDependencies` function in `packages/module-federation/src/utils/dependencies.ts` strips the `npm:` prefix but not the version suffix, resulting in package names like `@ngrx/store@21.0.1` being passed to `sharePackages()`. These fail to match entries in `package.json` (which uses `@ngrx/store`), so **no npm packages are shared** between Module Federation host and remotes, causing runtime errors such as: ``` NG0201: No provider found for InjectionToken @ngrx/store Root Store Provider ``` ## Expected Behavior The version suffix is stripped from npm dependency names before they are added to the shared packages set. For example: - `@ngrx/store@21.0.1` -> `@ngrx/store` - `rxjs@7.8.1` -> `rxjs` - `lodash` (no version) -> `lodash` (unchanged) This ensures shared packages are correctly resolved regardless of the package manager (npm, pnpm, yarn, or bun). ## Related Issue(s) #35135 Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com> (cherry picked from commit 2ecb611)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
When using Bun as the package manager, the Nx project graph includes version numbers in external node dependency targets (e.g.,
npm:@ngrx/store@21.0.1), whereas npm usesnpm:@ngrx/store(without version).The
collectDependenciesfunction inpackages/module-federation/src/utils/dependencies.tsstrips thenpm:prefix but not the version suffix, resulting in package names like@ngrx/store@21.0.1being passed tosharePackages(). These fail to match entries inpackage.json(which uses@ngrx/store), so no npm packages are shared between Module Federation host and remotes, causing runtime errors such as:Expected Behavior
The version suffix is stripped from npm dependency names before they are added to the shared packages set. For example:
@ngrx/store@21.0.1->@ngrx/storerxjs@7.8.1->rxjslodash(no version) ->lodash(unchanged)This ensures shared packages are correctly resolved regardless of the package manager (npm, pnpm, yarn, or bun).
Related Issue(s)
#35135