I'm a bit confused trying to use geofire-common in browser code.
In the beginning, I've made a successful attempt with NodeJS which uses geofire-common
referenced here in the Google documentation and which code looks like this:
import { createRequire } from 'module'; // <------ trick to get a require function
const require = createRequire(import.meta.url);
const { initializeApp, cert } = require('firebase-admin/app');
const { getFirestore } = require('firebase-admin/firestore');
const serviceAccount = require('./serviceAccountKey.json');
initializeApp({
credential: cert(serviceAccount),
});
const db = getFirestore();
const geofire = require('geofire-common'); //<---------- geofire-common
Then, I wanted to make this work from the browser side... and I stumbled uponthis example. In this example, I can see a 'require' function so I guess it has something to do with old school commonJS module:
const geofire = require('geofire-common');
Require
is not part of the standard JavaScript API and should be NodeJS specific (which is a bit strange because i thought the example was browser code), so I've tried to use an ES6 import..
import {geofire} from 'geofire-common';
... without success :
The requested module '/node_modules/.vite/geofire-common.js?v=738ba8db' does not provide an export named 'geofire'
If some of the JS experts around would be willing to shed some light about those 2 packages and help me to correctly import geofire
if it's possible, that would be much appreciated.