You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+23
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,29 @@ See below for details.
23
23
24
24
### Changed
25
25
26
+
-**BREAKING**: Use `lazyfire` for ESM-enabled web environments to make Firebase modules load on demand. It ensures maximum performance, but requires installation of additional dependency and change of application initialization.
27
+
28
+
So, if you're using webpack or another ESM-enabled bundler, install `lazyfire`:
29
+
30
+
```bash
31
+
npm install lazyfire --save
32
+
# Or using Yarn:
33
+
yarn add lazyfire
34
+
```
35
+
36
+
And then change `firebase.initializeApp` to `configureApp`:
37
+
38
+
```diff
39
+
-import * as firebase from 'firebase/app'
40
+
-import 'firebase/firestore'
41
+
+import { configureApp } from 'lazyfire'
42
+
43
+
-firebase.initializeApp({
44
+
+configureApp({
45
+
// Firebase app configuration
46
+
})
47
+
```
48
+
26
49
-**BREAKING**: Make TypeScript 3.8 the minimal supported version.
Copy file name to clipboardExpand all lines: README.md
+30-4
Original file line number
Diff line number
Diff line change
@@ -34,27 +34,53 @@ yarn add typesaurus
34
34
_Note that Typesaurus requires `firebase` package to work in the web environment and `firebase-admin` to work in Node.js. These packages aren't listed as dependencies,
35
35
so that they won't install automatically along with the Typesaurus package._
36
36
37
+
Additionally, when using with ESM-enabled bundler (like webpack), you'll need to install `lazyfire` that enables asynchronous importing of Firebase modules in the web environment:
38
+
39
+
```sh
40
+
npm install lazyfire --save
41
+
# Or using Yarn:
42
+
yarn add lazyfire
43
+
```
44
+
45
+
[Read more about Lazy Fire](https://github.com/kossnocorp/lazyfire).
46
+
37
47
## Configuration
38
48
39
-
Typesaurus does not require additional configuration, however **when using with ESM-enabled bundler, you should transpile `node_modules`**. TypeScript preserves many modern languages features when it compiles to ESM code. So if you have to support older browsers, use Babel to process the dependencies code
49
+
Typesaurus does not require additional configuration, however **when using with ESM-enabled bundler (like webpack), you should transpile `node_modules`**. TypeScript preserves many modern languages features when it compiles to ESM code. So if you have to support older browsers, use Babel to process the dependencies code.
40
50
41
51
## Get started
42
52
43
53
### Initialization
44
54
45
-
To start working with Typesaurus, initialize Firebase normally.
55
+
To start working with Typesaurus, you'll need to initialize Firebase.
46
56
47
-
In the web environment ([see Firebase docs](https://firebase.google.com/docs/web/setup#add-sdks-initialize)):
57
+
#### Web environment
58
+
59
+
In the web environment when using ESM-enabled bundler (like webpack), use [Lazy Fire](https://github.com/kossnocorp/lazyfire) to configure the Firebase application:
60
+
61
+
```ts
62
+
import { configureApp } from'lazyfire'
63
+
64
+
configureApp({
65
+
// Firebase app configuration
66
+
})
67
+
```
68
+
69
+
#### Legacy web environment
70
+
71
+
In the web environment with ESM-disabled ([see Firebase docs](https://firebase.google.com/docs/web/setup#add-sdks-initialize)):
48
72
49
73
```ts
50
74
import*asfirebasefrom'firebase/app'
51
75
import'firebase/firestore'
52
76
53
77
firebase.initializeApp({
54
-
//Project configuration
78
+
//Firebase app configuration
55
79
})
56
80
```
57
81
82
+
#### Node.js environment
83
+
58
84
In Node.js ([see Firebase docs](https://firebase.google.com/docs/admin/setup#initialize-sdk)):
0 commit comments