Skip to content

Commit

Permalink
Do a full UMD export when not in MODULARIZE mode (fix emscripten-core…
Browse files Browse the repository at this point in the history
…#5864)

Also provide .then() when in MODULARIZE_INSTANCE mode (emscripten-core#6442)
  • Loading branch information
curiousdannii committed Apr 25, 2018
1 parent c8d9b35 commit 5295cd3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
15 changes: 13 additions & 2 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ if (memoryInitializer) {
#endif

#if MODULARIZE
#if MODULARIZE_INSTANCE == 0

// Modularize mode returns a function, which can be called to
// create instances. The instances provide a then() method,
// must like a Promise, that receives a callback. The callback
Expand All @@ -142,7 +142,18 @@ Module['then'] = function(func) {
}
return Module;
};
#endif

// In MODULARIZE mode emcc.py will export the module in the proper place outside the wrapper
#else // MODULARIZE

if (typeof exports === 'object' && typeof module === 'object') {
module['exports'] = Module;
} else if (typeof define === 'function' && define['amd']) {
define([], function() { return Module; });
} else if (typeof exports === 'object') {
exports["{{{ EXPORT_NAME }}}"] = Module;
}

#endif

/**
Expand Down
3 changes: 0 additions & 3 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,6 @@ var MODULARIZE_INSTANCE = 0; // Similar to MODULARIZE, but while that mode expor
// a singleton instance. In other words, it's the same as if you
// used MODULARIZE and did EXPORT_NAME = EXPORT_NAME() to create
// the instance manually.
// Note that the promise-like API MODULARIZE provides isn't
// available here (since you arean't creating the instance
// yourself).

var BENCHMARK = 0; // If 1, will just time how long main() takes to execute, and not
// print out anything at all whatsoever. This is useful for benchmarking.
Expand Down
8 changes: 0 additions & 8 deletions src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,6 @@ if (ENVIRONMENT_IS_NODE) {

Module['arguments'] = process['argv'].slice(2);

#if MODULARIZE
// MODULARIZE will export the module in the proper place outside, we don't need to export here
#else
if (typeof module !== 'undefined') {
module['exports'] = Module;
}
#endif

#if NODEJS_CATCH_EXIT
process['on']('uncaughtException', function(ex) {
// suppress ExitStatus exceptions from showing an error
Expand Down

0 comments on commit 5295cd3

Please sign in to comment.