-
Notifications
You must be signed in to change notification settings - Fork 18
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
Improve bundle size #48
Comments
Hi @DavidRouyer. Thanks for filing this issue. On your latest point, A key issue appears to be that at least 3 copies of our package are being included by the Next.js bundler. Do you think that's normal/unavoidable? If you're only importing |
Thank you for your answer!
Yeah I removed my comment because I was building the project with
I don't know, I'm fairly new to to Next.js and everything is obfuscated, I'm just doing a standard |
I replaced the ✓ 114 modules transformed. |
That's an initially impressive reduction ... but I think it's down to the fact that the These shims are mainly pretty small. The problem is the Somewhat frustratingly, it seems that dead code elimination/tree-shaking is unable to remove quite a long list of unused methods on If you have any other ideas for addressing that, or otherwise shrinking the bundle size, do let me know. By skipping |
I've looked at this a bit more, and not found any easy way to reduce the bundle size that doesn't have drawbacks. If we remove methods from And skipping |
@jawj I was just coming in to report this issue -- glad it is already being discussed. For my specific use-case, I only need to use the Relying on your user's bundlers to do the magic of tree shaking isn't a great strategy IMO. It's better to provide the individual modules yourself if possible (where you can control the bundler). I would love to be able to |
Thanks @nicksrandall. Unfortunately even the But I'll keep the issue open for a bit and see if there's anything we can do here. |
Steps to reproduce
I'm building a project with Next.js, tRPC, Drizzle and Neon as a Postgres database (you can find the source code here: https://github.com/DavidRouyer/customer-service)
The library is used in the following way:
I'm having an issue when deploying my application on Vercel, I'm getting the following message:
The Edge Function "index" size is 1.04 MB and your plan size limit is 1 MB.
I've installed
@next/bundle-analyzer
to investigate the problem with the bundle size on the edge part:As you can see,
@neondatabase/serverless
is bundled multiple times and represents a large part of my bundle:Expected result
Have a smaller bundle size (or maybe a specific entry for edge only?)
Actual result
The bundle size is too big
Environment
Vercel, Edge Runtime
Logs, links
The text was updated successfully, but these errors were encountered: