-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: Add build flags to allow noop iframe/canvas/shadow dom managers #114
Conversation
PR to implement this in replay: getsentry/sentry-javascript#9274 |
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.
Great change!
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.
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
I think this is a good approach. This means it works like our other tree shaking flags and users can opt out in the same way. Easier documentation and more consistency across our packages 👍
This depends on getsentry/rrweb#114 to be merged first, but allows to configure build time flags to shake out certain rrweb features that may not be used. It also adds a size limit entry that shows the total bundle size with everything that can be shaken out removed, incl. debug stuff. Bundle size is about ~11kb gzipped less in this scenario, which is not bad.
…#114) This PR adds 3 new build flags to rrweb: * `__RRWEB_EXCLUDE_CANVAS__` * `__RRWEB_EXCLUDE_SHADOW_DOM__` * `__RRWEB_EXCLUDE_IFRAME__` 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.
…#114) This PR adds 3 new build flags to rrweb: * `__RRWEB_EXCLUDE_CANVAS__` * `__RRWEB_EXCLUDE_SHADOW_DOM__` * `__RRWEB_EXCLUDE_IFRAME__` 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.
This PR adds 3 new build flags to rrweb:
__RRWEB_EXCLUDE_CANVAS__
__RRWEB_EXCLUDE_SHADOW_DOM__
__RRWEB_EXCLUDE_IFRAME__
If you set these to
true
at build time, it will replace the regularShadowDomManager
/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.