frontegg / frontegg-nextjs

MIT License
7 stars 3 forks source link

[BUG] Slim down enormous bundle size of required dependencies #62

Open mcmxcdev opened 2 years ago

mcmxcdev commented 2 years ago

Describe the bug

@frontegg/nextjs depends on @frontegg/admin-portal and @frontegg/redux-store (which is required by @frontegg/react-hooks) libraries, which are both huge in size.

When using @next/bundle-analyzer, these are the findings:

These sizes are unacceptable in modern web development and should be brought down as much as possible. This bloat is bad for users with metered internet connections, slows down builds and can be avoided.

Expected behavior Bring down the bundle size of frontegg libraries to an acceptable level.

Screenshots

Screenshot from 2022-09-06 15-41-57

mcmxcdev commented 2 years ago

As a side note, we don't even use @frontegg/admin-portal at all in our application. I expect it to be tree-shaked away and not blow up the bundle.

rotemzif1 commented 2 years ago

Hey, @mcmxcdev this should be done if you upgrade to the latest version.

mcmxcdev commented 1 year ago

Meanwhile, we are using @frontegg/nextjs v6.7.4 and although things have improved a lot, @frontegg/nextjs is still the 2nd largest dependency right after next:

https://user-images.githubusercontent.com/16797721/204533008-5c9acffa-30e6-40bc-8e43-abaf6a1ed8aa.mp4

janikga commented 7 months ago

I want to extend on this. Recently, we have been investigating our next.js bundle size and discovered that @frontegg/nestjs blows up our individual pages WAY out of proportion.

Our first load JS baseline is around 83 kB; with a simple Frontegg import (e.g., the useAuthUserOrNull hook), the size blows up to almost 450 kB (437 kB first load JS)[using the bundle analyzer].

Screenshot 2024-02-23 at 17 23 06

Especially the size of https://www.npmjs.com/package/@frontegg/redux-store seems to be quite horrible (600kB parsed size on the server, 330kB parsed size on the client)

Screenshot 2024-02-23 at 17 26 39 Screenshot 2024-02-23 at 17 26 57

Are there any plans to reduce the size of https://www.npmjs.com/package/@frontegg/redux-store? The npm page also lists the unpacked size as 2.2 MB, which is insane.

As a paying customer, it would be great to see some improvements soon. Otherwise, we might consider switching to a product offering acceptable bundle sizes.

Thanks for your help!