Skip to content

[@sentry/nextjs] @sentry/cli always bundled in production #3865

Description

@belgattitude

Package + Version

  • @sentry/nextjs - v 6.10.0
  • @sentry/webpack-plugin - v 1.16.0

Version:

6.10.0

Description

Right now the @sentry/webpack-plugin (/ @sentry/cli) is required as regular dep, meaning we can't get rid off it in production.

This makes prod bundle much bigger and lead to

  • Exceeding lambdas limit of 50Mb (in this case the lambda deployment would fail)
  • Lower performance and slow cold start for lambdas (and maybe some 504...)
  • Longer and (non-cacheable) installs (needs to download binary at build)

As an example, see a vercel debug based on an example repo https://github.com/belgattitude/nextjs-monorepo-example

Edit: Try a deploy on vercel and check the log with NEXT_DEBUG_FUNCTION_SIZE=1

00:42:46.970 | Serverless Function's pages: api/graphql-sdl.js, api/hello.js, api/rest/poem.js, api/rest/post.js, api/rest/post/[id].js
-- | --
00:42:46.980 | Large Dependencies Uncompressed size Compressed size
00:42:46.980 | node_modules/.prisma/client 43.4 MB 15.2 MB
00:42:46.980 | node_modules/sharp/vendor 18.4 MB 7.66 MB
00:42:46.980 | node_modules/@sentry/cli 17.9 MB 6.78 MB
00:42:46.980 | node_modules/next/dist 31.9 MB 6.33 MB
00:42:46.980 | node_modules/sass/sass.dart.js 4.09 MB 610 kB
00:42:46.980 | node_modules/@mui/material 1.84 MB 567 kB
00:42:46.981 | node_modules/@prisma/client 1.66 MB 336 kB
00:42:46.981 | node_modules/react-dom/cjs 1.18 MB 289 kB
00:42:46.981 | node_modules/caniuse-lite/data 719 kB 278 kB
00:42:46.981 | node_modules/next/node_modules 740 kB 194 kB
00:42:46.981 | node_modules/micro/node_modules 360 kB 190 kB
00:42:46.981 | node_modules/encoding/node_modules 329 kB 179 kB
00:42:46.981 | node_modules/iconv-lite/encodings 303 kB 172 kB
00:42:46.981 | node_modules/@next/react-dev-overlay 450 kB 131 kB
00:42:46.981 | node_modules/styled-jsx/node_modules 570 kB 110 kB
00:42:46.981 | All dependencies 133 MB 41.4 MB

Fixing

It's not totally clear to me what would be the best to do.

Option 1:

@sentry/nextjs could move @sentry/html-plugin to devDependencies (or peerDeps/optional), but I'm not sure as it's included in nextjs.config.js so maybe need some more work to be sure the plugin is not required for production builds. A proposal here: #3866

Option 2:

@sentry/html-webpack plugin, move @sentry/cli to devDependencie (or peerDeps/optional)... That would be sufficient as the it's actually the one that increase size significantly (17Mb).

Edit

Option 3:

Ditch @sentry/cli in favour of a custom lightweight sourcemap uploader (That would be the more universal solution)

Option 4:

Possible too, add an option to vercel/nft / nextjs to ignore sentry binary... Would solve vercel problem, but then quid of serverless, netlify...

I could provide some P/R's but let me know what would the recommended approach...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions