Skip to content

update documentation to show the correct import syntax #1274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions packages/firebase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var app = firebase.initializeApp({ ... });
If you are using ES6 imports or TypeScript:

```
import firebase from 'firebase';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's another instance (import firebase from 'firebase/app') that should be updated too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! done.

import * as firebase from 'firebase';
var app = firebase.initializeApp({ ... });
```

Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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).
Expand Down
4 changes: 4 additions & 0 deletions packages/firebase/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ require('firebase/<PACKAGE>');
ES Modules:
import firebase from 'firebase/app';
import 'firebase/<PACKAGE>';

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

import firebase from '../app';
Expand Down