You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can customize the Worker's chunk name through the `name` property (the property value must be statically analyzable). This name will replace the `[name]` placeholder in the generated chunk filename:
name: 'my-worker',// <-- When the value of the name property can be statically analyzed, the worker's chunk name can be customized with this property to replace the [name] placeholder when the chunk file is generated
23
+
name: 'my-worker',
20
24
});
21
25
```
22
26
23
-
In addition to `newWorker()`, the following syntax is also supported:
27
+
:::info
28
+
This syntax was chosen for its strong standards compliance. It's built on the standard ECMAScript module specification, which means it works seamlessly even without build tools. For example, it runs natively in modern browsers with ES module support.
29
+
:::
30
+
31
+
### Additional syntax
32
+
33
+
In addition to `newWorker()`, Rspack also supports the following syntax by default:
34
+
35
+
- `newSharedWorker()`, see [SharedWorker](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker)
36
+
37
+
```js
38
+
constsharedWorker=newSharedWorker(
39
+
newURL('./shared-worker.js', import.meta.url),
40
+
);
41
+
sharedWorker.port.start();
42
+
```
43
+
44
+
- `import { Worker } from"node:worker_threads"`: commonly used in Node.js environments, see [Worker threads](https://nodejs.org/api/worker_threads.html)
- `navigator.serviceWorker.register()`: used to register Service Workers, see [ServiceWorkerContainer](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register)
- `navigator.serviceWorker.register()`:用于注册 Service Worker,详见 [ServiceWorkerContainer](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register)。
0 commit comments