memfs icon indicating copy to clipboard operation
memfs copied to clipboard

add ability for worker module creation

Open Karnith opened this issue 2 years ago • 2 comments

The current code for worker in FsaNodeSyncAdapterWorker only creates a worker from url string: line #24

If this would be changed to:

let worker;
if (url && typeof url === 'string' && url.includes('type=module')) {
	worker = new Worker(url, { type: 'module' })
} else {
	worker = new Worker(url);
};

it would allow for the fsa-to-node module to be used in frameworks where import is the only way to grab the worker file (vite for example). The import would look like:

import MyWoker from '../worker?worker&url'

which gets morphed to the url string /src/worker.ts?type=module&worker_file and expects the worker initialization to have the worker options of type module passed top it.

Karnith avatar Dec 18 '23 18:12 Karnith

Or just allow passing a worker?

louwers avatar Mar 08 '25 16:03 louwers

Implement this by allowing to pass a Worker or a URL:

urlOrWorker: string | Worker,

streamich avatar Jul 27 '25 10:07 streamich