Preact-cli: Cant build with partial importing Firebase modules

Created on 4 Mar 2018  Â·  5Comments  Â·  Source: preactjs/preact-cli


Do you want to request a feature or report a bug?
Bug
What is the current behaviour?
When using preact build the output is:

✖ ERROR Template execution failed: Error: The XMLHttpRequest compatibility library was not found.
✖ ERROR   Error: The XMLHttpRequest compatibility library was not found.

If the current behaviour is a bug, please provide the steps to reproduce.
Use firebase like so:

import firebase from 'firebase/app'
import 'firebase/auth'

const firebaseAuth = firebase.auth();

and preact build

What is the expected behaviour?
It only loads and builds the imported modules.

If this is a feature request, what is motivation or use case for changing the behaviour?
no

Please mention other relevant information.

  • Node version 9.6.1
  • npm version 5.6.0
  • Operating system macOS
  • CLI version 2.1.0
  • Browser Chrome

Most helpful comment

@DennisKo @lukeed I'm having the same problem. Can I have some more info on how to fix this?

This is what I have:

import firebase from 'firebase/app'
import 'firebase/database'
import 'firebase/auth'

const config = { ... }

export default firebase.initializeApp(config)

I'm getting the same error as @DennisKo described in his first comment:

✖ ERROR Template execution failed: Error: The XMLHttpRequest compatibility library was not found.
✖ ERROR   Error: The XMLHttpRequest compatibility library was not found.

I tried using the xmlhttprequest module as mentioned in this comment but it gives me these errors:

✖ ERROR ./node_modules/xmlhttprequest/lib/XMLHttpRequest.js
Module not found: Error: Can't resolve 'child_process'
Module not found: Error: Can't resolve 'fs'

All 5 comments

You need to import from '@firebase/*`. It's foiled me too.

This can be closed. It didnt work with the way I exported firebaseAuth export const firebaseAuth = firebase.auth();. I now just export default firebase and call firebase.auth().*

Edit: @lukeed Its actually working with both imports...

@DennisKo @lukeed I'm having the same problem. Can I have some more info on how to fix this?

This is what I have:

import firebase from 'firebase/app'
import 'firebase/database'
import 'firebase/auth'

const config = { ... }

export default firebase.initializeApp(config)

I'm getting the same error as @DennisKo described in his first comment:

✖ ERROR Template execution failed: Error: The XMLHttpRequest compatibility library was not found.
✖ ERROR   Error: The XMLHttpRequest compatibility library was not found.

I tried using the xmlhttprequest module as mentioned in this comment but it gives me these errors:

✖ ERROR ./node_modules/xmlhttprequest/lib/XMLHttpRequest.js
Module not found: Error: Can't resolve 'child_process'
Module not found: Error: Can't resolve 'fs'

@pepebecker I'm having the same issue.

@pepebecker I used this as the base for my project as this code builds without issues. -> https://github.com/m4r1vs/FireChattr

Was this page helpful?
0 / 5 - 0 ratings