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

Duplicate shared library code in common.js in angular module fedaration #29748

Open
1 of 4 tasks
jannikbuscha opened this issue Jan 24, 2025 · 0 comments
Open
1 of 4 tasks
Assignees
Labels
scope: module federation Issues related to module federation support type: bug

Comments

@jannikbuscha
Copy link

jannikbuscha commented Jan 24, 2025

Current Behavior

I have an Angular Nx Module Federation Monorepo with three micro frontends in /apps (Shell, MFE1, MFE2).

I also have a shared library (SharedDataService) in /libs.

I use this shared library in MFE1 and MFE2 and the code of the service is in their common.js files.

Is this correct because it creates redundancy? Can't this be outsourced from the common.js?

Image

Expected Behavior

I already know from this issue why there is a common.js file in each case/MFE, but I don't understand why the shared library is not outsourced or how to do this.

GitHub Repo

https://github.com/jannikbuscha/exp_arbeit.git

Steps to Reproduce

  1. cd .\nx-module-federation\
  2. npm install
  3. npx nx serve shell

Nx Report

Node           : 20.18.0
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 10.8.2

nx                     : 20.3.2
@nx/js                 : 20.3.2
@nx/eslint             : 20.3.2
@nx/workspace          : 20.3.2
@nx/angular            : 20.3.2
@nx/devkit             : 20.3.2
@nx/eslint-plugin      : 20.3.2
@nx/module-federation  : 20.3.2
@nx/web                : 20.3.2
@nx/webpack            : 20.3.2
typescript             : 5.6.3
---------------------------------------
Community plugins:
angular-eslint : 19.0.2

Failure Logs

Package Manager Version

10.8.2

Operating System

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

Additional Information

The problem remains with :

  shared: (library-name, sharedConfig) => {
    if (library-name === '@nx-module-federation/data') {
      return { singleton: true, requiredVersion: false };
    }

    return sharedConfig;
  },
@FrozenPandaz FrozenPandaz added the scope: module federation Issues related to module federation support label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: module federation Issues related to module federation support type: bug
Projects
None yet
Development

No branches or pull requests

3 participants