angular-architects / module-federation-plugin

MIT License
713 stars 191 forks source link

Getting 404 for Angular Core when upgrading to Native Federation 18.1 #624

Open tonybrasunas-greenlots opened 3 weeks ago

tonybrasunas-greenlots commented 3 weeks ago

I'm upgrading an application from Module Federation v16 / Angular 16 to Native Federation 18.1.2 and Angular 18.2.0

I've completed the basics of the upgrade and migration to Native Federation / 18.2.

The Shell application loads but when attempting to load a remote (an exported Module) into the UI, I get an internal 404. It doesn't seem to find Angular core library in the file.

Screenshot 2024-08-20 at 10 33 32 AM

Has anyone else seen this issue?

This is the MFE's federation.config:

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

module.exports = withNativeFederation({

  name: 'fleetManagerFrontend',

  exposes: {
    './Module': './src/app/fleet-manager/fleet-manager.module.ts'
  },

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

  skip: [
    'rxjs/ajax',
    'rxjs/fetch',
    'rxjs/testing',
    'rxjs/webSocket',
  ]

And the host's federation.manifest:

{
  "fleetManagerFrontend": "http://localhost:4300/remoteEntry.json"
}
tonybrasunas-greenlots commented 3 weeks ago

As a followup here, it seems to be an issue with getting the shared dependencies, such as Angular, when loading the microfrontend.

The initial host loads fine, including Angular, but then when initiating the loading of the MFE and requesting shared copies, there's a 404.

Screenshot 2024-08-20 at 6 41 06 PM

elvysmarcos commented 3 weeks ago

I'm getting the same issue

image

image

I installed @types/node

tonybrasunas-greenlots commented 3 weeks ago

I'm seeing those issues too when running ng serve

Screenshot 2024-08-21 at 2 22 57 PM
alaindeurveilher commented 3 weeks ago

The cause of the issue and a temporary workaround are provided in the following issue: https://github.com/angular-architects/module-federation-plugin/issues/621

tonybrasunas-greenlots commented 2 weeks ago

Thanks for the tip @alaindeurveilher, but this seems to be a different issue. I used the patch to rewrite the one line in the library'sbuilder.js, but that does not solve this issue for me.

Or, more accurately, when I use that patch, I get a different issue: Unable to resolve specifier@angular/profile-browser` and then Host application doesn't even load