-
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: Bundle canvas worker manually #144
Conversation
9d3f35f
to
a3d829d
Compare
size-limit report 📦
|
Tracking this upstream as well: rrweb-io#1376 |
}, | ||
); | ||
} catch { | ||
// Error when initializing canvas... |
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.
Should this bubble up to error handler?
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.
good point, I'll wrap this in callbackWrapper instead!
const workerBlob = new Blob([workerString]); | ||
return URL.createObjectURL(workerBlob); |
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.
Does this mean we'll have potential CSP errors now?
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.
we already had before! Previously this was just being rewritten to a string-based worker by rollup under the hood 😬
4ad67b6
to
4571ff5
Compare
This bump contains the following changes: - fix(rrweb): Use unpatched requestAnimationFrame when possible [#150](getsentry/rrweb#150) - ref: Avoid async in canvas [#143](getsentry/rrweb#143) - feat: Bundle canvas worker manually [#144](getsentry/rrweb#144) - build: Build for ES2020 [#142](getsentry/rrweb#142) Extracted out from #9826 Closes #6946
While trying to get the ReplayCanvas integration to properly tree shake, I noticed that the current way this worker is built is not ideal, and maybe is not treeshakeable properly. We use a rollup plugin to convert the worker to a base64 string, which a) is more verbose than just having the worker be a plain string, and b) possibly is not tree shakeable. This refactors the worker to work the same way as the compression worker in Sentry - we build it to a string and use that in rrweb. This is a bit more complicated, from a setup perspective, but gives us full control over the worker build.
While trying to get the ReplayCanvas integration to properly tree shake, I noticed that the current way this worker is built is not ideal, and maybe is not treeshakeable properly. We use a rollup plugin to convert the worker to a base64 string, which a) is more verbose than just having the worker be a plain string, and b) possibly is not tree shakeable.
This refactors the worker to work the same way as the compression worker in Sentry - we build it to a string and use that in rrweb. This is a bit more complicated, from a setup perspective, but gives us full control over the worker build.