Skip to content

Conversation

chargome
Copy link
Member

@chargome chargome commented Sep 15, 2025

This PR extends the experimental useRunAfterProductionCompileHook flag to be used with webpack as well which can save build time as sourcemaps are only uploaded once.

We do this by:

  • Consolidate all logic for generating build-plugin related code into getBuildPluginOptions and getting rid of the separate webpackPluginOptions logic
  • Enabling the after production compile hook also for webpack builds.
  • If we detect that the user has opted into using the hook, we disable all sourcemap-related operations within the bundler plugin (injection, upload, deletion)
  • If the user does not set the flag the bundler plugin behaviour does not change
  • We switch the upload patterns we pass to the CLI to paths when using the cli directly for uploads (the CLI handles traversing the path automatically), as using glob patters led to some missing sourcemaps when testing
  • With this PR we also drastically narrow down which sourcemaps are being uploaded for turbopack builds

Follow up tasks will be to:

  • Enabling this behaviour as default for turbopack
  • Possibly getting rid of adding the serverless path as this does not even exist in Next13
  • Adding some sort of e2e test verifies that errors get actually sourcemapped (?)

Warning: Enabling this might affect build integrity as bundled files are mutated after the build ends.

@chargome chargome self-assigned this Sep 15, 2025
Copy link
Contributor

github-actions bot commented Sep 16, 2025

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,760 - 9,143 -4%
GET With Sentry 1,392 16% 1,394 -0%
GET With Sentry (error only) 6,046 69% 6,056 -0%
POST Baseline 1,202 - 1,199 +0%
POST With Sentry 509 42% 531 -4%
POST With Sentry (error only) 1,061 88% 1,065 -0%
MYSQL Baseline 3,284 - 3,318 -1%
MYSQL With Sentry 460 14% 453 +2%
MYSQL With Sentry (error only) 2,648 81% 2,670 -1%

View base workflow run

Copy link
Contributor

github-actions bot commented Sep 17, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.22 kB - -
@sentry/browser - with treeshaking flags 22.74 kB - -
@sentry/browser (incl. Tracing) 40.26 kB - -
@sentry/browser (incl. Tracing, Replay) 78.63 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.29 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 83.29 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 95.52 kB - -
@sentry/browser (incl. Feedback) 40.94 kB - -
@sentry/browser (incl. sendFeedback) 28.88 kB - -
@sentry/browser (incl. FeedbackAsync) 33.78 kB - -
@sentry/react 25.93 kB - -
@sentry/react (incl. Tracing) 42.26 kB - -
@sentry/vue 28.71 kB - -
@sentry/vue (incl. Tracing) 42.07 kB - -
@sentry/svelte 24.24 kB - -
CDN Bundle 25.75 kB - -
CDN Bundle (incl. Tracing) 40.07 kB - -
CDN Bundle (incl. Tracing, Replay) 76.3 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 81.8 kB - -
CDN Bundle - uncompressed 75.23 kB - -
CDN Bundle (incl. Tracing) - uncompressed 118.65 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 233.78 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 246.54 kB - -
@sentry/nextjs (client) 44.26 kB - -
@sentry/sveltekit (client) 40.69 kB - -
@sentry/node-core 49.96 kB - -
@sentry/node 151.25 kB - -
@sentry/node - without tracing 91.87 kB - -
@sentry/aws-serverless 105.31 kB - -

View base workflow run

@chargome chargome marked this pull request as ready for review September 17, 2025 13:03
@chargome chargome changed the title [WIP] feat(nextjs): Use afterProductionCompile hook for webpack builds feat(nextjs): Use afterProductionCompile hook for webpack builds Sep 17, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some nit comments, but overall looks great! 🚀

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for creating the helper functions. This is much more readable now

@chargome chargome merged commit 9b22c8a into develop Sep 19, 2025
188 checks passed
@chargome chargome deleted the cg-next-webpack-on-build-end branch September 19, 2025 12:02
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

Successfully merging this pull request may close these issues.

3 participants