Tooling, bundle & workers

Practical delivery concerns for Rust modules in the browser—not specific version pins (those change), but the decision space.

Overview

Editor WASM binaries can be large. You’ll combine compile-time opts (wasm-opt), load strategy (dynamic import()), and sometimes off-main-thread work for CRDT or heavy transforms.

Build & ship

  • wasm-pack / trunk — common entry points; align with your JS bundler (Vite, Webpack, etc.).
  • wasm-opt — shrink and speed; measure before and after for your real workload.
  • Source maps — keep for dev; strip for prod when size matters.

Bundle size & splitting

Lazy-load the editor WASM on routes that need it. Consider separating lightweight validation WASM from heavy layout if you truly have two tiers—two modules can be easier to cache than one monolith.

Workers & threads

Moving CRDT merge or parse work to a Web Worker keeps the main thread responsive. True shared-memory parallelism needs SharedArrayBuffer, which imposes cross-origin isolation (COOP/COEP) on your site.

Editor UI still needs selection sync on the main thread—workers are not a free pass for input latency; they help CPU-bound background tasks.

Browser constraints

Policies (CSP, COEP, third-party embeds) affect whether you can use threads or import WASM from CDNs. Validate against your deployment target early.