I'm migrating a simple html / javascript project from firebase realtime database to cloud firestore. I've followed the quickstart and added the library for firebase-firestore - but when I try to initialise the firestore I get 'Uncaught TypeError: firebase.firestore is not a function'. The quickstart mentions:
const firebase = require("firebase");
// Required for side-effects
require("firebase/firestore");
.. but I think that's only if I'm using npn to get the libraries, and doesn't apply?
What am I missing?
index.html
<head>
<script src="https://www.gstatic.com/firebasejs/4.5.1/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.5.1/firebase-firestore.js"></script>
<script src="./app.js" type="text/javascript"></script>
app.js
(function()
{var config = {
apiKey: "...",
authDomain: "...",
databaseURL: "...",
projectId: "...",
storageBucket: "...",
messagingSenderId: "..."
};
firebase.initializeApp(config);
var oldDB = firebase.database(); <-- THIS WORKS
// Initialize Cloud Firestore through Firebase
var newDB = firebase.firestore(); <-- 'Uncaught TypeError: firebase.firestore is not a function'