LoginSignup
27
7

More than 5 years have passed since last update.

[Firebase][JavaScript] プロジェクトにimportする際に警告文が出てくる

Posted at

FirebaseでWebアプリを開発しようと、importした際に
コンソールに以下警告文が出てきました。
スクリーンショット 2018-11-13 12.33.38.png

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>';

解決法

言われたとおり、importの部分を書き換えます。

import firebase from 'firebase'

//...

:point_down:

import firebase from 'firebase/app'
import 'firebase/app'
import 'firebase/firestore' // ここには使用するFirebaseSDKモジュールを記載

//...

こうすると、警告文が消えます!

原因

  • セキュリティの観点から、本番環境では使用するFirebaseSDKだけを選んでimportが推奨されているもよう(問題なく動作はする)。
27
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
7