Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module Federation shared libs with PNPM has only core Angular packages and missing all the rest #26136

Closed
1 of 4 tasks
gultyayev opened this issue May 27, 2024 · 5 comments
Closed
1 of 4 tasks
Assignees
Labels
blocked: repro needed blocked: retry with latest Retry with latest release or head. outdated scope: module federation Issues related to module federation support type: bug

Comments

@gultyayev
Copy link

gultyayev commented May 27, 2024

Current Behavior

I have a simple MFE repo. 1 host app and 1 remote. All apps are Angular 18 + Ionic.
The problem is that NX doesn't recognize dependencies from PNPM. Only @angular/* packages are listed (I placed a call to check what it prints out)

shared: (name, config) => {
    console.log({name});

    return config;
  },

Results in
image

Which is way too few dependencies. However, if I switch to NPM the amount of dependencies almost tripled.

I also tried to specify '@jsverse/transloco' in additionalShared which resulted in error that "project graph doesn't list it as a dependency".

Expected Behavior

The shared singleton libs with the default config should be identically resolved for PNPM and NPM.

GitHub Repo

No response

Steps to Reproduce

  1. Create an NX workspace.
  2. Create a host and a remote Angular apps.
  3. Use PNPM as a package manager. This is important.
  4. Add @ionic/angular for example.
  5. Add the logging function to see what dependencies are registered
shared: (name, config) => {
    console.log({name});

    return config;
  },
  1. nx serve the host app.
  2. Notice, that there is nothing but the @angular packages and the remote
  3. Remove pnpm-lock and install packages now with NPM
  4. Serve again, notice how much more packages are present all of a sudden

Nx Report

Node   : 20.13.1
OS     : darwin-arm64
npm    : 10.5.2

nx                 : 19.1.0
@nx/js             : 19.1.0
@nx/jest           : 19.1.0
@nx/linter         : 19.1.0
@nx/eslint         : 19.1.0
@nx/workspace      : 19.1.0
@nx/angular        : 19.1.0
@nx/cypress        : 19.1.0
@nx/devkit         : 19.1.0
@nx/eslint-plugin  : 19.1.0
@nx/express        : 19.1.0
@nx/node           : 19.1.0
@nx/playwright     : 19.1.0
@nrwl/tao          : 19.1.0
@nx/web            : 19.1.0
@nx/webpack        : 19.1.0
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/playwright/plugin
@nx/eslint/plugin
@nx/cypress/plugin
---------------------------------------
Community plugins:
@ionic/angular         : 8.2.0
@ionic/angular-toolkit : 11.0.1
@jsverse/transloco     : 7.4.1

Failure Logs

No response

Package Manager Version

pnpm 9.1.2

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@FrozenPandaz FrozenPandaz added the scope: module federation Issues related to module federation support label May 29, 2024
@Coly010
Copy link
Contributor

Coly010 commented Jun 3, 2024

Can you try this again on Nx 19.1.1, or provide a reproduction repo where this can be reproduced?

I was not able to reproduce it, and got the same results with npm and pnpm:

PNPM

pnpx nx build shell
Packages: +108
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 117, reused 108, downloaded 0, added 108, done

> nx run shell:build:production

⠋ Generating browser application bundles (phase: setup)...    TypeScript compiler options "target" and "useDefineForClassFields" are set to "ES2022" and "false" respectively by the Angular CLI. To control ECMA version and features use the Browserslist configuration. For more information, see https://angular.dev/tools/cli/build#configuring-browser-compatibility
    NOTE: You can set the "target" to "ES2022" in the project's tsconfig to remove this warning.
remote/Routes
@nx/webpack
@angular/router
@angular/core
@ionic/angular
@angular/common
@angular/platform-browser
@nx/angular
remote/Routes
@angular/core
@angular/core/primitives/event-dispatch
@angular/core/primitives/signals
@angular/core/rxjs-interop
@angular/core/testing
@angular/animations
@angular/animations/browser
@angular/animations/browser/testing
@angular/common
@angular/common/http
@angular/common/http/testing
@angular/common/testing
@angular/common/upgrade
@nx/webpack
@angular/router
@angular/router/testing
@angular/router/upgrade
@ionic/angular
@ionic/angular/common
@ionic/angular/standalone
@angular/platform-browser
@angular/platform-browser/animations
@angular/platform-browser/animations/async
@angular/platform-browser/testing
@nx/angular
@nx/angular/module-federation
@nx/angular/src/generators/utils
@nx/angular/src/utils
@nx/angular/testing

NPM

npx nx build shell

> nx run shell:build:production

⠋ Generating browser application bundles (phase: setup)...    TypeScript compiler options "target" and "useDefineForClassFields" are set to "ES2022" and "false" respectively by the Angular CLI. To control ECMA version and features use the Browserslist configuration. For more information, see https://angular.dev/tools/cli/build#configuring-browser-compatibility
    NOTE: You can set the "target" to "ES2022" in the project's tsconfig to remove this warning.
remote/Routes
@nx/webpack
@angular/router
@angular/core
@ionic/angular
@angular/common
@angular/platform-browser
@nx/angular
remote/Routes
@angular/core
@angular/core/primitives/event-dispatch
@angular/core/primitives/signals
@angular/core/rxjs-interop
@angular/core/testing
@angular/animations
@angular/animations/browser
@angular/animations/browser/testing
@angular/common
@angular/common/http
@angular/common/http/testing
@angular/common/testing
@angular/common/upgrade
@nx/webpack
@angular/router
@angular/router/testing
@angular/router/upgrade
@ionic/angular
@ionic/angular/common
@ionic/angular/standalone
@angular/platform-browser
@angular/platform-browser/animations
@angular/platform-browser/animations/async
@angular/platform-browser/testing
@nx/angular
@nx/angular/module-federation
@nx/angular/src/generators/utils
@nx/angular/src/utils
@nx/angular/testing

@Coly010 Coly010 added blocked: repro needed blocked: retry with latest Retry with latest release or head. labels Jun 3, 2024
@gultyayev
Copy link
Author

@Coly010 attached the repro.

Just in case,

> node -v
v20.14.0
> pnpm -v
9.1.4

Archive.zip

@gultyayev
Copy link
Author

Tried NX 19.2. Did not fix the issue either.

@gultyayev
Copy link
Author

Seems that nx reset with rm -rf node_modules and pnpm install fixed the issue. Might be that after switching from NPM to PNPM there were some leftovers in the NX cache, or pnpm install migrated the node_modules a bit differently than it would install packages with no folder present before.

Copy link

github-actions bot commented Jul 8, 2024

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: repro needed blocked: retry with latest Retry with latest release or head. outdated scope: module federation Issues related to module federation support type: bug
Projects
None yet
Development

No branches or pull requests

3 participants