I know we can use firebase.apps.length to check whether the Firebase is initiated or not.
Eg:
import firebase from 'firebase';
if (!firebase.apps.length) {
firebase.initializeApp({});
}
export default firebase;
https://github.com/zeit/next.js/issues/1999
However, I read another question on StackOverflow that if we import the same file multiple times, it just runs once (Does ES6 module importing execute the code inside the imported file?)
So the question is why Firebase behaves like that? I mean if this post is true: Does ES6 module importing execute the code inside the imported file?, then we don't need to check firebase.apps.length in the first place because it just runs once no matter how many times we import it