2

I'm migrating an existing Angular v16 module-federation application to Angular v18 and the esbuild-based native federation plugin. The application has a dozen microfrontends hosted inside the shell application.

I've gotten the host application updated and running native-federation, and I've made the basic changes in the first microfrontend to load it as a remote inside the shell. But when I try to initiate loading that MFE inside the shell, I get 404 errors for the shared libraries (such as angular core and angular common) as an async/await request can't find them.

Why aren't the basic libraries shared?

enter image description here

I'm using the vanilla template for sharing the MFE via the federation.manifest.json file.

const { withNativeFederation, shareAll } = require('@angular-architects/native-federation/config');

module.exports = withNativeFederation({

  name: 'managerFrontend',

  exposes: {
    './Component': './src/app/manager/manager.component.ts'
  },

  shared: {
    ...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
  },

  skip: [
    'rxjs/ajax',
    'rxjs/fetch',
    'rxjs/testing',
    'rxjs/webSocket'
  ]
  
});
2
  • I had the same issue with a new app created with Angular 18.2 and native federation v18. I also activated zoneless, I don’t know if it’s relevant.
    – AlainD.
    Commented Aug 24, 2024 at 8:00
  • I encountered the same error and I don't know what to do. Commented Oct 17, 2024 at 11:23

1 Answer 1

0

Precise versions seem to be needed here.

I was able to fix this by using the very latest version of the plug-in and by precisely matching the versions of the Angular libraries.

It also seems there was a bug in the original v18 version of the Native Federation plug-in, something that was fixed with v18.2.2.

  "dependencies": {
    "@angular-architects/native-federation": "^18.2.2",
    "@angular/animations": "18.2.7",
    "@angular/common": "18.2.7",
    "@angular/compiler": "18.2.7",
...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.