Open raliand opened 1 month ago
@raliand
I've run into this issue recently and I solved it by adding firebase/app
and firebase/messaging
to the skip
array in federation.config.js
like this:
const { withNativeFederation, shareAll } = require('@angular-architects/native-federation/config');
module.exports = withNativeFederation({
shared: {
...shareAll({ singleton: true, strictVersion: false, requiredVersion: 'auto' }),
},
skip: [
'rxjs/ajax',
'rxjs/fetch',
'rxjs/testing',
'rxjs/webSocket',
'firebase/app',
'firebase/messaging',
// Add further packages you don't need at runtime
]
});
You will still be able to import and use firebase
functions where necessary in your project, e.g.:
import { initializeApp } from 'firebase/app';
import { getMessaging, getToken, onMessage } from 'firebase/messaging';
The reason for this issue occuring might be that firebase
is being loaded twice - once when federation plugin sets up all the dependencies via withNativeFederation
call and then again when you actually import it somewhere. Same error occurs when using @angular/fire
, by the way. @manfredsteyer worth looking into, perhaps?
@vladimirs-puzanovs-vr Thank you for the suggestion. The point though, is to initialize the firebase app once when bootstrapping the skeleton app and use it across all the federated apps. We do this with module federation and Angular 14 and it works really well. I am trying to understand if it will be possible to do this with an app where we use only standalone components.
I am trying to create an angular project to work with the Firebase (@angular/fire) and Native Federation in an NX Monorepo.
This is my setup: tsconfig.base.json
package.json
app.config.ts
app.routes.ts
app.component.ts
project.json
When I run the application through nx run broker-bi:serve-original it runs as expected but with no native federation. When I run it through nx run broker-bi:serve I get the following error:
What am I dong wrong?