diff --git a/BUILD.md b/BUILD.md index 77deac1d4c..b0a59460ce 100644 --- a/BUILD.md +++ b/BUILD.md @@ -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.