Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Deno 3 min read How-to mediumAdept

wasmbuild - Using Rust in Deno and Web Apps

wasmbuild 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.

Related posts

  • Intro to Wasm in Deno

    Deno mediumAdept

    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.

  • Deno 2.1: Wasm Imports and other enhancements

    Deno mediumAdept

    Deno 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.

  • Deno's Other Open Source Projects

    Deno easyNovice

    Deno 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 mediumAdept

    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.

  • Deno 1.12 Release Notes

    Deno mediumAdept

    Deno 1.12 adds Web Crypto key generation, signing and verification, server-side WebSocket upgrades via Deno.upgradeWebSocket on the unstable native HTTP server, and TypeScript transpilation plus automatic static-to-dynamic import conversion in the REPL. It also adds MessageChannel/MessagePort, streaming WebAssembly compilation and instantiation, SharedArrayBuffer and Atomics sharing between workers for WASM threading, and reliable WeakRef/FinalizationRegistry. Smaller changes include console piping to Chrome DevTools, test runner --shuffle and --fail-fast=N flags, per-fetch proxy configuration through Deno.createHttpClient, AbortSignal support in readFile, deprecation of Deno.copy, and an upgrade to V8 9.2.

The quest for software engineering knowledge.

Look:
Layout: