Replies: 2 comments 1 reply
-
I'm not sure if this will work – but try using |
Beta Was this translation helpful? Give feedback.
-
Any new insight on that since? So I have a web worker I'm loading like this: const w = new Worker(new URL("./that.worker", import.meta.url), {
credentials: "same-origin",
type: "module"
}); It works and runs and does what it is supposed to. The problem is that the worker absolutely requires a large (500kb) library that is also used throughout the rest of the project (a mess of separate entry points sharing code, designed for embedding inside a really brittle legacy PHP site.) It is fairly important that it share at least this 500kb library (and preferably other code) with the rest of the project, which already chunks dependencies the way I like, but Vite seems insistent on duplicating chunks. If I just pass
If I build my worker as a separate entry point, and then, directly in the bundled code, change I'm pretty sure this is supposed to be possible (https://bundlers.tooling.report/code-splitting/between-workers/) but it's entirely unclear to me how to get Vite to actually do that. |
Beta Was this translation helpful? Give feedback.
-
I have 3 web workers + the main code, all importing
comlink
(for instance, it can be any other common dependency). When I build, all 4 entry points (main + workers) contain thecomlink
code. The main code has an import to acomlink
file, and the 3 workers have it inline in their entrypoint file.I want them all to share the code, instead of having 4 instances of it, to decrease bundle size and build time. I want them all to import the same file.
How can this be achieved?
Beta Was this translation helpful? Give feedback.
All reactions