Angular Modular Federation with base-href for remote module in shell
I’ve 2 remote apps app1
and app2
and a shell app myapp
, since all the applications will be behind a proxy, each app is distinguished by base-href i.e, /app1
,/app2
and /myapp
respectively. From app1
App1Module is exposed as a remote which has app1.component which loads data from relative path of app1
from ./assets/config.json
, the code snippet to load the config.json is as shown below.
Why doesn’t Angular automatically load remoteEntry.js with Webpack Module Federation even after configuration?
I am using Webpack’s Module Federation feature in an Angular project. I have properly made all the necessary setup in custom-webpack.config.js for Module Federation. However, I am running into an issue: Angular doesn’t automatically import the remoteEntry.js file.
From what I understand, Module Federation uses static import, which means that remoteEntry.js should be directly referenced in my Angular application. But in my case, it looks like Angular does not automatically load this file. I have read that this can be solved by manually including the script file in the index.html or by using Webpack’s dynamic public path feature. However, each method comes with its own drawbacks.
I am looking for a way to automatically import this file in Angular. Why doesn’t Angular support this out of the box? Has anyone faced this issue before or have any ideas of how to solve this?
Thanks in advance.
Angular and Module Federation Navigating From One Remote to Another ‘TypeError: Cannot read properties of undefined (reading ‘call’)’
Using Angular 17.3.4, nx 18.2.4, and Module Federation.