The content of this section is derived from the content of the following links and is subject to the CC BY 4.0 license.
The following contents can be assumed to be the result of modifications and deletions based on the original contents if not specifically stated.
Web Workers are first-class citizens of Rspack, which means you don't need any loader to use Web Workers directly.
For examples:
The syntax was chosen to allow running code without bundler, it is also available in native ECMAScript modules in the browser.
Note that new Worker
can also accept a string representation of a URL, but only passing in URLs is supported in Rspack.
Rspack does not support the use of variables in new Worker
. For example, the following code will not work:
This is because Rspack cannot statically analyze the syntax. Please be sure to note this limitation when using the Worker syntax in Rspack.
The current implementation supports most of the common usage scenarios, the following uncommon scenarios are still not supported
module.parser.javascript.worker
is not supportednavigator.serviceWorker.register()
is not supported/* webpackEntryOptions: { filename: "workers/[name].js" } */
magic comments