5

我正在构建一个 Angular Web 应用程序,我正在像这样导入:

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();

但错误并没有消失。不明白怎么去掉?

4

1 回答 1

3

背景

仅当您像在第一个代码片段中一样加载所有 firebase 模块时,才会触发该警告消息。最好只使用裸导入,就像您将其更改为:

import * as firebase from 'firebase/app';
import 'firebase/firestore';

这仅导入firestore模块。

解决方案

在您更改的任何文件中搜索您的导入from 'firebase'。甚至像import {firestore} from 'firebase';这样的代码也会触发警告消息。

于 2019-12-29T08:30:38.020 回答