mirror of
https://github.com/denoland/deno.git
synced 2024-12-15 11:58:42 -05:00
14 lines
403 B
TypeScript
14 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));
|
||
|
}
|