Trouble bundling Firestore for Universal (ENOENT / app.firestore not a function)
See original GitHub issueVersion info
Angular: 10@latest & 11@latest - same result
Firebase: 8.1.1
AngularFire: 6.1.1
Node: 12
Was all working fine on Firebase with SSR setup following the angularfire Guide.
We upgraded Firebase JS SDK and in order to get SSR working again, we had to remove the following from angular.json
:
"externalDependencies": [
"@firebase/firestore"
]
Hence the error TypeError: app.firestore is not a function
disappeared and SSR was working again, except on a sub-page that actually tries to load from data from firestore. When rendering this through SSR, we got the error:
Unhandled Promise rejection: ENOENT: no such file or directory, open '/workspace/dist/carchecker-ui/server/src/protos/google/firestore/v1/firestore.proto'
Expected behavior
Get SSR working with Firestore.
Actual behavior
I can choose a halfway working SSR solution by removing externalDependencies
in angular.json
(server) that seems to render some of the pages or breaking with missing Proto-Buffer stuff.
Or break SSR entirely with the TypeError: app.firestore is not a function
when having @firebase/firestore
in externalDependencies
in angular.json
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:9 (4 by maintainers)
When i add this to externalDependencies
"externalDependencies": [ "@firebase/app", "@firebase/firestore" ]
I no longer receive any errors, neither firestore.proto nor app.firestore is not a function I don’t know if this will help you.Checkout what I’ve done in my sample app to support this https://github.com/angular/angularfire/blob/master/sample/server.ts#L18. I used
dir-loader
to include the protos into the server build as a quick hack.I’m considering what an official happy path here with the schematic might look like.