| Summary: | Unexpected 'var' resolution in module | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Tzvetelin Vassilev <tzvetelin.vassilev> |
| Component: | JavaScriptCore | Assignee: | 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 | ||
That's correct behavior. module's global scope is Module lexical environment. Not global scope. |
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.