Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export Emscripten runtime for the Web (#509)
Some runtime environments look like Node.js, but are not Node.js which confuses Emscripten loader code. I'm talking about JavaScript bundlers that are used for Web and Electron apps. These things make the code believe that it can use "require()" for importing and "module.exports" for exporting things, and expect this be the case. However, Emscripten believes that it is smarter, detects that it's not running in Node.js environment, and just uses "Module" for exports. This breaks bundler's expectation and various Emscripten runtime functions (like "allocate()") end up not being exported, resulting in weird TypeErrors when WasmThemis code tries calling them. This can be avoided by exporting whatever Emscripten wants to export in Node.js style via "module.exports". We can insert this code into generated file by using "--pre-js" flag of emcc. Since now we have more than one file for Emscripten compilation, move them all into a subdirectory to keep the root directory tidy.
- Loading branch information