// In MODULARIZE mode we wrap the generated code in a factory function // and return either the Module itself, or a promise of the module. // // We assign to the `moduleRtn` global here and configure closure to see // this as an extern so it won't get minified. if (runtimeInitialized) { moduleRtn = Module; } else { // Set up the promise that indicates the Module is initialized moduleRtn = new Promise((resolve, reject) => { readyPromiseResolve = resolve; readyPromiseReject = reject; }); } #if ASSERTIONS // Assertion for attempting to access module properties on the incoming // moduleArg. In the past we used this object as the prototype of the module // and assigned properties to it, but now we return a distinct object. This // keeps the instance private until it is ready (i.e the promise has been // resolved). for (const prop of Object.keys(Module)) { if (!(prop in moduleArg)) { Object.defineProperty(moduleArg, prop, { configurable: true, get() { abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`) } }); } } #endif