// Good
new Worker(new URL("worker.js", import.meta.url).href, { type: "module" });
// Bad
new Worker(new URL("worker.js", import.meta.url).href);
new Worker(new URL("worker.js", import.meta.url).href, { type: "classic" });
new Worker("./worker.js", { type: "module" });
舉例來說,有一個主程式碼 main.ts 以來用來派發的工作程式碼 worker.ts :
// main.ts
new Worker(new URL("worker.ts", import.meta.url).href, { type: "module" });
There are no limits, you can create as many as you want
Again, there are no limits. We now have facilities to set heap limits on the isolate, but it's not possible to set them for workers.