Skip to content

fix: Add "react-native" entry point to @firebase/app #9112

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hsubox76
Copy link
Contributor

Fixes #8988

See expo/expo#36598 (comment) for a user's helpful explanation of the root cause. @firebase/app has no specific "react-native" entry point so metro resolves it using the exports["."].default path in package.json I guess, which is ESM, while the auth and firestore "react-native" bundles are CJS and use "require" statements which cause them to import firebase/app CJS code. This causes two unconnected versions of firestore/app to exist in the developer's app.

This PR follows the suggested fix in the second bullet point, to add a "react-native" entry point to firebase/app which points to the CJS bundle. This fixes the issue in my repro case.

I tested this to see if there is a similar problem with the other product packages that are supported on React Native (ai, functions, database) but don't have a "react-native" entry point, but even if Metro brings in the ESM versions of those packages, they still seem to play nice with (register with) the CJS app bundle, in this configuration. It just seems that CJS product packages can't register with an ESM firebase/app, but the other way around is fine.

@google-oss-bot
Copy link
Contributor

@google-oss-bot
Copy link
Contributor

@hsubox76 hsubox76 marked this pull request as ready for review June 20, 2025 22:51
@hsubox76 hsubox76 requested review from a team as code owners June 20, 2025 22:51
@hsubox76 hsubox76 requested review from DellaBitta and dlarocque June 20, 2025 22:52
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

Successfully merging this pull request may close these issues.

Failed to initialize auth with persistence: [Error: Component auth has not been registered yet]
3 participants