Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request simplifies worker handling and updates the documentation accordingly. It includes breaking changes (see below).
Workers out of the box
The build and the modules now already contain a worker that is inlined into a new
./dist-module/worker/decoder.js
module, so users do not need to worry about how to build the worker. The./pool.js
module uses that worker as a dynamic import, unless thePool
instance is created with a customcreateWorker()
function as 2nd argument. This makes it easy to use custom workers that add additional decoders.The inlining of the worker is done with the new
scripts/serialize-workers.js
script, using rollup and a technique that is borrowed form OpenLayers.Removal of the
threads.js
dependencyWorker pools are simple enough to not require a heavy dependency like
threads.js
. This pull request removes that dependency. This change reduces the resulting build sizes and gets rid of bundler warnings abouteval()
.Fixes
npm run dev
now works again, thanks to the inlined worker.Pool
test has been resurrected.Documentation
The API docs have been updated to show how to use a custom decoder worker. I removed the section about the worker overhead for copying data between worker and main thread, because that is no longer necessary thanks to the use of Transferables (this was also the case with threads.js already).
Breaking changes
Pool
API has changed. The 2nd argument is no longer athreads/Worker
instance, but a function that returns a Web Worker.src/
folder is now in thedist-module/
folder. This change was necessary to allow for a good build story of the new./dist-worker/worker/decoder.js
module. All development life cycle scripts have been updated so developers don't need to worry about this change during development.