🔥 fix: Firebase CDN Initialization Under tsdown CJS Interop (#14046)

The `@librechat/api` build migrated to tsdown (rolldown/oxc) in #13595.
tsdown externalizes third-party deps and uses strict CJS interop, so a
default import of the Firebase v9+ modular SDK — whose CJS entry is
`__esModule`-marked with only named exports and no `default` — resolves
to `undefined`. `firebase.initializeApp(...)` then throws:

  TypeError: Cannot read properties of undefined (reading 'initializeApp')

crashing startup whenever the Firebase file strategy is configured
(`fileStrategy: firebase` or a granular `fileStrategies` entry).

Switch to the idiomatic modular named import (`initializeApp`) and use
the already-imported `FirebaseApp` type for the return annotation.
This commit is contained in:
Jaka Centa 2026-07-01 14:20:40 +02:00 committed by GitHub
parent 6576688f1b
commit 68bb533083
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
import firebase from 'firebase/app';
import { initializeApp } from 'firebase/app';
import { getStorage } from 'firebase/storage';
import { logger } from '@librechat/data-schemas';
import type { FirebaseStorage } from 'firebase/storage';
@ -7,7 +7,7 @@ import type { FirebaseApp } from 'firebase/app';
let firebaseInitCount = 0;
let firebaseApp: FirebaseApp | null = null;
export const initializeFirebase = (): firebase.FirebaseApp | null => {
export const initializeFirebase = (): FirebaseApp | null => {
if (firebaseApp) {
return firebaseApp;
}
@ -31,7 +31,7 @@ export const initializeFirebase = (): firebase.FirebaseApp | null => {
return null;
}
firebaseApp = firebase.initializeApp(firebaseConfig);
firebaseApp = initializeApp(firebaseConfig);
logger.info('Firebase CDN initialized');
return firebaseApp;
};