Wasm ESM integration does not seem to work with import/exporting wasm mutable globals
It seems to coerce the Wasm globals in the numbers (i.e. snapshots them), which seems to make exporting mutable globals and manipulating them from JS impossible.
@sbc100 I've implemented a fix for issue #25543 The issue occurs in two places:
- tools/extract_metadata.py - get_global_exports() only stores the numeric value of globals, losing mutability information
- tools/emscripten.py - create_global_exports() and create_receiving() don't handle mutable globals specially in ESM integration mode
I modified get_global_exports() to store both value and mutability in tools/extract_metadata.py:
tools/emscripten.py - Updated create_global_exports() to skip declaring mutable globals locally in ESM mode (they'll be imported from WASM instead)
Modified create_receiving() to import mutable globals from the WASM module in ESM integration mode
Before raising the PR, I'd like to understand your preferred testing approach
We do now support exporting mutable globals to JS since I landed #25530.
The issue described in this bug is that there is no way to export mutable globals from Wasm to JS under the ESM integration proposal. I don't think this something that emscripten can solve because its more of spec issue. See https://github.com/WebAssembly/esm-integration/pull/104
According to https://github.com/emscripten-core/emscripten/issues/25543 it seems like this issue is not something that is possible with the current ESM integration spec.