Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ability for worker module creation #974

Open
Karnith opened this issue Dec 18, 2023 · 0 comments
Open

add ability for worker module creation #974

Karnith opened this issue Dec 18, 2023 · 0 comments

Comments

@Karnith
Copy link

Karnith commented Dec 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant