Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are there any plans to integrate with firebase v9? #109

Open
mapringg opened this issue Apr 5, 2021 · 4 comments
Open

Are there any plans to integrate with firebase v9? #109

mapringg opened this issue Apr 5, 2021 · 4 comments

Comments

@mapringg
Copy link

mapringg commented Apr 5, 2021

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

@nandorojo nandorojo mentioned this issue May 9, 2021
4 tasks
@erictherobot
Copy link

I threw this together and it may be a start. I was able to connect to v9!

Screen Shot 2021-05-29 at 12 21 46 PM

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

Screen Shot 2021-05-29 at 12 23 10 PM

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.

@nandorojo
Copy link
Owner

I threw this together and it may be a start. I was able to connect to v9!

Screen Shot 2021-05-29 at 12 21 46 PM
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

Screen Shot 2021-05-29 at 12 23 10 PM

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

@nandorojo
Copy link
Owner

nandorojo commented Jun 9, 2021

@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.

See: #117

@lemasc
Copy link

lemasc commented Jun 9, 2021

@nandorojo Thanks! I think I will create a PR so that it might be easier to track any changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants