【发布时间】:2019-09-12 06:00:06
【问题描述】:
我正在构建一个 Angular 网络应用程序,并且我正在像这样导入:
import * as firebase from 'firebase';
db = firebase.firestore();
但最近我不断收到此错误:
It looks like you're using the development build of the Firebase JS SDK.
When deploying Firebase apps to production, it is advisable to only import the
individual SDK components you intend to use.
For the module builds, these are available in the following manner
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):
Typescript:
import * as firebase from 'firebase/app';
import 'firebase/<PACKAGE>';
所以,很自然地,我把它改成了这样:
import * as firebase from 'firebase/app';
import 'firebase/firestore';
db = firebase.firestore();
但错误并没有消失。我不明白如何删除它?
【问题讨论】:
-
修改第一行从'firebase/app'导入firebase;
-
为什么不直接使用 @angular/fire 之类的东西来处理导入和初始化以及高级订阅?
-
当我执行
import firebase from 'firebase/app';时,我收到 tslint 错误Module '"c:/myApp/node_modules/firebase/index"' has no default export -
@AlexanderStaroselsky @angular/fire 没有一些必要的实用程序,例如获取服务器时间戳。
-
我无法评论 @angular/fire 中的每个特定功能,但您肯定会创建 firebase 服务器时间戳。我个人在@angular/fire 项目中做过。无论哪种方式,编码愉快。
标签: angular typescript firebase import google-cloud-firestore