Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ type Server = typeof import('./angular/index.js') |
import type { Request } from 'firebase-functions/v2/https';
import type { Response } from 'express';

import { isUsingFirebaseJsSdk } from './utils.js'

const dirname = process.env.__FIREBASE_FRAMEWORKS_ENTRY__;
const usingFirebaseJsSdk = !!process.env.__FIREBASE_DEFAULTS__;
const usingFirebaseJsSdk = await isUsingFirebaseJsSdk();
const basename = usingFirebaseJsSdk ? 'firebase-aware' : 'index';

// .env isn't parsed for Cloud Functions discovery during deploy, handle undefined
Expand Down
11 changes: 11 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export async function isUsingFirebaseJsSdk() {
if(!process.env.__FIREBASE_DEFAULTS__) return false;

try {
await import('firebase/app');

return true
} catch (e) {
return false;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: line break at end of files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, there's no prettier config in this repo though, we should add it, probably use the same config as the CLI