feat(useWebWorkerFn): support local dependencies #3316
Closed
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.
Description
fixes #2005
useWebWorkerFn
used to support remote dependencies for the function passed but not local functions.the library which this function is a port of (
useWorker
by Alessio Koci) have the support of local dependencies.The addition is also very much a port of
useWorker
implementation.Additional context
In order to support this feature, I've added a new dependency on core package called
isoworker
. as the core package is very light with dependencies, im unsure if thats fine or it's enough for us to split it into integration package of its own. open for thoughts馃 Generated by Copilot at 7e11dfb
This pull request adds a new feature to the
useWebWorkerFn
hook that allows users to pass local dependencies to the web worker. It uses theisoworker
module to create a context for the dependencies and inject them into the worker blob URL. It also updates the documentation, the demo code, and the dependencies for the@vueuse/core
package.馃 Generated by Copilot at 7e11dfb
isoworker
dependency to@vueuse/core
package to support local dependencies inuseWebWorkerFn
hook (link, link, link)localDependencies
option touseWebWorkerFn
hook and pass it tocreateWorkerBlobUrl
function (link, link, link, link)isoworker
module to create a context for local dependencies and inject it into the web worker code increateWorkerBlobUrl
function (link, link)useWebWorkerFn
documentation fromWith dependencies
toWith remote dependencies
and add a new section forWith local dependencies
with an example code snippet (link, link)useWebWorkerFn
hook to use a different heavy task function that uses two local dependencies:pow
andrandomNumber
(link)resolve
dependency from1.22.2
to1.22.3
inpnpm-lock.yaml
file, affecting several packages that depend on it (link, link, link, link, link, link, link)requiresBuild
property to@vueuse/core
package inpnpm-lock.yaml
file, indicating that the package needs to be built before being used (link)pnpm-lock.yaml
file that marked@vueuse/core
package as a dev dependency instead of a dependency (link, link)