mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
88983fb3eb
Construct a new module graph container for workers instead of sharing it with the main worker. Fixes #17248 Fixes #23461 --------- Co-authored-by: David Sherret <dsherret@gmail.com>
13 lines
403 B
TypeScript
13 lines
403 B
TypeScript
import fs from "node:fs/promises";
|
|
import { isMainThread, Worker } from "node:worker_threads";
|
|
|
|
await fs.writeFile("mod.mjs", "export default " + isMainThread);
|
|
|
|
const path = new URL("mod.mjs", import.meta.url);
|
|
const i = await import(path.href);
|
|
console.log(i);
|
|
|
|
if (isMainThread) {
|
|
const worker = new Worker(new URL("main.ts", import.meta.url));
|
|
worker.on("message", (msg) => console.log(msg));
|
|
}
|