Skip to content

Firebase Auth tree shaking #1459

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

Closed
harwoodspike opened this issue Nov 9, 2023 · 3 comments
Closed

Firebase Auth tree shaking #1459

harwoodspike opened this issue Nov 9, 2023 · 3 comments
Assignees
Labels

Comments

@harwoodspike
Copy link

What problem is this solving

The current VueFire uses getAuth in the authentication module, but according to https://firebase.google.com/docs/auth/web/custom-dependencies that imports all of the authentication module and doesn't remove anything in the tree shaking process.

So I am trying to solve the tree shaking issue while adding more flexibility.

Proposed solution

I propose that we add the ability to optionally pass the Auth object into VueFire.

In my project I build the Auth object using initializeAuth which should properly tree shake. It would be awesome to pass that into VueFire so that VueFire doesn't use getAuth which in turn should allow proper tree shaking.

Describe alternatives you've considered

No response

Copy link
Member

posva commented Nov 9, 2023

I wasn’t aware of this issue. It should be doable without breaking changes I believe

@posva posva self-assigned this Dec 1, 2023
@posva posva added bug and removed feature request labels Dec 1, 2023 — with Volta.net
@posva posva closed this as completed in 7d94183 Dec 1, 2023
@harwoodspike
Copy link
Author

@posva Thanks for the ability to customize the Auth dependencies.

I would like to know if it would be possible to add a VueFireAuth module that accepts the Auth instance like:

export function VueFireAuthFromAuth({
  auth,
  initialUser,
}: VueFireAuthOptions): VueFireModule {
  return (firebaseApp: FirebaseApp, app: App) => {
    const [user, initAuth] = _VueFireAuthInit(
      firebaseApp,
      app,
      initialUser,
      undefined,
      auth
    )
    setupOnAuthStateChanged(user, initAuth)
  }
}

I propose this as I am using Vuefire without ssr or nuxt and would like to use Firebase emulators but I am unable to get the Auth instance from Vuefire outside of injectable context.

I configure all my Firebase configs in a files outside of Vue so it doesn't have injectable context.

@posva
Copy link
Member

posva commented Dec 15, 2023

Sure. I added d5d5e1b. I think I should have gone for that solution rather than passing the dependencies. Hopefully I will publish a new version soon

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

No branches or pull requests

2 participants