aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Pesch <inolen@gmail.com>2013-06-27 16:42:41 -0700
committerAnthony Pesch <inolen@gmail.com>2013-07-01 11:02:05 -0700
commit1f8cdac6b6e3bbc601b4bf955451790cabb4a469 (patch)
tree5b13479514806e885cc35deae64eb1bf15d148df
parent4d0be84d50307689f6b15f9f4502255736e522db (diff)
- Added MODULE_NAME setting to control global module export
-rw-r--r--src/jsifier.js4
-rw-r--r--src/settings.js3
-rw-r--r--src/shell.js10
3 files changed, 11 insertions, 6 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index d6cd188c..b13d39a3 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -44,7 +44,7 @@ function JSify(data, functionsOnly, givenFunctions) {
// things out as they are ready.
var shellParts = read(shellFile).split('{{BODY}}');
- print(shellParts[0]);
+ print(processMacros(preprocess(shellParts[0])));
var preFile = BUILD_AS_SHARED_LIB ? 'preamble_sharedlib.js' : 'preamble.js';
var pre = processMacros(preprocess(read(preFile).replace('{{RUNTIME}}', getRuntime())));
print(pre);
@@ -1749,7 +1749,7 @@ function JSify(data, functionsOnly, givenFunctions) {
print(postParts[1]);
var shellParts = read(shellFile).split('{{BODY}}');
- print(shellParts[1]);
+ print(processMacros(preprocess(shellParts[1])));
// Print out some useful metadata
if (EMIT_GENERATED_FUNCTIONS || PGO) {
var generatedFunctions = JSON.stringify(keys(Functions.implementedFunctions).filter(function(func) {
diff --git a/src/settings.js b/src/settings.js
index 3a91b488..39774690 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -376,6 +376,9 @@ var EMIT_GENERATED_FUNCTIONS = 0; // whether to emit the list of generated funct
var JS_CHUNK_SIZE = 10240; // Used as a maximum size before breaking up expressions and lines into smaller pieces
+var EXPORT_NAME = 'Module'; // Global variable to export the module as for environments without a standardized module
+ // loading system (e.g. the browser and SM shell).
+
// Compiler debugging options
var DEBUG_TAGS_SHOWING = [];
// Some useful items:
diff --git a/src/shell.js b/src/shell.js
index 873bcc65..1f987926 100644
--- a/src/shell.js
+++ b/src/shell.js
@@ -12,10 +12,6 @@ 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 (typeof module === "object") {
- module.exports = Module;
-}
-
if (ENVIRONMENT_IS_NODE) {
// Expose functionality in the same simple way that the shells work
// Note that we pollute the global namespace here, otherwise we break in node
@@ -50,6 +46,8 @@ if (ENVIRONMENT_IS_NODE) {
if (!Module['arguments']) {
Module['arguments'] = process['argv'].slice(2);
}
+
+ module.exports = Module;
}
if (ENVIRONMENT_IS_SHELL) {
@@ -68,6 +66,8 @@ if (ENVIRONMENT_IS_SHELL) {
Module['arguments'] = arguments;
}
}
+
+ this['{{{ EXPORT_NAME }}}'] = Module;
}
if (ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER) {
@@ -82,6 +82,8 @@ if (ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER) {
console.log(x);
};
}
+
+ this['{{{ EXPORT_NAME }}}'] = Module;
}
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {