Live Preview: Build and Test Workers Faster with Wrangler CLI 1.2.0
Matt Alonso, an intern on the Workers Developer Experience team at Cloudflare, worked to improve the Wrangler CLI for Cloudflare Workers. The Wrangler tool aims to make developing and publishing Workers projects a pleasant experience for all users. Alonso noticed that while testing with "wrangler preview" was fast, it opened multiple tabs, leading to messy results. To address this issue, he developed a feature inspired by `webpack-dev-server` and other similar watch-and-build tools, allowing for a single tab that refreshes live with the latest changes. The solution involved using Rust's notify crate for file system event monitoring and implementing a cooldown period to prevent wasteful builds. Additionally, Alonso used WebSockets for communication between the Wrangler CLI and previewer, working closely with the Workers UI team and security team to ensure proper implementation and protection from script content exposure. The Live Preview feature was released in Wrangler 1.2.0 under "wrangler preview --watch" and works for all types of Wrangler projects, including those using WebAssembly.
Company
Cloudflare
Date published
Aug. 19, 2019
Author(s)
Matt Alonso
Word count
716
Hacker News points
None found.
Language
English