Added Vite bundler support, Channels & Async functions #5
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.
To support the Vite bundler (and possible others), I figured out, that providing the
wasm.js
file as a path is not enough. Additionally also the direct path to thewas.wasm
file need to be provided. If both are delivered correctly it's working. This solves my issue #4.The implementation simply adds a new path for the actual wasm file. Please let me know, when the naming is still a bit off.
Following my example code from my index.js file loaded with Vite:
This leaves one problem for now. Using the worker pool is only possible after it has been fully loaded. With this configuration the main rust code is running before the WebWorkerPool is fully initialized. Using it inside rust before will create a new default one which will fail. This is due to the actual implementation here.
wasmworker/src/global.rs
Line 50 in 9251271
Could this be changed to something which is waiting until the pool is ready?
My local workaround for this is the following ugly code: