From de34c7ed29bcce8b46a65f5effe45090b8493ba5 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Thu, 14 Nov 2024 14:11:29 +0100 Subject: feat(cli): add `--unstable-node-globals` flag (#26617) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR adds a new `--unstable-node-globals` flag to expose Node globals by default. Fixes https://github.com/denoland/deno/issues/26611 --------- Co-authored-by: Bartek IwaƄczuk --- runtime/js/98_global_scope_shared.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'runtime/js/98_global_scope_shared.js') diff --git a/runtime/js/98_global_scope_shared.js b/runtime/js/98_global_scope_shared.js index 7a2723899..f8e76b7ce 100644 --- a/runtime/js/98_global_scope_shared.js +++ b/runtime/js/98_global_scope_shared.js @@ -32,6 +32,8 @@ import { DOMException } from "ext:deno_web/01_dom_exception.js"; import * as abortSignal from "ext:deno_web/03_abort_signal.js"; import * as imageData from "ext:deno_web/16_image_data.js"; import process from "node:process"; +import Buffer from "node:buffer"; +import { clearImmediate, setImmediate } from "node:timers"; import { loadWebGPU } from "ext:deno_webgpu/00_init.js"; import * as webgpuSurface from "ext:deno_webgpu/02_surface.js"; import { unstableIds } from "ext:runtime/90_deno_ns.js"; @@ -300,4 +302,15 @@ unstableForWindowOrWorkerGlobalScope[unstableIds.net] = { unstableForWindowOrWorkerGlobalScope[unstableIds.webgpu] = {}; +unstableForWindowOrWorkerGlobalScope[unstableIds.nodeGlobals] = { + Buffer: core.propWritable(Buffer), + setImmediate: core.propWritable(setImmediate), + clearImmediate: core.propWritable(clearImmediate), + global: { + enumerable: true, + configurable: true, + get: () => globalThis, + }, +}; + export { unstableForWindowOrWorkerGlobalScope, windowOrWorkerGlobalScope }; -- cgit v1.2.3