mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
fix(npm): add console
global for node environment (#16519)
This global is already isolated to node during type checking. Closes #16518
This commit is contained in:
parent
5140795662
commit
77fb26e143
5 changed files with 11 additions and 6 deletions
|
@ -19,6 +19,7 @@ static NODE_GLOBALS: &[&str] = &[
|
|||
"clearImmediate",
|
||||
"clearInterval",
|
||||
"clearTimeout",
|
||||
"console",
|
||||
"global",
|
||||
"process",
|
||||
"setImmediate",
|
||||
|
@ -194,9 +195,10 @@ mod tests {
|
|||
"var globalThis = {}",
|
||||
";var Buffer = globalThis.Buffer;",
|
||||
"var clearImmediate = globalThis.clearImmediate;var clearInterval = globalThis.clearInterval;",
|
||||
"var clearTimeout = globalThis.clearTimeout;var global = globalThis.global;",
|
||||
"var process = globalThis.process;var setImmediate = globalThis.setImmediate;",
|
||||
"var setInterval = globalThis.setInterval;var setTimeout = globalThis.setTimeout;\n",
|
||||
"var clearTimeout = globalThis.clearTimeout;var console = globalThis.console;",
|
||||
"var global = globalThis.global;var process = globalThis.process;",
|
||||
"var setImmediate = globalThis.setImmediate;var setInterval = globalThis.setInterval;",
|
||||
"var setTimeout = globalThis.setTimeout;\n",
|
||||
"export const x = 1;"
|
||||
),
|
||||
NODE_GLOBAL_THIS_NAME.as_str(),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// package that has all the locals defined
|
||||
const Buffer = 1, clearImmediate = 1, clearInterval = 1, clearTimeout = 1, global = 1, process = 1, setImmediate = 1, setInterval = 1, setTimeout = 1, globalThis = 1;
|
||||
const Buffer = 1, clearImmediate = 1, clearInterval = 1, clearTimeout = 1, console = 1, global = 1, process = 1, setImmediate = 1, setInterval = 1, setTimeout = 1, globalThis = 1;
|
||||
const exports = 2;
|
||||
console.log("Loaded.");
|
||||
require("./other.js");
|
||||
|
|
2
cli/tests/testdata/npm/registry/@denotest/cjs-local-global-decls/1.0.0/other.js
vendored
Normal file
2
cli/tests/testdata/npm/registry/@denotest/cjs-local-global-decls/1.0.0/other.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
const console = new global.console.Console({ stdout: process.stdout });
|
||||
console.log("Loaded.");
|
|
@ -100,6 +100,7 @@
|
|||
nodeGlobals.clearImmediate = nativeModuleExports["timers"].clearImmediate;
|
||||
nodeGlobals.clearInterval = nativeModuleExports["timers"].clearInterval;
|
||||
nodeGlobals.clearTimeout = nativeModuleExports["timers"].clearTimeout;
|
||||
nodeGlobals.console = nativeModuleExports["console"];
|
||||
nodeGlobals.global = nodeGlobalThis;
|
||||
nodeGlobals.process = nativeModuleExports["process"];
|
||||
nodeGlobals.setImmediate = nativeModuleExports["timers"].setImmediate;
|
||||
|
|
|
@ -662,7 +662,7 @@
|
|||
Module.wrapper = [
|
||||
// We provide the non-standard APIs in the CommonJS wrapper
|
||||
// to avoid exposing them in global namespace.
|
||||
"(function (exports, require, module, __filename, __dirname, globalThis) { const { Buffer, clearImmediate, clearInterval, clearTimeout, global, process, setImmediate, setInterval, setTimeout} = globalThis; var window = undefined; (function () {",
|
||||
"(function (exports, require, module, __filename, __dirname, globalThis) { const { Buffer, clearImmediate, clearInterval, clearTimeout, console, global, process, setImmediate, setInterval, setTimeout} = globalThis; var window = undefined; (function () {",
|
||||
"\n}).call(this); })",
|
||||
];
|
||||
Module.wrap = function (script) {
|
||||
|
|
Loading…
Add table
Reference in a new issue