You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the web worker for replay is built via yarn build:worker. This builds the worker script and stores it as a string in src/worker.js, which is then actually used.
While this works, it has some downsides:
Since this is built & checked in, it is possible to have a different version of this locally/on CI/when building.
You need to remember to run this every now and then locally & check the generated file in (if it changed)
It is not ideal to have a two-step build process inside of replay (this is a bit custom and requires a bunch of custom/duplicate build stuff in there).
Some notes on what doesn't work
Sadly, just using something like https://github.com/darionco/rollup-plugin-web-worker-loader does not work as easily as expected.
While it is possible to get it to work, jest & jsdom do not like this. Basically, jsdom-worker only works with string-based workers, not with an actual js file reference. And it's also not really possible to do something like fs.readFileSync('worker.js') as that would not include all the dependencies etc.
Proposed solution
After some experimentation, we believe the best approach is to move the worker into a private sub-package, e.g. @sentry/replay-compression-worker. This package would build the worker into a single worker.js file, similar to what we have now, but:
in a standalone package
In a .js file, not a string
Then, replay can depend on this (and internally inline it at build time), and we can make it work with rollup-plugin-web-worker-loader (because there exists a fully built file that we can read from disk & inline).
The text was updated successfully, but these errors were encountered:
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
Currently, the web worker for replay is built via
yarn build:worker
. This builds the worker script and stores it as a string insrc/worker.js
, which is then actually used.While this works, it has some downsides:
Some notes on what doesn't work
Sadly, just using something like https://github.com/darionco/rollup-plugin-web-worker-loader does not work as easily as expected.
While it is possible to get it to work, jest & jsdom do not like this. Basically,
jsdom-worker
only works with string-based workers, not with an actual js file reference. And it's also not really possible to do something likefs.readFileSync('worker.js')
as that would not include all the dependencies etc.Proposed solution
After some experimentation, we believe the best approach is to move the worker into a private sub-package, e.g.
@sentry/replay-compression-worker
. This package would build the worker into a singleworker.js
file, similar to what we have now, but:Then, replay can depend on this (and internally inline it at build time), and we can make it work with rollup-plugin-web-worker-loader (because there exists a fully built file that we can read from disk & inline).
The text was updated successfully, but these errors were encountered: