emscripten-core / emscripten-core/emscripten
awkward structure in mjs build
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
mjs module looks like:
```js
var Module = (() => {
var _scriptDir = import.meta.url;
return (
async function(Module = {}) {
var Module = typeof Module != "undefined" ? Module : {};
// module stuff
}
);
})();
export default Module;
```
There are a few problems with this:
- Safari doesn't understands this and I truly believe the cause is a Safari bug (tested under Safari 16.4 MacOS / iOS)
- Default argument value assumes that argument is defined
- Hoisting doesn't work here, es module provides module scope
You could really name things better. The first Module actually is a factory that generates a Module, the second one is Module closure and the third one is the Module, which is the factory result.
Contributor guide
Assessment
This issue has not been assessed yet.