IjzerenHein / firestorter

Use Google Firestore in React with zero effort, using MobX 🤘
http://firestorter.com
MIT License
378 stars 50 forks source link

Preserve property read side effects during tree shaking #180

Closed ghatchue closed 1 year ago

ghatchue commented 1 year ago

Preserve property read side effects during tree shaking.

With default tsdx settings, tree shaking assumes that there will be no side effects for object reads. This currently breaks firestorter functionality when the sync mode is set to 'Auto', which is the recommended setting. Specifically, the following lines are removed from the compiled js:

You can inspect firestorter.cjs.development.js to see it clearly.

This implies that observing (via mobx) these getters (i.e. isLoaded) will not have the intended effect of tracking that observable reference, and fetching data from the Firestore collection.

IjzerenHein commented 1 year ago

Wow, great find!!!

I will push this out immediately and see how we can solve this integrally so other bundlers also don't run into this into the future.

Thanks so much @ghatchue ❤️ 🙏