-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
using:
emcc (Emscripten gcc/clang-like replacement) 1.39.16 (9ecd579)
with a specific combination of flags:
emcc -s WASM=0 -s LEGACY_VM_SUPPORT=1 -s EXPORT_NAME="Hello" -s MODULARIZE=1 hello.c -o hello.js
produces an unusable js file. hello.c is the standard hello world and I test it with
var Hello = require('./hello.js')
Hello()
and what happens is
Module['ready'] = new Promise(function(resolve, reject) {
^
TypeError: Promise is not a constructor
at /home/reighley/Code/misc/webasm/hello.js:32:19
at Object. (/home/reighley/Code/misc/webasm/test.js:2:1)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
at internal/main/run_main_module.js:17:11
The problem seems to be related to pull #10697
This pull replaced the Promise-like Module with a real Promise BUT
If you run the flag with both LEGACY_VM_SUPPORT=1 and WASM=0 it will break because it will try to polyfill Promise after Promise even though it is using Promise in the module definition. The polyfill Promise will shadow the real one even before the polyfill is defined.
If LEGACY_VM_SUPPORT=0 it won't try to polyfill because you have a new VM
if WASM=1 it won't need Promise at all because everything happens inside the .wasm file
but if both are set I die
ATTN : @lourd