-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(browser): Separate dev/prod browser builds #18078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
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.
|
There was a problem hiding this 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)
8d0f261 to
92bc9f6
Compare
size-limit report 📦
|
41be108 to
eb515c4
Compare
|
Needs some tests to confirm Spotlight actually works in dev mode... |
packages/browser/src/sdk.ts
Outdated
| if (!defaultIntegrations) { | ||
| defaultIntegrations = []; | ||
| } | ||
| defaultIntegrations.push(spotlightBrowserIntegration()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct as we need to pass options.spotlight as an argument to spotlightBrowserIntegration as {sidecarUrl: options.spotlight} if it's a string.
| defaultIntegrations.push(spotlightBrowserIntegration()); | |
| defaultIntegrations.push(spotlightBrowserIntegration(typeof options.spotlight === 'string' ? {sidecarUrl: options.spotlight} : undefined)); |
| options.defaultIntegrations == null ? getDefaultIntegrations(options) : options.defaultIntegrations; | ||
|
|
||
| /* rollup-include-development-only */ | ||
| if (options.spotlight) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
| if (!pattern.test(code)) return null; | ||
| const replaced = code.replace(pattern, ''); | ||
| return { code: replaced, map: null }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Regex Global State Mutates, Breaks Replacement
The regex pattern has the global flag (g) and is being reused. When pattern.test(code) is called on line 133, it modifies the regex's internal lastIndex property. This causes the subsequent code.replace(pattern, '') call on line 134 to potentially fail or behave incorrectly because the regex state has been mutated. The regex will start matching from the lastIndex position set by the test() call rather than from the beginning. This could result in development-only code blocks not being properly removed from production builds. The fix is to either: 1) use pattern.test() without the global flag, 2) reset pattern.lastIndex = 0 between calls, or 3) use code.includes() or code.match() for the check instead.
This PR:
The development build has this code:
But production builds have this stripped out: