Open mapringg opened 3 years ago
I threw this together and it may be a start. I was able to connect to v9!
import { initializeApp, getApp } from 'firebase/app';
import { getAuth } from 'firebase/auth';
import { getFirestore } from 'firebase/firestore';
import { getFunctions } from 'firebase/functions';
import { getStorage } from 'firebase/storage';
const firebaseConfig = {
// your fb config, apiKey: "123..."
};
export const fbConfig = initializeApp(firebaseConfig);
type Config = typeof fbConfig;
const auth = getAuth(getApp());
const db = getFirestore(getApp());
const functions = getFunctions(getApp());
const storage = getStorage(getApp());
export class Fuego {
public db: typeof db;
public auth: typeof auth;
public functions: typeof functions;
public storage: typeof storage;
constructor(config: Config) {
this.db = !fbConfig ? db : db; // this is probably pointless
this.auth = auth;
this.functions = functions;
this.storage = storage;
}
}
Unfortunately, there are more modifications to be made on the hooks files (see errors below) since everything has changed from v8 -> v9 - I'll try to dig around on this
My current project is using vite + preact + typescript - I wrote my own hooks for v9 recently - just straight FB, but I was using Fuego before on another project and I really want to see it continue.
I threw this together and it may be a start. I was able to connect to v9!
import { initializeApp, getApp } from 'firebase/app'; import { getAuth } from 'firebase/auth'; import { getFirestore } from 'firebase/firestore'; import { getFunctions } from 'firebase/functions'; import { getStorage } from 'firebase/storage'; const firebaseConfig = { // your fb config, apiKey: "123..." }; export const fbConfig = initializeApp(firebaseConfig); type Config = typeof fbConfig; const auth = getAuth(getApp()); const db = getFirestore(getApp()); const functions = getFunctions(getApp()); const storage = getStorage(getApp()); export class Fuego { public db: typeof db; public auth: typeof auth; public functions: typeof functions; public storage: typeof storage; constructor(config: Config) { this.db = !fbConfig ? db : db; // this is probably pointless this.auth = auth; this.functions = functions; this.storage = storage; } }
Unfortunately, there are more modifications to be made on the hooks files (see errors below) since everything has changed from v8 -> v9 - I'll try to dig around on this
My current project is using vite + preact + typescript - I wrote my own hooks for v9 recently - just straight FB, but I was using Fuego before on another project and I really want to see it continue.
This would defeat the purpose of v9's optimizations, I think, since you're calling the functions at the root. A rewrite would be needed such that getAuth() etc is called at the time it's used within a function
@lemasc I looked through your repo. I don't have time to test at the moment, but at first glance, it all looks good!
Congrats on your first contribution - I know it can be intimidating.
If someone else wants to look at / test that, feel free. You can also direct attention to it on my "Help Wanted" issue.
@nandorojo Thanks! I think I will create a PR so that it might be easier to track any changes.
The current firebase sdk has a large bundle size. The upcoming v9 version seems to solve this problem. I have tried implementing it with swr-firestore, but there are too many changes.
Firebase Modular