Background
I have a Next.js app on Cloudflare Pages (aka Workers). When I tried deploying the app, then I started receiving errors on Cloudflare pages mentioning "You have exceeded the Paid plan's max. bundle size (10 mb gzipped)".
Issue
I started analysing the bundle. The conclusion is when I wrap the nextConfig with withSentryConfig, the app's bundle size increases by 400% (5mb -> 25mb) which are mostly edge functions. On average, **each **edge function's size increased by 1.4mb (from 0.1mb->1.5mb).
My attempt
1
Implemented the recommended "Tree Shaking With Next.js" web pack config at https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/tree-shaking/#tree-shaking-with-nextjs. Decreased the bundle size from 25.6mb -> 25.5mb.
2
I removed all 3 sentry.*.config.ts and instrumentation.ts files. Decreased the bundle size from 25.5mb -> 24.3mb.
3
I removed the withSentryConfig from next.config.mjs. Decreased the bundle size from 24.3mb -> 4.5mb.
**Q1: **Has anyone come across the same issue, and managed to solve it?
Q2: What are my options to decrease the bundle size?