Rust Rewrites HarmonyOS Builds: arkdown Cuts Cold Builds 8.4x and Memory 75%
HarmonyOS developers facing 10-minute cold builds and memory OOMs now have a Rust alternative that produces byte-identical packages to the official toolchain. arkdown's 75% memory reduction makes large builds feasible on 16 GB dev machines and constrained CI containers, and its npm/CLI interface drops into existing workflows without a separate runtime.
arkdown, an open-source Rust build toolchain for HarmonyOS, replaces the official Hvigor pipeline end-to-end: parsing ArkTS/TypeScript, type checking, UI syntax transformation, module bundling, Native C/C++ compilation, resource handling, ABC bytecode generation, and signing into HAP, HSP, HAR, and APP packages. It's built on OXC for parsing/AST/codegen, Rolldown for module graph scanning, and tsrs for TypeScript semantics—all modified to understand ArkTS's custom syntax and ArkUI DSL, with tsrs embedded in-process to eliminate subprocess IPC.
The payoff is measured on a real production app (11,627 TS files + 23 ETS files, with 1.5 GB of native debug symbols). Cold builds drop from 629.69s (Hvigor) to 75.36s with full type checking, or 62.94s with --skip-checker. Peak physical memory falls from 9.68 GiB to 2.39 GiB. The toolchain passes 37/37 strict output-parity fixture tests against hvigorw with zero allowlist, covering HAP, HSP, HAR, APP, hot-reload HQF, and ArkGuard obfuscation. It installs via npm and runs with a single npx command; a --enable-zig flag cross-compiles native code without extra config.
Remaining gaps: cross-process hot rebuilds are still slower than Hvigor (15-17s vs 5.96s) because Rolldown lacks a structured disk graph cache, and HAR signing still falls back to a Java jar. Both are on the roadmap. The author also plans to extend the codebase into millisecond-level formatters, linters, and LSP support for ArkTS in editors like Zed and VS Code.
The strict parity test suite (37/37 with no allowlist) is the credibility anchor; it forces the Rust implementation to match Hvigor output exactly, which is what makes the toolchain trustworthy for production installs.
Embedding tsrs in-process, instead of running a separate compiler process, eliminates IPC overhead and is a major reason for the memory and speed gains; this trend of avoiding subprocesses is likely to spread to other build toolchains.
The article shows that a JavaScript/TypeScript-based build pipeline deeply coupled to Node.js can be fully reimplemented in Rust, but only because ArkTS is a TS superset with strict syntax rules; the authors had to port 1,003 linter rules and 243 diagnostics to match exactly, a huge effort most tooling projects wouldn't attempt.
Hot rebuild performance is currently worse than Hvigor because the toolchain hasn't yet built a disk cache for the module graph; this is the classic tradeoff: a fresh Rust implementation can win on cold builds and memory, but incremental builds require good cache design.