diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs index 582284c36a..6e47da8f63 100644 --- a/cli/tests/integration/npm_tests.rs +++ b/cli/tests/integration/npm_tests.rs @@ -54,6 +54,13 @@ itest!(cjs_local_global_decls { http_server: true, }); +itest!(compare_globals { + args: "run --allow-read --unstable npm/compare_globals/main.js", + output: "npm/compare_globals/main.out", + envs: env_vars(), + http_server: true, +}); + itest!(dynamic_import { args: "run --allow-read --unstable npm/dynamic_import/main.ts", output: "npm/dynamic_import/main.out", diff --git a/cli/tests/testdata/npm/compare_globals/main.js b/cli/tests/testdata/npm/compare_globals/main.js new file mode 100644 index 0000000000..ce43e32b11 --- /dev/null +++ b/cli/tests/testdata/npm/compare_globals/main.js @@ -0,0 +1,2 @@ +import * as globals from "npm:@denotest/globals"; +console.log(globals.global === globals.globalThis); diff --git a/cli/tests/testdata/npm/compare_globals/main.out b/cli/tests/testdata/npm/compare_globals/main.out new file mode 100644 index 0000000000..a1a5c0e8f3 --- /dev/null +++ b/cli/tests/testdata/npm/compare_globals/main.out @@ -0,0 +1,3 @@ +Download http://localhost:4545/npm/registry/@denotest/globals +Download http://localhost:4545/npm/registry/@denotest/globals/1.0.0.tgz +true diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-local-global-decls/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/cjs-local-global-decls/1.0.0/package.json index b151deaf66..1048fe76d0 100644 --- a/cli/tests/testdata/npm/registry/@denotest/cjs-local-global-decls/1.0.0/package.json +++ b/cli/tests/testdata/npm/registry/@denotest/cjs-local-global-decls/1.0.0/package.json @@ -1,4 +1,4 @@ { - "name": "@deno/cjs-local-global-decls", + "name": "@denotest/cjs-local-global-decls", "version": "1.0.0" } diff --git a/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.js new file mode 100644 index 0000000000..be5e6e5ac4 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.js @@ -0,0 +1,2 @@ +exports.globalThis = globalThis; +exports.global = global; diff --git a/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/package.json new file mode 100644 index 0000000000..cba0742c1a --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/package.json @@ -0,0 +1,4 @@ +{ + "name": "@denotest/globals", + "version": "1.0.0" +} diff --git a/ext/node/01_node.js b/ext/node/01_node.js index 8425d31013..883932c5d3 100644 --- a/ext/node/01_node.js +++ b/ext/node/01_node.js @@ -93,7 +93,7 @@ nodeGlobals.clearImmediate = nativeModuleExports["timers"].clearImmediate; nodeGlobals.clearInterval = nativeModuleExports["timers"].clearInterval; nodeGlobals.clearTimeout = nativeModuleExports["timers"].clearTimeout; - nodeGlobals.global = nodeGlobals; + nodeGlobals.global = nodeGlobalThis; nodeGlobals.process = nativeModuleExports["process"]; nodeGlobals.setImmediate = nativeModuleExports["timers"].setImmediate; nodeGlobals.setInterval = nativeModuleExports["timers"].setInterval;