Skip to content

build(core): Do not mangle private methods used by Replay - #6493

Merged
Lms24 merged 2 commits into
masterfrom
lms-replay-fix-cdn-min
Dec 12, 2022
Merged

build(core): Do not mangle private methods used by Replay#6493
Lms24 merged 2 commits into
masterfrom
lms-replay-fix-cdn-min

Conversation

@Lms24

@Lms24Lms24 commented Dec 12, 2022

Copy link
Copy Markdown
Member

In Replay, we access some private methods from the core SDK package from the Client class. Because we mangle private fields by default, our SDK CDN bundles wouldn't expose these methods and fields anymore in their clear name to external callers, such as our Replay CDN bundle, producing runtime errors because the methods were not found.

This PR fixes these errors by explicitly excluding the called private methods from mangling so that they can be accessed externally. This is admittedly not a clean solution but it unblocks minified CDN bundle users. In the long run we can revert this PR once we streamlined Replay event sending into the SDK (#6480) (as well as breadcrumbs via hooks?).

Note: This unfortunately increases bundle size, not just for the Replay CDN bundle, but also for the Browser SDK CDN bundle.

fixes#6466

@mydea

Copy link
Copy Markdown
Member

Very nice! I made a PR refactoring _withClient, so I think we can leave this in here - that one was relatively easy to refactor: #6494

Comment threadrollup/plugins/bundlePlugins.js Outdated
@github-actions

github-actionsBot commented Dec 12, 2022

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
@sentry/browser - ES5 CDN Bundle (gzipped + minified)19.7 KB (+0.08% 🔺)
@sentry/browser - ES5 CDN Bundle (minified)61.04 KB (+0.14% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified)18.49 KB (+0.12% 🔺)
@sentry/browser - ES6 CDN Bundle (minified)54.59 KB (+0.16% 🔺)
@sentry/browser - Webpack (gzipped + minified)20.27 KB (0%)
@sentry/browser - Webpack (minified)66.25 KB (0%)
@sentry/react - Webpack (gzipped + minified)20.29 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified)47.29 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified)26.68 KB (+0.07% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified)25.13 KB (+0.08% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified)41.85 KB (+0.03% 🔺)
@sentry/replay - Webpack (gzipped + minified)37.89 KB (0%)

Comment threadrollup/plugins/bundlePlugins.js Outdated
Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
@Lms24Lms24 changed the title fix(replay): Do not mangle private fields used by Replayfix(replay): Do not mangle private methods used by ReplayDec 12, 2022
@Lms24Lms24 changed the title fix(replay): Do not mangle private methods used by Replaybuild(core): Do not mangle private methods used by ReplayDec 12, 2022
@Lms24
Lms24 merged commit d36de87 into masterDec 12, 2022
@Lms24
Lms24 deleted the lms-replay-fix-cdn-min branch December 12, 2022 10:24
@Lms24Lms24 mentioned this pull request Dec 22, 2022
Sign up for freeto 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.

[Replay] Replay not sending on errors

2 participants

@Lms24@mydea