diff options
author | Marvin Hagemeister <marvin@deno.com> | 2024-11-14 14:11:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-14 13:11:29 +0000 |
commit | de34c7ed29bcce8b46a65f5effe45090b8493ba5 (patch) | |
tree | 5dc23f03d87522682342f0f82215566e8e580298 /tests | |
parent | 4e899d48cffa95617266dd8f9aef54603a87ad82 (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 'tests')
-rw-r--r-- | tests/specs/lint/node_globals_no_duplicate_imports/main.out | 3 | ||||
-rw-r--r-- | tests/specs/run/node_globals_hints/buffer.out | 3 | ||||
-rw-r--r-- | tests/specs/run/node_globals_hints/clear_immediate.out | 3 | ||||
-rw-r--r-- | tests/specs/run/node_globals_hints/global.out | 3 | ||||
-rw-r--r-- | tests/specs/run/node_globals_hints/set_immediate.out | 3 | ||||
-rw-r--r-- | tests/specs/run/unstable/__test__.jsonc | 5 | ||||
-rw-r--r-- | tests/specs/run/unstable/node_globals.out | 4 | ||||
-rw-r--r-- | tests/specs/run/unstable/node_globals.ts | 7 |
8 files changed, 26 insertions, 5 deletions
diff --git a/tests/specs/lint/node_globals_no_duplicate_imports/main.out b/tests/specs/lint/node_globals_no_duplicate_imports/main.out index 058b80795..ce5523f99 100644 --- a/tests/specs/lint/node_globals_no_duplicate_imports/main.out +++ b/tests/specs/lint/node_globals_no_duplicate_imports/main.out @@ -4,4 +4,5 @@ const _foo = setImmediate; at [WILDCARD]main.ts:3:14 info: setImmediate is not available in the global scope in Deno. - hint: Import it explicitly with import { setImmediate } from "node:timers";. + hint: Import it explicitly with import { setImmediate } from "node:timers";, + or run again with --unstable-node-globals flag to add this global. diff --git a/tests/specs/run/node_globals_hints/buffer.out b/tests/specs/run/node_globals_hints/buffer.out index 4980e6d12..858f404ab 100644 --- a/tests/specs/run/node_globals_hints/buffer.out +++ b/tests/specs/run/node_globals_hints/buffer.out @@ -4,4 +4,5 @@ Buffer; at [WILDCARD]buffer.js:1:1 info: Buffer is not available in the global scope in Deno. - hint: Import it explicitly with import { Buffer } from "node:buffer";. + hint: Import it explicitly with import { Buffer } from "node:buffer";, + or run again with --unstable-node-globals flag to add this global. diff --git a/tests/specs/run/node_globals_hints/clear_immediate.out b/tests/specs/run/node_globals_hints/clear_immediate.out index ecd34babe..a973a3172 100644 --- a/tests/specs/run/node_globals_hints/clear_immediate.out +++ b/tests/specs/run/node_globals_hints/clear_immediate.out @@ -4,4 +4,5 @@ clearImmediate; at [WILDCARD]clear_immediate.js:1:1 info: clearImmediate is not available in the global scope in Deno. - hint: Import it explicitly with import { clearImmediate } from "node:timers";. + hint: Import it explicitly with import { clearImmediate } from "node:timers";, + or run again with --unstable-node-globals flag to add this global. diff --git a/tests/specs/run/node_globals_hints/global.out b/tests/specs/run/node_globals_hints/global.out index e090d32e2..ad01ac426 100644 --- a/tests/specs/run/node_globals_hints/global.out +++ b/tests/specs/run/node_globals_hints/global.out @@ -4,4 +4,5 @@ global; at [WILDCARD]global.js:1:1 info: global is not available in the global scope in Deno. - hint: Use globalThis instead, or assign globalThis.global = globalThis. + hint: Use globalThis instead, or assign globalThis.global = globalThis, + or run again with --unstable-node-globals flag to add this global. diff --git a/tests/specs/run/node_globals_hints/set_immediate.out b/tests/specs/run/node_globals_hints/set_immediate.out index 38859ff5d..b3feb3127 100644 --- a/tests/specs/run/node_globals_hints/set_immediate.out +++ b/tests/specs/run/node_globals_hints/set_immediate.out @@ -4,4 +4,5 @@ setImmediate; at [WILDCARD]set_immediate.js:1:1 info: setImmediate is not available in the global scope in Deno. - hint: Import it explicitly with import { setImmediate } from "node:timers";. + hint: Import it explicitly with import { setImmediate } from "node:timers";, + or run again with --unstable-node-globals flag to add this global. diff --git a/tests/specs/run/unstable/__test__.jsonc b/tests/specs/run/unstable/__test__.jsonc index 3ddcdb583..bceb2ac12 100644 --- a/tests/specs/run/unstable/__test__.jsonc +++ b/tests/specs/run/unstable/__test__.jsonc @@ -20,6 +20,11 @@ "exitCode": 1, "output": "kv.out" }, + "node_globals": { + "args": "run --unstable-node-globals node_globals.ts", + "exitCode": 0, + "output": "node_globals.out" + }, "temporal": { "args": "run temporal.ts", "exitCode": 1, diff --git a/tests/specs/run/unstable/node_globals.out b/tests/specs/run/unstable/node_globals.out new file mode 100644 index 000000000..77045c7cb --- /dev/null +++ b/tests/specs/run/unstable/node_globals.out @@ -0,0 +1,4 @@ +global: true +Buffer: true +setImmediate: true +clearImmediate: true diff --git a/tests/specs/run/unstable/node_globals.ts b/tests/specs/run/unstable/node_globals.ts new file mode 100644 index 000000000..706b7eb65 --- /dev/null +++ b/tests/specs/run/unstable/node_globals.ts @@ -0,0 +1,7 @@ +import * as nodeBuffer from "node:buffer"; +import * as nodeTimers from "node:timers"; + +console.log(`global: ${globalThis === global}`); +console.log(`Buffer: ${Buffer === nodeBuffer.default}`); +console.log(`setImmediate: ${setImmediate === nodeTimers.setImmediate}`); +console.log(`clearImmediate: ${clearImmediate === nodeTimers.clearImmediate}`); |