From 17be1563475e5a2d7a5e7c88c02061253669db5f Mon Sep 17 00:00:00 2001 From: Fraser Adams Date: Wed, 2 Oct 2013 19:59:27 +0100 Subject: fixed problem where module.exports, which is needed by node.js gets incorrectly minified by Closure. Simple change from module.exports = Module to module['exports'] = Module fixes this. Added simple test case compiling with --O2 -closure 1 to /tests/Module-exports --- src/shell.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/shell.js') diff --git a/src/shell.js b/src/shell.js index 7bfbe781..bb89ab6e 100644 --- a/src/shell.js +++ b/src/shell.js @@ -68,7 +68,9 @@ if (ENVIRONMENT_IS_NODE) { Module['arguments'] = process['argv'].slice(2); - module.exports = Module; + // Explicitly using associative array form instead of dot notation form prevents the closure compiler + // minifying the exports property, which is important if Module is to remain visible to node.js + module['exports'] = Module; } else if (ENVIRONMENT_IS_SHELL) { Module['print'] = print; -- cgit v1.2.3-70-g09d2 From 0c7ec24c3f7c50d90d3b6f32c941115fc0610984 Mon Sep 17 00:00:00 2001 From: Fraser Adams Date: Tue, 15 Oct 2013 18:14:40 +0100 Subject: removed comment in src/shell.js and explicitly called run_js with engine=NODE_JS as requested --- src/shell.js | 2 -- tests/test_other.py | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/shell.js') diff --git a/src/shell.js b/src/shell.js index bb89ab6e..be23b3c1 100644 --- a/src/shell.js +++ b/src/shell.js @@ -68,8 +68,6 @@ if (ENVIRONMENT_IS_NODE) { Module['arguments'] = process['argv'].slice(2); - // Explicitly using associative array form instead of dot notation form prevents the closure compiler - // minifying the exports property, which is important if Module is to remain visible to node.js module['exports'] = Module; } else if (ENVIRONMENT_IS_SHELL) { diff --git a/tests/test_other.py b/tests/test_other.py index 95e0afe4..de46098d 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -1931,8 +1931,8 @@ done. # Check that main.js (which requires test.js) completes successfully when run in node.js # in order to check that the exports are indeed functioning correctly. - for engine in JS_ENGINES: - if engine == NODE_JS: self.assertContained('bufferTest finished', run_js(path_from_root('tests', 'Module-exports', 'main.js'))) + if NODE_JS in JS_ENGINES: + self.assertContained('bufferTest finished', run_js(path_from_root('tests', 'Module-exports', 'main.js'), engine=NODE_JS)) # Delete test.js again and check it's gone. try_delete(path_from_root('tests', 'Module-exports', 'test.js')) @@ -1951,8 +1951,8 @@ done. # Check that main.js (which requires test.js) completes successfully when run in node.js # in order to check that the exports are indeed functioning correctly. - for engine in JS_ENGINES: - if engine == NODE_JS: self.assertContained('bufferTest finished', run_js(path_from_root('tests', 'Module-exports', 'main.js'))) + if NODE_JS in JS_ENGINES: + self.assertContained('bufferTest finished', run_js(path_from_root('tests', 'Module-exports', 'main.js'), engine=NODE_JS)) # Tidy up files that might have been created by this test. try_delete(path_from_root('tests', 'Module-exports', 'test.js')) -- cgit v1.2.3-70-g09d2