Skip to content
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

Bundle size / unused JS / Tree shaking? #693

Open
2 tasks done
kaumac opened this issue Nov 18, 2023 · 2 comments
Open
2 tasks done

Bundle size / unused JS / Tree shaking? #693

kaumac opened this issue Nov 18, 2023 · 2 comments

Comments

@kaumac
Copy link

kaumac commented Nov 18, 2023

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

I'm currently optimizing the marketing pages of my application (built with nextjs and supabase).
One of the problems I'm facing is that I'm using createMiddlewareClient on the nextjs middleware to handle the authentication on my app. The problem is that the nextjs middleware is browser based, so the imported modules gets to the bundle fetched by the user.
Importing createMiddlewareClient adds a around ~30kb to the bundle, the problem is that Lighthouse tests indicates that ~23kb of that is unused.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. import { createMiddlewareClient } from '@supabase/auth-helpers-nextjs' on nextjs middleware.
  2. Deploy application and analyze the generated bundle
  3. Supabase code will be fetched by users when visiting pages that are affected by the middleware.
  4. A lot of code is not used.

Expected behavior

I'm not really sure if the supabase code is tree shaken. Ideally unused code should not get to the js bundle

@kaumac kaumac added the bug Something isn't working label Nov 18, 2023
@silentworks silentworks removed the bug Something isn't working label Nov 19, 2023
@taxsta
Copy link

taxsta commented Nov 28, 2023

Same problem here too. Been trying to figure out how to fix this as supabase has doubled our _app bundle size too.

@chriskrogh
Copy link

chriskrogh commented Apr 13, 2024

same here. I noticed that the docs now recommend using @supabase/ssr over @supabase/auth-helpers-nextjs, but the bundle size of ssr is still pretty hefty (25.92 KB Gzipped on version "^0.3.0")

Screenshot 2024-04-13 at 9 44 06 AM

anyone on the team got any recommendations for tree shaking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants