-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Our Makefile.inc currently builds two outputs for each Emscripten module.
One, ModuleName.js, is the output produced by Emscripten with its MODULARIZE option switched on.
The other, ModuleName.umd.js, is the result of taking ModuleName.js, stripping out the module wrapper, and wrapping with a UMD module wrapper instead.
Unfortunately the scrappy shell script to strip out the Emscripten module wrapper is very fragile, and appears to have been broken (on my system) by a recent Emscripten update which added another couple of lines of boilerplate to the end of its module wrapper.
Why did we do this in the first place? Because the Emscripten module output "seemed like" a sensible choice for use when including the module into a web page, while the UMD output "seemed like" a sensible choice for use in Node. But UMD is supposed to work in a web page as well, so we could presumably instead run Emscripten without the MODULARIZE option and just add a UMD wrapper to that output, producing a single module that we can use everywhere.
There is another problem with that, which is that our UMD wrapper appears to be incomplete -- it doesn't contain anything to check for a browser context and add the module to the window object as might be expected.
Alternatively, maybe Emscripten has some other option that we aren't using, that would make it produce something suitable for both browser and Node itself.