Bug 255396

Summary: Unexpected 'var' resolution in module
Product: WebKit Reporter: Tzvetelin Vassilev <tzvetelin.vassilev>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: mark.lam, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=223533

Tzvetelin Vassilev
Reported 2023-04-13 07:56:39 PDT
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.
Attachments
Radar WebKit Bug Importer
Comment 1 2023-04-20 07:57:21 PDT
Yusuke Suzuki
Comment 2 2023-04-20 09:23:26 PDT
That's correct behavior. module's global scope is Module lexical environment. Not global scope.
Note You need to log in before you can comment on or make changes to this bug.