My concrete Problem is also detailed here
I want to use a web worker defined in a dependency (I also only want to use it in this dependency) but I cannot find a way to load it as svelte-package -> vite messes up the pass and doesn't make the worker file available in the specified path
- create a svelte package that uses a web worker, i.e a component that uses something like
import Worker from '$lib/workers/w.worker?worker';
in its script tag - bundle that package using
svelte-package
- ❗ this replaces the import with a relative path:
import Worker from '../workers/w.worker?worker';
- ❗ this replaces the import with a relative path:
- upload to npmjs or similar and add as dependency
- in the new project run
npm run dev
- ❗ this throws:
✘ [ERROR] Could not resolve "../workers/w.worker?worker"
- ❗ this throws:
similarly using the new Worker(new URL('$lib/workers/w.workers.mts', import.meta.url), { type: 'module' });
syntax results in the browser having a 404