-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Angular Fire Firestore not working with Angular Universal v9 (Ivy) due to issue with Firestore UMD generated by ngcc #2280
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
Comments
As a secondary issue which is related, once I hack the Firestore UMD to temporarily fix the issue described above ^^^ (by removing the If
Which I would imagine is because the main server package is using the If
The reason for this is because of this line of code where one of the downstream dependencies is referencing Since the code has been packaged up with the main server build, that path to So, I think one of two fixes clearly have to be made: A) If firestore an external dependency, then have to figure out some way to maintain the same angular core context (not sure how to do that, though) B) If firestore is packaged with the server build, need to update the |
OK, so after a lot of hacking compiled module code, I have Angular Universal + Firestore working for Angular v9 (Ivy). There definitely are some fixes needed here. The hacks I had to make are as follows:
I am not 100% but I believe ultimately this issue comes from this line in the source code: https://github.com/angular/angularfire/blob/master/src/firestore/firestore.ts#L17 You can see the comment about it being there just for Angular 6 support. That firestore import reference isn't used anywhere. So I believe when the UMD module is built during the publishing process, it must result in that extra param in the UMD factory function. It is a hack, but I am pretty sure a super quick fix for this would be to use that
Now, interestingly, if you look at the source for this one: You will see that there is a possibility to set |
@jeffwhelpley, FYI with regards to the See: https://unpkg.com/browse/@firebase/[email protected]/dist/index.node.cjs.js - Line 23213 Regarding the UMD processing there is seems to be a bug as correctly mentioned above, however I didn't need to run NGCC as a postinstall hook as Maybe you can share a repo where your are encountering this issue? PS: This issues is more of an Angular FW thing, rather than Angular Fire. |
Here is a PR for the ngcc side of things: angular/angular#34660 |
Here is a public repo with the issue: https://github.com/jeffwhelpley/ngufire. Follow the instructions in the README to recreate the issue. |
Thanks for spelunking through this! Once we drop ng6 we'll be able to use Typescript versions that support dynamic types, I'm going to start developing v6 off of master today; expect me to drop those soon. Keep an eye out for |
Should be addressed in |
Getting this error in version 10 of angular
|
any update on this issue ? |
@OmarHegazi94 there's no issue here any longer. We're fully compatible with IVY and the latest versions of Angular. |
Uh oh!
There was an error while loading. Please reload this page.
Version info
Angular: 9.0.0-rc.7
Firebase: 7.6.1
AngularFire: 5.3.0-rc.4
Other (e.g. Ionic/Cordova, Node, browser, operating system):
node v12.3.1
How to reproduce these conditions
Try to compile and run an Angular Universal app that has a dependency on
@angular/fire/firestore
. It won't even compile unless you run thengcc
.If you run
ngcc
, though, then you will get an error when you run your server like this:When I look at the UMD that is generated for Firestore by ngcc, I see this at the beginning:
I was debugging this code for awhile to try and figure out what is going on until I realized that the call to the
factory()
function is sending in more input params (9) than there is actually in the function definition (8). he function hasexports,rxjs,operators,fire,core,common,firebase,ɵngcc0
which is 8 params, but here is what the factory is sending in:When you look at the original UMD for Firestore, this starts to make sense because you can see there is an extra param there as well:
You can see here that
require('firebase/firestore')
is at the end of thefactory()
call, but there is no param for that. So, in the original UMD there is no harm because that extra param isn't used. But,ngcc
must be adding an extra param without checking for this.So, I believe at least part of the fix is figuring out why the normal Firestore UMD has that references to
/firebase/firestore
even though it is not being used.Steps to set up and reproduce
package.json
scripts section make sure you have"postinstall": "ngcc"
angular.json
server options section make sure you have"bundleDependencies": true
and addexternalDependencies
there for any native dependenciesSample data and security rules
N/A
Debug output
** Errors in the JavaScript console **
N/A
** Output from
firebase.database().enableLogging(true);
**N/A
** Screenshots **
N/A
Expected behavior
To not error out
Actual behavior
Get errors listed above.
The text was updated successfully, but these errors were encountered: