uni-firebase
v0.3.6-native
Published
universal firebase base for firebase-js-sdk v9 compat, firebase-admin, and react-native-firebase
Downloads
32
Readme
uni-firebase
universal firebase base for firebase-js-sdk v9 compat, firebase-admin, and react-native-firebase
Usage
library
import { Firestore, CollectionReference } from 'uni-firebase/firestore'
export const users = (firestore: Firestore) => firestore.collection("users") as CollectionReference<User>
application
import { FieldValue } from 'uni-firebase/firestore'
import { users } from 'library'
const update = (uid: string) => {
users.doc(uid).update({
updated_at: FieldValue.serverTimestamp()
})
}
Hot to install
Browser (firebase-js-sdk v9 compat)
"dependencies": {
"uni-firebase":"[VERSION]-browser"
}
Admin (firebase-admin)
"dependencies": {
"uni-firebase":"[VERSION]-admin"
}
Native (react-native-firebase)
"dependencies": {
"uni-firebase":"[VERSION]-native"
}
Library
Install either environment package in devDependencies
and append peerDependencies
.
"devDependencies": {
"uni-firebase":"[VERSION]-browser"
},
"peerDependencies": {
"uni-firebase":">=[VERSION]"
}
Monorepo
Add the above to the application's package.json for the application and one for the library in the root package.json
Add aliases by
paths
intsconfig.json
application
{ "compilerOptions": { "paths": { "@uni-firebase/*": ["./node_modules/uni-firebase/*"] } } }
library
{ "compilerOptions": { "paths": { "@uni-firebase/*": ["../../node_modules/uni-firebase/*"] } } }
use
tsc-alias
package to replace aliasesuniFirebaseReplacer.js
exports.default = function exampleReplacer({ orig, file, config }) { console.log(orig) const result = orig.replace('@uni-firebase', 'uni-firebase') return result }
package.json
{ "build": "tsc && tsc-alias -r uniFirebaseReplacer.js" }