diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-22 14:26:28 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-22 14:26:28 -0700 |
commit | 22d510338239c1cf33136392c77a9b3d7d2ce2bc (patch) | |
tree | b2a697df7edd3cf9177a30e4de4f0940595142fc | |
parent | b040c0d6d4896017b1af268d0c89b7575cf3b343 (diff) |
fix file packager Module autocreation
-rw-r--r-- | tools/file_packager.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/file_packager.py b/tools/file_packager.py index 0696e4da..142702e2 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -627,8 +627,8 @@ if has_preloaded: ''' ret += ''' - if (typeof Module == 'undefined') Module = {}; - if (!Module['preRun']) Module['preRun'] = []; + var Module; + if (!Module) Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()'); function runWithFS() { ''' ret += code @@ -637,6 +637,7 @@ ret += ''' if (Module['calledRun']) { runWithFS(); } else { + if (!Module['preRun']) Module['preRun'] = []; Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it } ''' |