summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
authorMarvin Hagemeister <marvin@deno.com>2024-11-14 14:11:29 +0100
committerGitHub <noreply@github.com>2024-11-14 13:11:29 +0000
commitde34c7ed29bcce8b46a65f5effe45090b8493ba5 (patch)
tree5dc23f03d87522682342f0f82215566e8e580298 /runtime/js
parent4e899d48cffa95617266dd8f9aef54603a87ad82 (diff)
feat(cli): add `--unstable-node-globals` flag (#26617)
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 <biwanczuk@gmail.com>
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/90_deno_ns.js13
-rw-r--r--runtime/js/98_global_scope_shared.js13
2 files changed, 20 insertions, 6 deletions
diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js
index 11f618ce2..079338510 100644
--- a/runtime/js/90_deno_ns.js
+++ b/runtime/js/90_deno_ns.js
@@ -144,12 +144,13 @@ const unstableIds = {
http: 5,
kv: 6,
net: 7,
- otel: 8,
- process: 9,
- temporal: 10,
- unsafeProto: 11,
- webgpu: 12,
- workerOptions: 13,
+ nodeGlobals: 8,
+ otel: 9,
+ process: 10,
+ temporal: 11,
+ unsafeProto: 12,
+ webgpu: 13,
+ workerOptions: 14,
};
const denoNsUnstableById = { __proto__: null };
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 };