From daeef8d4a901258f4169209d4e09e9ff0f3b21d3 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Tue, 17 Dec 2024 17:18:36 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20dynamically=20import=20node=20pr?= =?UTF-8?q?ocess?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/main.ts b/lib/main.ts index 0f68f999..598cc536 100644 --- a/lib/main.ts +++ b/lib/main.ts @@ -3,7 +3,7 @@ import { type Operation } from "./types.ts"; import { callcc } from "./callcc.ts"; import { run } from "./run.ts"; import { useScope } from "./scope.ts"; -import process from "node:process"; +import { call } from "./call.ts"; /** * Halt process execution immediately and initiate shutdown. If a message is @@ -96,6 +96,9 @@ export async function main( } }, *node() { + let { default: process } = yield* call(() => + import("node:process") + ); hardexit = (status) => process.exit(status); try { process.on("SIGINT", interrupt.SIGINT); @@ -164,7 +167,7 @@ function* withHost(op: HostOperation): Operation { // @see https://github.com/iliakan/detect-node/blob/master/index.js } else if ( Object.prototype.toString.call( - typeof process !== "undefined" ? process : 0, + typeof globalThis.process !== "undefined" ? globalThis.process : 0, ) === "[object process]" ) { return yield* op.node();