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 so spotlight doesn't get included in CDN bundles

Vite and Webpack will automatically include Spotlight in development/production mode and it is excluded in production. Unfortunately, Rollup will not select development unless you set the exportConditions for @rollup/plugin-node-resolve

@github-actions

This comment was marked as off-topic.

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.6 kB +0.03% +6 B 🔺
@sentry/browser - with treeshaking flags 23.09 kB +0.03% +6 B 🔺
@sentry/browser (incl. Tracing) 41.23 kB +0.01% +4 B 🔺
@sentry/browser (incl. Tracing, Profiling) 45.51 kB +0.02% +7 B 🔺
@sentry/browser (incl. Tracing, Replay) 79.7 kB +0.01% +4 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 69.38 kB +0.01% +6 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 84.4 kB +0.01% +1 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 96.57 kB +0.01% +5 B 🔺
@sentry/browser (incl. Feedback) 41.27 kB +0.02% +7 B 🔺
@sentry/browser (incl. sendFeedback) 29.27 kB +0.03% +7 B 🔺
@sentry/browser (incl. FeedbackAsync) 34.2 kB +0.02% +5 B 🔺
@sentry/react 26.29 kB -0.04% -8 B 🔽
@sentry/react (incl. Tracing) 43.19 kB -0.06% -23 B 🔽
@sentry/vue 29.08 kB +0.03% +6 B 🔺
@sentry/vue (incl. Tracing) 43 kB +0.01% +4 B 🔺
@sentry/svelte 24.61 kB +0.03% +5 B 🔺
CDN Bundle 26.89 kB +0.03% +7 B 🔺
CDN Bundle (incl. Tracing) 41.78 kB +0.01% +2 B 🔺
CDN Bundle (incl. Tracing, Replay) 78.3 kB +0.01% +2 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 83.77 kB +0.01% +1 B 🔺
CDN Bundle - uncompressed 78.86 kB +0.02% +14 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 123.98 kB +0.02% +14 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 240.01 kB +0.01% +14 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 252.77 kB +0.01% +14 B 🔺
@sentry/nextjs (client) 45.31 kB +0.02% +6 B 🔺
@sentry/sveltekit (client) 41.61 kB +0.01% +3 B 🔺
@sentry/node-core 50.76 kB - -
@sentry/node 157.82 kB +0.01% +1 B 🔺
@sentry/node - without tracing 92.64 kB - -
@sentry/aws-serverless 106.37 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!

@timfish timfish changed the title feat(browser): Separate dev/prod browser builds feat(browser): Include Spotlight in development bundles Nov 7, 2025
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