Problem is observed with emscripten build. Generated Module looks in this way: // Module.mjs var Module = (() => { var _scriptDir = import.meta.url; return ( async function(Module = {}) { console.log(Module) // result is null, expected value is data var Module = typeof Module != "undefined" ? Module : {}; console.log(Module) // result is {} // emscripten stuff } ); })(); export default Module; After import like this: // index.mjs let factory = (await import("Module.mjs")).default await Module({/* data */}) Something is got wrong and Module value is lost.
<rdar://problem/108318013>
That's correct behavior. module's global scope is Module lexical environment. Not global scope.