Hmm, I also noticed a few additional details about the MAIN_MODULE=2 build that are not the case for the default option build.
1. Loading the JavaScript file will cause a warning in browsers
AnimalLibraryMainModule2.js:formatted:159 on the web, we need the wasm binary to be preloaded and set on Module['wasmBinary']. emcc.py will do that for you when generating HTML (but not JS)
shell_printErr @ AnimalLibraryMainModule2.js:formatted:159
abort @ AnimalLibraryMainModule2.js:formatted:7257
getBinary @ AnimalLibraryMainModule2.js:formatted:1604
doNativeWasm @ AnimalLibraryMainModule2.js:formatted:1642
Module.asm @ AnimalLibraryMainModule2.js:formatted:1719
(anonymous) @ AnimalLibraryMainModule2.js:formatted:6874
AnimalLibraryMainModule2.js:formatted:159 failed to compile wasm module: abort("on the web, we need the wasm binary to be preloaded and set on Module['wasmBinary']. emcc.py will do that for you when generating HTML (but not JS)") at Error
If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.
shell_printErr @ AnimalLibraryMainModule2.js:formatted:159
doNativeWasm @ AnimalLibraryMainModule2.js:formatted:1644
Module.asm @ AnimalLibraryMainModule2.js:formatted:1719
(anonymous) @ AnimalLibraryMainModule2.js:formatted:6874
2. All of the exports are set to undefined since Module["asm"](Module.asmGlobalArg, Module.asmLibraryArg, buffer); returns false. (which means var asm = false)
For example even expected exports like the following
var _ANM_CatCreateScottishFold = Module["_ANM_CatCreateScottishFold"] = asm["_ANM_CatCreateScottishFold"];
will end up setting _ANM_CatCreateScottishFold and Module["_ANM_CatCreateScottishFold"] to undefined which is pretty clearly not the intended behaviour.
I guess these will probably all be sorted out when shared modules are updated to work better with WASM. Still let me know if I should file another issue for this behaviour.
Thanks,
David