aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler.js5
-rw-r--r--src/shell.js5
-rw-r--r--tests/hello_world.js5
-rw-r--r--tools/js-optimizer.js5
4 files changed, 20 insertions, 0 deletions
diff --git a/src/compiler.js b/src/compiler.js
index 1876ee1c..9e239c1d 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -17,6 +17,11 @@ var ENVIRONMENT_IS_WEB = typeof window === 'object';
var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+if (!ENVIRONMENT_IS_NODE) {
+ // Node needs these in the global scope, everywhere else, cleaner to not pollute the global scope
+ eval('var print, printErr, read, load, arguments_;');
+}
+
if (ENVIRONMENT_IS_NODE) {
// Expose functionality in the same simple way that the shells work
print = function(x) {
diff --git a/src/shell.js b/src/shell.js
index d67cc45a..b45d2c7d 100644
--- a/src/shell.js
+++ b/src/shell.js
@@ -9,6 +9,11 @@ var ENVIRONMENT_IS_WEB = typeof window === 'object';
var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+if (!ENVIRONMENT_IS_NODE) {
+ // Node needs these in the global scope, everywhere else, cleaner to not pollute the global scope
+ eval('var print, printErr, read, load, arguments_;');
+}
+
if (ENVIRONMENT_IS_NODE) {
// Expose functionality in the same simple way that the shells work
print = function(x) {
diff --git a/tests/hello_world.js b/tests/hello_world.js
index e6fcf070..ae86bfab 100644
--- a/tests/hello_world.js
+++ b/tests/hello_world.js
@@ -6,6 +6,11 @@ var ENVIRONMENT_IS_WEB = typeof window === 'object';
var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+if (!ENVIRONMENT_IS_NODE) {
+ // Node needs these in the global scope, everywhere else, cleaner to not pollute the global scope
+ eval('var print, printErr, read, load, arguments_;');
+}
+
if (ENVIRONMENT_IS_NODE) {
// Expose functionality in the same simple way that the shells work
print = function(x) {
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index a0595b88..c2fcee43 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -13,6 +13,11 @@ var ENVIRONMENT_IS_WEB = typeof window === 'object';
var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+if (!ENVIRONMENT_IS_NODE) {
+ // Node needs these in the global scope, everywhere else, cleaner to not pollute the global scope
+ eval('var print, printErr, read, load, arguments_;');
+}
+
if (ENVIRONMENT_IS_NODE) {
// Expose functionality in the same simple way that the shells work
print = function(x) {