Intro to Wasm in Deno
Deno 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.
Related posts
- 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.
- Deno 2.1: Wasm Imports and other enhancements
Deno mediumAdeptDeno 2.1 lets Wasm modules be imported directly as ES modules. They join the module graph, are cached and type-checked, can import JS/TS modules, and no longer need read or net permissions. The release also starts the first LTS branch with six months of fixes. Other changes include `deno outdated` for JSR/npm dependency updates, embedding asset files in `deno compile` with V8 code caching (about 2x faster subsequent startups in their benchmark), stack traces in permission prompts via DENO_TRACE_PERMISSIONS, and `deno task` support for descriptions, parallel dependencies with cycle and diamond handling, and workspaces. CommonJS detection from package.json `type` improves Node compatibility.
- Roll your own JavaScript runtime, pt. 2
Deno mediumAdeptA custom JavaScript runtime built on deno_core gains three capabilities: a fetch op backed by the reqwest crate and registered in the runjs extension, a CLI that takes the script path as its first argument, and TypeScript/TSX support. TypeScript support comes from a custom TsModuleLoader that implements deno_core's ModuleLoader trait. It picks a MediaType from the file extension and uses deno_ast to parse and transpile TS, TSX and JSX into JavaScript before handing the module to JsRuntime. The whole runtime stays around 154 lines of Rust.
- Deno's Other Open Source Projects
Deno easyNoviceDeno publishes many MIT-licensed supporting libraries extracted from its runtime, most of them Rust crates. Highlights include rusty_v8 (zero-overhead Rust bindings to V8's C++ API), deno_core (ops and an event loop mapping JS Promises to Rust Futures), rust-urlpattern, import_map, eszip (a streamable single-file format for serialized module graphs, used by Deno Deploy), sui (embedding data in ELF/PE/Mach-O executables while keeping them code-signable), dnt (Deno-to-npm transform), wasmbuild, the monch parser combinator library, deno_task_shell, the flaky_test macro, and vnotify (detecting changes across millions of S3 objects via hashed notification keys). Most entries come with short usage examples.
- Life of a Zed Extension: Rust, WIT, Wasm
Zed mediumAdeptZed 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.