docs: WebAssembly build instructions #40541

Adds build instructions for the experimental WASM (`wasm32-emscripten`) target
under the Cross-compiling section of `BUILD.md`.
This commit is contained in:
Rawan Khalid
2026-07-02 13:07:53 -04:00
committed by GitHub
parent 25d33dd12b
commit 25d65d60b6
+20
View File
@@ -593,3 +593,23 @@ Also relevant for webassembly (WASM) build.
cross-compiling or "-Dhost=" (empty string) to assume that target binaries
can run on the host during the build process (e.g. if target is x86 on a
x86_64 system, or if emulation set up with binfmt or similar)
### WebAssembly (experimental)
Neovim can be cross-compiled to WebAssembly using the `wasm32-emscripten` target.
- Requires the [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) (`emsdk`).
- After installing and activating it, pass its sysroot to `-Demscripten-sysroot`, e.g. `$EMSDK/upstream/emscripten/cache/sysroot`.
To build the WebAssembly target:
```bash
zig build nvim_bin \
-Dtarget=wasm32-emscripten \
-Demscripten-sysroot=$EMSDK/upstream/emscripten/cache/sysroot
```
This currently produces:
- `nvim.wasm`, the WebAssembly module.
- `nvim.js`, the JavaScript loader generated by Emscripten.