警告“看起来您正在使用 Firebase JS SDK 的开发版本"在 Angular Firebase 应用程序中 [英] Warning "It looks like you're using the development build of the Firebase JS SDK" in Angular firebase app

查看:20
本文介绍了警告“看起来您正在使用 Firebase JS SDK 的开发版本"在 Angular Firebase 应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 angular 项目中使用了 angular fire sdk.但它会触发以下警告.我搜索了这个问题并得到了答案.但这些答案不适用于 angular 项目.

您似乎在使用 Firebase JS SDK 的开发版本.将 Firebase 应用部署到生产环境时,建议只导入您打算使用的各个 SDK 组件.对于模块构建,这些可以通过以下方式获得(将 <PACKAGE> 替换为组件的名称 - 即身份验证、数据库等):CommonJS 模块:const firebase = require('firebase/app');require('firebase/');ES模块:从firebase/app"导入 firebase;导入 'firebase/';打字稿:从firebase/app"导入 * 作为 firebase;导入 'firebase/';

我的应用模块如下所示.

从'@angular/fire'导入{AngularFireModule};从@angular/fire/auth"导入 {AngularFireAuthModule};进口:[...AngularFireModule.initializeApp(environment.firebaseConfig),AngularFireAuth 模块,]

我想在我的 angular 项目中停止这个警告.

解决方案

我终于找到了解决方案.

<块引用>

这是导入 firebase 的错误方法

从'firebase'导入{auth};

<块引用>

这是导入 firebase 的正确方法

import * as firebase from 'firebase/app';

I'm using angular fire sdk in my angular project. But it trigger following warning. I searched about this problem and get answers. But those answers cannot apply to angular project.

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):

CommonJS Modules:
const firebase = require('firebase/app');
require('firebase/<PACKAGE>');

ES Modules:
import firebase from 'firebase/app';
import 'firebase/<PACKAGE>';

Typescript:
import * as firebase from 'firebase/app';
import 'firebase/<PACKAGE>';

My app module looks like this.

import {AngularFireModule} from '@angular/fire';
import {AngularFireAuthModule} from '@angular/fire/auth';

imports:[
   ...
    AngularFireModule.initializeApp(environment.firebaseConfig),
    AngularFireAuthModule,
]

I want to stop this warning in my angular project.

解决方案

Finally i found a solution.

This is Wrong Way to import firebase

import {auth} from 'firebase';

And This is Correct Way to import firebase

import * as firebase from 'firebase/app';

这篇关于警告“看起来您正在使用 Firebase JS SDK 的开发版本"在 Angular Firebase 应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆