jsayol/FireSQL

Check for constructor.name fails on minified production builds

fridstrom opened this issue · 3 comments

On a project which is running fine in development mode, the following error is thrown in the browser when trying to run webpack/minified production build:
Uncaught Error: With options as the second parameter, the first parameter needs to be a path string or a Firestore reference.

I think it fails because the constructor.name "Firestore" is changed in production (to "t" in my case)

The check on line 27 of firesql.ts subsequently fails:
refOrOptions.constructor.name === 'Firestore'

In a vanilla Vue Cli 3 project. This is how I invoke fireSQL:

const firestore = firebase.firestore(); 
export const firesql = new FireSQL(firestore, {includeId: 'id'});

Thanks for the effort you're in to this project!

You're right! Thanks for reporting this.

I'll fix this as soon as I can. In the meantime, as a workaround you can initialize FireSQL just with the options:

export const firesql = new FireSQL({includeId: 'id'});

This will internally use the Firestore instance from the default Firebase app.

Thanks for the workaround! Can confirm production build is running :)
Cheers!

I just published version 1.0.2 fixing this issue. Thanks again for reporting it!