Skip to content

Conversation

@timfish
Copy link
Collaborator

@timfish timfish commented Nov 2, 2025

This PR:

  • Splits the browser build output into separate development and production builds
  • References these two builds in the package.json exports
  • Adds a Rollup plugin to production builds which can strip out code wrapped with development-only magic comments
  • Adds the spotlight integration to the default integrations in development mode only
  • Also adds this plugin for browser bundles

The development build has this code:

image

But production builds have this stripped out:

image

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 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,779 - 8,887 -1%
GET With Sentry 1,214 14% 1,427 -15%
GET With Sentry (error only) 5,674 65% 6,176 -8%
POST Baseline 1,129 - 1,195 -6%
POST With Sentry 437 39% 506 -14%
POST With Sentry (error only) 988 88% 1,068 -7%
MYSQL Baseline 3,157 - 3,336 -5%
MYSQL With Sentry 319 10% 580 -45%
MYSQL With Sentry (error only) 2,523 80% 2,720 -7%

View base workflow run

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.

This looks really promising, thanks Tim!

(I realize this is still in draft so feel free to ignore this review if you're still planning on making changes)

@timfish timfish force-pushed the timfish/build/dev-prod-browser-build branch from 8d0f261 to 92bc9f6 Compare November 3, 2025 12:04
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.64 kB +0.03% +6 B 🔺
@sentry/browser - with treeshaking flags 23.13 kB +0.04% +8 B 🔺
@sentry/browser (incl. Tracing) 41.27 kB +0.01% +4 B 🔺
@sentry/browser (incl. Tracing, Profiling) 45.55 kB +0.02% +8 B 🔺
@sentry/browser (incl. Tracing, Replay) 79.75 kB +0.01% +5 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 69.43 kB +0.01% +6 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 84.44 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 96.61 kB +0.01% +6 B 🔺
@sentry/browser (incl. Feedback) 41.32 kB +0.02% +7 B 🔺
@sentry/browser (incl. sendFeedback) 29.32 kB +0.03% +7 B 🔺
@sentry/browser (incl. FeedbackAsync) 34.24 kB +0.02% +5 B 🔺
@sentry/react 26.32 kB -0.02% -5 B 🔽
@sentry/react (incl. Tracing) 43.22 kB -0.06% -24 B 🔽
@sentry/vue 29.14 kB +0.03% +7 B 🔺
@sentry/vue (incl. Tracing) 43.05 kB +0.01% +4 B 🔺
@sentry/svelte 24.65 kB +0.03% +5 B 🔺
CDN Bundle 26.91 kB +0.03% +8 B 🔺
CDN Bundle (incl. Tracing) 41.8 kB +0.01% +2 B 🔺
CDN Bundle (incl. Tracing, Replay) 78.32 kB +0.01% +3 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 83.8 kB +0.01% +1 B 🔺
CDN Bundle - uncompressed 78.91 kB +0.02% +14 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 124.02 kB +0.02% +14 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 240.06 kB +0.01% +14 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 252.82 kB +0.01% +14 B 🔺
@sentry/nextjs (client) 45.37 kB +0.02% +6 B 🔺
@sentry/sveltekit (client) 41.67 kB +0.01% +3 B 🔺
@sentry/node-core 50.81 kB - -
@sentry/node 157.88 kB - -
@sentry/node - without tracing 92.69 kB - -
@sentry/aws-serverless 106.42 kB - -

View base workflow run

@timfish timfish force-pushed the timfish/build/dev-prod-browser-build branch from 41be108 to eb515c4 Compare November 3, 2025 13:02
@timfish
Copy link
Collaborator Author

timfish commented Nov 3, 2025

Needs some tests to confirm Spotlight actually works in dev mode...

@timfish timfish marked this pull request as ready for review November 3, 2025 13:28
options.defaultIntegrations == null ? getDefaultIntegrations(options) : options.defaultIntegrations;

/* rollup-include-development-only */
if (options.spotlight) {
Copy link
Member

Choose a reason for hiding this comment

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

How hard would it be to fill this value from the env variables? I'm okay with trying all variants like PUBLIC_SENTRY_SPOTLIGHT or VITE_SENTRY_SPOTLIGHT etc.

Happy to do this in a follow up too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah probably best in a follow up PR. If we can keep it between the magic comments it'll all get striped out!

import { globalHandlersIntegration } from './integrations/globalhandlers';
import { httpContextIntegration } from './integrations/httpcontext';
import { linkedErrorsIntegration } from './integrations/linkederrors';
import { spotlightBrowserIntegration } from './integrations/spotlight';
Copy link

Choose a reason for hiding this comment

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

Bug: Development-only import leaked into production bundle

The spotlightBrowserIntegration import is not wrapped in the development-only magic comments, but its usage is. This means the spotlight integration module will be bundled into production builds even though it's only used in development mode (lines 97-105). The import should be wrapped in /* rollup-include-development-only */ and /* rollup-include-development-only-end */ comments to ensure it's tree-shaken from production builds, reducing bundle size.

Fix in Cursor Fix in Web

Copy link
Collaborator Author

@timfish timfish Nov 6, 2025

Choose a reason for hiding this comment

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

Any sort of bundling will remove this, it's just an unused import...

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.

4 participants