0

Question: Is it possible to share an app config, that was configured in the parent with an imported submodule in JavaScript?

import firebase from "firebase/compat/app";
firebase.initializeApp(window.config);


import { someView } from "@custom-package/views";


someView()

//within the package @custom-package/views

import firebase from "firebase/compat/app";
const someView = ()=>{
   //some firestore query
   firebase.firestore().....
}

export default {
   someView
}


Currently, I'm getting this error:

Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app-compat/no-app)

As an additional info, I can share, that @custom-package/views is bundled with webpack and served as a private NPM package.

enter image description here

roundrobin
  • 674
  • 1
  • 7
  • 23

1 Answers1

0

Can you try adding firebase.initializeApp(window.config); before you call the firestore in your @custom-package/views.

The error you mentioned usually happens when firebase calls were made before invoking firebase app initialization. You can see here that that is the case.

Hope this helps.

Michael C
  • 308
  • 1
  • 6
  • Hi Michael, thanks for your answer. As you can see in my example, I'm calling it it before calling `@custom-package/views` – roundrobin Jun 19 '23 at 08:04