From 4c3c14cc617202a36a879c84aae3a155c4796899 Mon Sep 17 00:00:00 2001 From: Feiyang1 Date: Tue, 2 Oct 2018 13:11:56 -0700 Subject: [PATCH 1/4] update documentation to show the correct import syntax --- packages/firebase/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firebase/README.md b/packages/firebase/README.md index f6ab8d89a84..1d258cb87a6 100644 --- a/packages/firebase/README.md +++ b/packages/firebase/README.md @@ -83,7 +83,7 @@ var app = firebase.initializeApp({ ... }); If you are using ES6 imports or TypeScript: ``` -import firebase from 'firebase'; +import * as firebase from 'firebase'; var app = firebase.initializeApp({ ... }); ``` From 4d7d8d0fd448703188b7fc06779790ee62f8829c Mon Sep 17 00:00:00 2001 From: Feiyang1 Date: Tue, 2 Oct 2018 14:33:40 -0700 Subject: [PATCH 2/4] update import syntax for firebase/app --- packages/firebase/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firebase/README.md b/packages/firebase/README.md index 1d258cb87a6..6d1501050e0 100644 --- a/packages/firebase/README.md +++ b/packages/firebase/README.md @@ -138,7 +138,7 @@ services you use: ``` // This import loads the firebase namespace along with all its type information. -import firebase from 'firebase/app'; +import * as firebase from 'firebase/app'; // These imports load individual services into the firebase namespace. import 'firebase/auth'; From f85c8809a69ca4bdaaf692f45459f43baec48cd9 Mon Sep 17 00:00:00 2001 From: Feiyang1 Date: Tue, 2 Oct 2018 16:09:42 -0700 Subject: [PATCH 3/4] add example for native es6 module in node --- packages/firebase/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/firebase/README.md b/packages/firebase/README.md index 6d1501050e0..e4a94391d0d 100644 --- a/packages/firebase/README.md +++ b/packages/firebase/README.md @@ -173,6 +173,19 @@ var app = firebase.initializeApp({ ... }); // ... ``` +If you are using native ES6 module with --experimental-modules flag, you should do: +``` +// This import loads the firebase namespace. +import firebase from 'firebase/app'; + +// These imports load individual services into the firebase namespace. +import 'firebase/auth'; +import 'firebase/database'; +``` + +_Known issue for typescript users with --experimental-modules: you have to set allowSyntheticDefaultImports to true in tsconfig.json to pass the type check. Use it with caution since it makes the assumption that all modules have a default export, which might not be the case for the other dependencies you have. And Your code will break if you try to import the default export from a module that doesn't have default export._ + + Firebase Storage is not included in the server side Firebase npm module. Instead, you can use the [`google-cloud` Node.js client](https://github.com/GoogleCloudPlatform/google-cloud-node). From 232062e854cd8b58febc703e81abe012a9cca7f8 Mon Sep 17 00:00:00 2001 From: Feiyang1 Date: Wed, 3 Oct 2018 14:16:27 -0700 Subject: [PATCH 4/4] update warning message to use the correct syntax for typescript --- packages/firebase/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/firebase/src/index.ts b/packages/firebase/src/index.ts index cbd360fe4e8..85449fe3de9 100644 --- a/packages/firebase/src/index.ts +++ b/packages/firebase/src/index.ts @@ -29,6 +29,10 @@ require('firebase/'); ES Modules: import firebase from 'firebase/app'; import 'firebase/'; + +Typescript: +import * as firebase from 'firebase/app'; +import 'firebase/'; `); import firebase from '../app';