Skip to content
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

import firebase error #930

Closed
sakulstra opened this issue Jan 30, 2017 · 7 comments
Closed

import firebase error #930

sakulstra opened this issue Jan 30, 2017 · 7 comments

Comments

@sakulstra
Copy link
Contributor

Hello,
I the firebase docs there's a section about reducing bundle size by only importing/requiring the parts that you need e.g.:

const firebase = require('firebase/app');
require('firebase/auth');

which works perfectly fine on e.g. create-react-app.
On next.js i get an
{ [Error: The XMLHttpRequest compatibility library was not found.] code: 'auth/internal-error', message: 'The XMLHttpRequest compatibility library was not found.' } error

Someone has an idea where this comes from?
I assume it has sth to do with not using webpack on the server-side and so running in some ssr issues?

Using

const firebase = require('firebase');

on the other hand works perfectly fine.

@Ehesp
Copy link
Contributor

Ehesp commented Jan 30, 2017

What firebase action are you trying to do? Or is this error thrown when trying to initilize the app?

@sakulstra
Copy link
Contributor Author

@Ehesp i only initialize the app, but even if i comment it out it seems like adding the two require lines above is enough to let the server crash.

@arunoda
Copy link
Contributor

arunoda commented Jan 30, 2017

@sakulstra I guess that's an issue.
May be you could try to mock the Node.js environment with the our custom server API and try to add what firebase is looking for.

Since firebase is not open source, that can be quite tricky. May be we could try to read the source code at node_modules

@timneutkens
Copy link
Member

Could you try const firebase = require('firebase') as stated here https://firebase.google.com/docs/web/setup that's the way to call on the node.js side of things. I'm not sure if it will run in a browser. But with dynamic imports coming 🔜 that could be resolved.

@sakulstra
Copy link
Contributor Author

@timneutkens this will most properly work as it's basically equivalent to:
import firebase from 'firebase' which also works, but like your require approach this increases build size a lot (with unnecessary things like messaging and database if you e.g. only need auth).

@arunoda i'll try to figure things out, but my hopes are low as it's not important enough to waste a lot of time with this :)

@Ehesp
Copy link
Contributor

Ehesp commented Jan 30, 2017

@sakulstra I do the general import, also does't work with specific importing.

On a side note with Firebase, just remember you can't do authentication with the client SDK on the server, or anything which requires user specific requests.

@elrumordelaluz
Copy link
Contributor

Same problem here, only solution using a general import (with unnecessary services in the final bundle) 🙁

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants