I've found an interesting behavior when using MODULARIZE=1.
Let's assume lib.js is our Emscripten build with MODULARIZE=1, then:
instance_1 = require('./lib')(); // Everything is good so far
instance_2 = require('./lib')(); //TypeError: require(...) is not a function
The things is that during initial call module.exports is overridden with plain Module without function wrapper.
I've stumbled upon this when writing tests for one project: initially library was called by wrapper code and then I needed to call few internal functions for testing purposes and called require() on module directly.
I've found an interesting behavior when using
MODULARIZE=1.Let's assume
lib.jsis our Emscripten build withMODULARIZE=1, then:The things is that during initial call
module.exportsis overridden with plainModulewithout function wrapper.I've stumbled upon this when writing tests for one project: initially library was called by wrapper code and then I needed to call few internal functions for testing purposes and called
require()on module directly.