getsentry / rrweb

record and replay the web
https://www.rrweb.io/
Other
9 stars 5 forks source link

feat: Add build flags to allow noop iframe/canvas/shadow dom managers #114

Closed mydea closed 9 months ago

mydea commented 9 months ago

This PR adds 3 new build flags to rrweb:

If you set these to true at build time, it will replace the regular ShadowDomManager / CanvasManager / IframeManager with a noop variant of these managers.

All of these together shave off about 8 KB gzipped from our replay bundles, if set to true.

For now, we'll probably keep this enabled by default, but at least we have a path for users to shake this out if they don't need these features.

Note: I played with some other approaches, e.g. instead of having the noop class make these e.g. iframeManager: IframeManager | undefined, but I think overall the code to guard against using this everywhere ends up being a similar amount of bytes, plus we need to spread this much more through the codebase, making rebasing on upstream master etc. potentially harder. This way, IMHO it should be the easiest way to keep this as contained as possible.

Note 2: In scenarios where you do not set the build flags at all (so neither to true or false), this will actually slightly increase the bundle size 😬 but it's a very tiny increase which is OK I'd say.

mydea commented 9 months ago

PR to implement this in replay: https://github.com/getsentry/sentry-javascript/pull/9274