-
Notifications
You must be signed in to change notification settings - Fork 73
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
Replace util with something smaller #361
Comments
It's weird that there's no mention of this in the documentation. This is going to be a serious issue going forward for people using Fauna on the front end. Most popular toolchains/scaffolding CLIs (eg: Create React App) are still using Webpack 4, but this is going to change in the coming months. It's also broken when using Rollup which is the default bundler when using Svelte. The solution for Rollup is using the
Also, all the polyfills needed to make the driver work on the browser are adding substantial weight. My current front end app with nothing but the Fauna driver and the polyfills is already weighting 131kB minified which is unacceptable. |
Apologies for the delay in responding to this. Someone will take a look and respond soon. |
I've tried importing using a script tag to see if it made any difference. When using:
The driver weights 178kB mininified and 48kB gzip which is quite heavy. Using a script tag certainly makes things easier for beginners but it is completely out of place in modern front end development. |
Any updates on this? 😁 |
We have more developers starting soon—specifically to help out with the drivers. This is at the top of the list. |
That's good to hear. Thank you! |
@steida @geirmarius Release 4.0.2 adds a module you asked |
@parkhomenko is there any effort going on to reduce the driver for the browser? The latest version has actually increased in size and now weights 185kB minified. |
faunadb still depends on I also fully agree with @PierBover and I would never ship fauandb in production with the current bundle size. It's way too big. Edit: Very thankful for the issue being worked on tho 😄🎉 |
Thank you for your answers, guys 😎 I'll discuss that with my team |
Here is PR #395 that reduce bundle size to about 70kb in the minified version |
Just tried it now. This is a massive improvement! 🎉 Seems to work without any hiccups in my projects 😄 If I may ask, what prevents the driver from being even 10x smaller than this again (7kb)? Seemingly the driver takes FQL and translates it into JSON, and surely that alone doesn't take 70kb of minified code? |
@geirmarius It could be even smaller with this proposal #270 |
Thanks @fireridlle this is awesome! Hopefully it will decrease even more though. Is polyfilling Node modules still necessary for the client? |
Unfortunately yes. For example, some browsers don't support fetch https://caniuse.com/?search=fetch. As we don't know at which browser/environment faunadb-js would run, we try to support as much as possible. We have more ideas on how to reduce bundle size, going to prioritize it soon |
@fireridlle For IE11 you can use /~https://github.com/developit/unfetch, it's super small, but I don't think IE11 should be supported. |
Just a small note, the version with a decreased bundle size is released now, the version is 4.0.3 |
It's good practice to not include any polyfills either way. You'll end up with several libraries polyfilling the same things and a bunch of unused code shipped to the client. Let the users add the polyfills. On top of that, if you don't even need polyfills to begin with because you target only newer browsers, that would make it even lighter. 😄 |
I agree with @steida and @geirmarius. The driver should not include a In any case, @fireridlle you should at least include a note in the docs of the driver mentioning this. As I wrote before, Webpack 5 and Rollup do not include NodeJS polyfills by default like Webpack 4 does. When |
Fauna DB driver uses
require('util')
for very-old-way inheritance. It was poly-filled with Webpack 4 and it's not with Webpack 5. The recommended fix from Webpack 5 adds 7kb gzipped.JFYI, this is my next.config.js for Webpack 5.
Note
// fix faunadb
.Fauna lib should provide browser and node versions so the users should not be forced to manually fix it.
Fauna lib should also be written in TypeScript and all queries should be tree-shakeable, but you probably are well aware of that.
The text was updated successfully, but these errors were encountered: