1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00
denoland-deno/tests/specs/node/worker_threads_cache/main.ts
Divy Srivastava 88983fb3eb
fix(node): seperate worker module cache (#23634)
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>
2024-05-16 07:09:35 +00:00

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));
}