Skip to content

Commit

Permalink
fix(app): specify hyphenated package name in import advice
Browse files Browse the repository at this point in the history
previously the error message for a missing import specified the
camel-case version of the package name, which is right for the
usage, but not for the import

Fixes #6009 - thanks to @FakhruddinAbdi for noticing it!
  • Loading branch information
mikehardy committed Feb 7, 2022
1 parent a583494 commit 5e898ec
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/app/lib/internal/registry/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,16 @@ function firebaseRootModuleProxy(firebaseNamespace, moduleNamespace) {
return getOrCreateModuleForRoot(moduleNamespace);
}

moduleWithDashes = moduleNamespace
.split(/(?=[A-Z])/)
.join('-')
.toLowerCase();

throw new Error(
[
`You attempted to use 'firebase.${moduleNamespace}' but this module could not be found.`,
'',
`Ensure you have installed and imported the '@react-native-firebase/${moduleNamespace}' package.`,
`Ensure you have installed and imported the '@react-native-firebase/${moduleWithDashes}' package.`,
].join('\r\n'),
);
}
Expand All @@ -215,11 +220,16 @@ export function firebaseAppModuleProxy(app, moduleNamespace) {
return getOrCreateModuleForApp(app, moduleNamespace);
}

moduleWithDashes = moduleNamespace
.split(/(?=[A-Z])/)
.join('-')
.toLowerCase();

throw new Error(
[
`You attempted to use "firebase.app('${app.name}').${moduleNamespace}" but this module could not be found.`,
'',
`Ensure you have installed and imported the '@react-native-firebase/${moduleNamespace}' package.`,
`Ensure you have installed and imported the '@react-native-firebase/${moduleWithDashes}' package.`,
].join('\r\n'),
);
}
Expand Down

0 comments on commit 5e898ec

Please sign in to comment.