Menu
Cloudflare Blog·October 20, 2026

Building a Faster TypeScript Compiler with Rust and WebAssembly

Cloudflare and Owner.com are collaborating on tsrs, a Rust port of the TypeScript compiler, aiming for significant performance and memory efficiency improvements. This initiative focuses on leveraging Rust's strengths, particularly for WebAssembly environments like Cloudflare Workers, to enable faster development toolchains and broader deployment scenarios without forking the core TypeScript language.

Read original on Cloudflare Blog

Leveraging Rust for Compiler Performance

The tsrs project involves porting the TypeScript compiler to Rust, driven by the need for faster type checking and reduced memory consumption. Early benchmarks show tsrs to be up to 8x faster and use ~70% less memory than TypeScript 7.0. These performance gains are crucial for improving developer experience by reducing wait times and enabling more efficient development environments. The initiative maintains strict compatibility with the official TypeScript language, with the TypeScript team remaining in full control of language design.

Why Rust and WebAssembly?

While a previous Go port significantly improved TypeScript's speed, Rust offers distinct advantages, especially concerning WebAssembly (Wasm). Rust's memory management model is well-suited for Wasm, allowing for straightforward memory interactions between Wasm guests and hosts without the overhead of a garbage collector. This makes Rust a superior choice for memory-efficient Wasm deployments, critical for environments like Cloudflare Workers where small memory footprints lead to substantial cost and performance benefits.

  • Memory Efficiency in Wasm: Rust's ownership model avoids garbage collection overhead, making it ideal for compact Wasm modules.
  • Cloudflare Workers Integration: Enables running entire software build and deployment systems in tightly constrained, sandboxed environments.
  • Expanded Development Environments: Facilitates running full development toolchains client-side in browsers, on embedded devices, or IoT applications.
💡

System Design Insight

Choosing a language for core infrastructure components like compilers often involves trade-offs between development speed, runtime performance, and ecosystem integration. Rust excels in scenarios demanding high performance, memory safety, and efficient WebAssembly compilation, making it suitable for critical developer tooling and edge computing environments. Consider these factors when designing performance-sensitive systems, especially those destined for constrained or distributed execution contexts.

Maintenance and Collaboration Strategy

The tsrs project emphasizes close collaboration with the TypeScript team to ensure strict adherence to the language specification and contribute performance improvements upstream. A sophisticated automated process, inspired by Cloudflare's Vinext project, is used to maintain compatibility. This involves agents reviewing changes, fetching diffs, opening tracking issues, and regenerating compatibility matrices nightly by running the upstream test suite against tsrs. This approach minimizes divergence and ensures a healthy, open-source project.

TypeScriptRustWebAssemblyCompilerCloudflare WorkersPerformance OptimizationDeveloper ToolsOpen Source

Comments

Loading comments...