neondatabase / neondatabase/serverless
Improve bundle size
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 548
- Forks
- 81
- PR merge metrics
- No merged PRs in 30d
Description
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:
import { neon } from '@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-http';
import * as auth from './schema/auth';
import * as contact from './schema/contact';
import * as message from './schema/message';
import * as ticket from './schema/ticket';
export const schema = { ...auth, ...contact, ...message, ...ticket };
export { pgTable as tableCreator } from './schema/_table';
export * from 'drizzle-orm';
export const db = drizzle(neon(process.env.DATABASE_URL!), { schema });
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Vercel Edge Runtime bundle from the linked customer-service project and inspect the @neondatabase/serverless entries with @next/bundle-analyzer. Trace why the package is bundled multiple times, then verify that the Edge Function is below the reported 1 MB limit or that an edge-specific entry point reduces its size.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, postgresql, typescript
- Domain
- cloud, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100