fix: Add "react-native" entry point to @firebase/app #9112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theexports["."].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.