-
Notifications
You must be signed in to change notification settings - Fork 903
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
Error while serving universal app #1797
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Take a look at this reply here: #1754 (comment) The problem seems to be that your bundler is pulling in an esm build which is meant for browser use and not Node, because of the issues outlined in that comment. That reply contains a workaround you can use while waiting for a potential future fix in @angular/fire. |
hi @hsubox76 the referred comments has fixed warning only. But the error of IDBIndex |
@tarunm007: I reproduced the original bug using the tutorial @itsmeneartou linked, and changing the |
Hi @hsubox76 @Feiyang1
While running
Let me know if you need any more info |
Also experiencing this issue even after following @Feiyang1 suggested solution. |
Code that is throwing the error in server.js is "module.exports = webpack_require(405);" // "firebase": module.exports = webpack_require(405); /***/ }), // "firebase/app": module.exports = webpack_require(420); /***/ }), // "firebase/auth": |
@tarunm007 Thanks so much for the repro. It was really helpful. So the basic problem for you and I think for everyone facing In your repo, you import firebase differently in different files. In In So when applying the fix @Feiyang1 suggested in
You'll notice the alias only applies to any time you try to import from
I would probably pick one or the other, but if going with Let's call that Option 1. Option 2 would be to tell Webpack to always pick the bundle specified in the "main" field of a library's
And there's no need to keep track of every file you plan to import and find its path in The downside is that this will apply to all of your dependencies, and other libraries may not have the same convention. They might not specify a Option 3 would be to tell Webpack to not bundle Firebase modules at all, but to directly bring them in with a Node This should ensure all the Firebase packages come in as Node (CommonJS) without breaking your non-Firebase dependencies, as well as any packages the Firebase code itself imports. It can be a little hard to read though. Hope one of those options works for you (and others in this thread)! |
@hsubox76 Thanks a lot. I had understood the problem but didn't got the solution which @Feiyang1 provided. Now I understood the solution also. For my test repo, option1 works very well. However I had used option3 in my project with change in regex to accommodate all the cases:
|
@raberana It's a workaround till we change firebase packaging to disambiguate between nodejs build and browser build for bundlers. We are still investigating what the best way is. And since it's probably going to be a breaking change, we will need to align it with a major release, so it could take some time. No, the linked fix only fix the SSR issue if you only use firebase products that don't have a special nodejs build. If you use firestore which has a different build for Nodejs, you need the workaround mentioned in this thread. |
Hey I'm still experiencing this issue, after trying method 1, 2, and three. After using option 1, packages within the AngularFire directories started to break, as it seemed as though the AngularFire libraries were trying to pull in the node versions of firebase. Then option 2, gave me a /package.json could not be found error, then option three, still does not solve the IDBindex error. I am not even entirely sure how this error still persists. Regular, ng serve, works well. It's only when I am ng serve:ssr, from the ssr build. I am not quite sure what to do, because the workarounds are not working, affecting all 6.x versions. I have also trashed the node_modules and package-lock.json |
For option 3, did you use the regex as is, or did you modify it to include all the Firebase components you are using? IndexedDB is used by more components than just firebase/app and firebase/firestore, including auth, performance, and messaging. If you are using one of those and did not include it in the regex, perhaps that might be causing the error? |
I used this one: const regex = /firebase(/([\w\d]+))*/; |
When I use option three, I get this error message: Error: Cannot find module './firebase.app.module' |
`// Work around for angular/angular-cli#7200 const regex = /firebase(/([\w\d]+))*/; module.exports = {
}], |
I think it may be that your regular expression is too broad and you are excluding your own Angular module (which seems to be named |
Adding the caret, did the trick, I modified the regex to look like this.
const regex = /^firebase(\/([\w\d]+))*/;
… On Jul 18, 2019, at 4:34 PM, Christina Holland ***@***.***> wrote:
I think it may be that your regular expression is too broad and you are excluding your own Angular module (which seems to be named firebase.app.module?) from being compiled. Perhaps you can add a ^ to the beginning of the regex to ensure it only applies if the absolute path begins with firebase, or something else to separate firebase imports from your own files?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#1797?email_source=notifications&email_token=ACBPZGLD5PULCUKGYZDPBC3QADHUPA5CNFSM4HNZQQM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2JWNCQ#issuecomment-512976522>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ACBPZGLVLEJ3UIFKG7SNJ4TQADHUPANCNFSM4HNZQQMQ>.
|
Didnt you got windows error after solving this regex problem |
Although the workaround is working for the moment, because of the two different references, firebase performance does not launch on the @firebase package, this is the error message: FirebaseError: Performance: Performance can only start when Firebase app instance is the default one. (performance/FB not default), what can we do about this? I'd like to use the firebase performance module as well. |
@stot3 Only one The default So to summarize, You need to instantiate |
I had a similar problem using If you are able to use es2017 dynamic import with webpack you can avoid this problem like this:
The firebase library will be avaiable |
Following the excellent instructions by hsubox76 fixes the IDBIndex error in my Electron app, but as soon as I try to do a send to the firestore database, I run into the next error:
Which again looks like it's using a browser API that is not available. |
Which option did you choose? If 1 or 3, you have to expand the list of aliases or the regex, respectively, to include all Firebase components you are using (in this case the list or regex must include |
I used option 1. And I only added an alias for "firebase" since that's the only file I actually import in my code. However, it seemed as if any require from firebase's In the end, I just switched to using firebase from the Electron renderer thread instead, where the esm version works without problems. |
For documentation purposes, here is a thread solving this problem in GatsbyJS: |
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
I followed this tutorial for creating server side rendered app. There were other errors as well before I stumbled upon this error but they already had solutions. This error occurs when I try to serve the app using
npm run serve:ssr
.The error I get is:
Before this I was receiving an error
window is not defined
so I added the below code inserver.ts
as mentioned in one of other issues in @angular/universal package, this commentWhen I build ssr app using
npm run build:ssr
, I receive warnings shown belowAlso when I serve(d) app using
npm run serve:ssr
while I receive these warnings when I usedfirebase@5.x.x
I received errorreference: self is not defined
after updating tofirebase@6.0.2
I receive errorI remove these warnings and errors by updating
webpack.server.config.js
by adding lines belowI also found out this stackoverflow question related to this error but I don't use performance module so solution is not applicable to me.
Steps to reproduce:
IDBIndex
errorHow can I solve this
IDBIndex
error ? Please helpThe text was updated successfully, but these errors were encountered: