Life of a Zed Extension: Rust, WIT, Wasm
Zed extensions are written in Rust but never compiled on the user's machine. A CI step in the zed-industries/extensions repository runs a small extensions CLI that compiles each extension's Rust code to a Wasm component targeting wasm32-wasip1 and its Tree-sitter grammars to Wasm. It packages them with Tree-sitter query files into an archive plus a manifest.json, uploads both to S3, and zed.dev mirrors the manifests into a database for the in-editor extension list. The extension API is a hand-written Rust trait layered over types that wit_bindgen generates at compile time from WIT definitions, so the WebAssembly Component Model can pass strings, records and resources like Worktree between the Wasm module and the Zed host.
Related posts
- Extensible Language Support in Zed - Part 1
Zed mediumAdeptZed loads third-party Tree-sitter grammars as WebAssembly modules using a hybrid design. Native code consumes the parser's static parse tables after they are copied out of wasm linear memory, while only the lexing functions, including hand-written external scanners, run inside Wasmtime. This avoids depending on the user's C compiler and keeps buggy scanners from crashing the editor. It also avoids copying large syntax trees out of wasm memory on every keystroke. A new `WasmStore` API lets wasm-loaded languages behave identically to native ones, and a bundled mini-libc with a bump allocator that is reset each parse makes scanner memory leaks impossible.
- wasmbuild - Using Rust in Deno and Web Apps
Deno mediumAdeptwasmbuild is a Deno-run CLI script that compiles Rust crates to WebAssembly via wasm-bindgen, generates JavaScript glue code with multiple loader strategies and lazy instantiation, and optimizes output with wasm-opt. Unlike wasm-pack or wasm-bindgen-cli, it needs no globally installed tool beyond the Rust toolchain and Deno, and it targets Deno and browsers specifically. A walkthrough scaffolds a crate with `deno task wasmbuild new`, builds an `add` function, and calls it from Deno, a browser page, and Deno Deploy. URL-based Deploy deployments don't yet work because the .wasm file isn't part of the module graph.
- Intro to Wasm in Deno
Deno mediumAdeptDeno 2.1 lets Wasm modules be imported directly like JavaScript modules, with their exports understood and typechecked. A hand-written WAT `add` function is compiled with wat2wasm and imported into Deno. The second example uses the wasmbuild CLI, which wraps wasm-bindgen, to scaffold a Rust crate and generate JS glue, .d.ts types and a .wasm binary, so Rust functions and structs can be called from JavaScript. Production use typically compiles Wasm from Rust, C++ or Go rather than writing WAT by hand.
- Introducing Ruvy
Shopify Engineering mediumAdeptRuvy is an open-source toolchain built on ruby.wasm that compiles Ruby scripts into WebAssembly modules, pre-initializing the Ruby VM and preloaded Ruby files at build time instead of at startup. Compared with ruby.wasm plus wasi-vfs, Ruvy modules instantiate and run about 20% faster (roughly 44 ms vs 56 ms in Wasmtime) and compile to native code with Cranelift about 70% faster (about 0.45 s vs 1.65 s). Because the script is embedded, Ruvy modules need no WASI arguments at runtime, which suits edge platforms that can't pass them. Ruvy is currently built from source, and contributions are invited, including Shopify Functions compatibility work.
- We Have to Start Over: From Atom to Zed
Zed easyNoviceZed's co-founders explain why they abandoned Atom's Electron/JavaScript stack and rebuilt a code editor in Rust: JavaScript's pointer-chasing arrays, uncontrollable GC pauses, and the costly JS/C++ boundary for multithreading made performance work feel like fighting the platform. Rust's ownership model pushed them toward a copy-on-write B-tree (SumTree) rope built on Arc, letting snapshots move to background threads in O(1), and high-level Rust code cut a find-all-matches operation from 1s to 4ms. GPU rendering with custom shaders and signed distance fields came out of necessity after Pathfinder proved too slow. Owning the stack (Tree-sitter, GPUI) lets them change anything, such as adding WASM language extensions, at the cost of building more themselves.