Replies: 1 comment
-
The following statement is not true (in bold), only if not using Web WorkerA web worker script can be directly imported by appending |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Since the definition of importing an esm web worker is a hack, we can use it as a constructor:
We can find the code previous
import
generates in the worker plugin:src/node/plugins/worker.ts
It is confusing to people how to use it with dynamic imports, and seems that cannot be used with
import('...')
.Invoking the
dynamic import
returns amodule
, and so, it is necessary to invoke what the worker plugin exports: it exports the function asdefault
so we need to use it, the following code is equivalent (with code spliting):I think this should be included in Vite docs, here: web worker section.
Beta Was this translation helpful? Give feedback.
All reactions