Building a better online editor for TypeScript
2 days ago
- #Deno
- #Cloudflare
- #TypeScript
- Val Town offers an integrated web editor for TypeScript automations and applications with fast deploys.
- The previous editor was buggy and slow, but now it's rewritten to be fast, accurate, and open-source.
- The old system ran TypeScript in a Web Worker, which struggled with Deno compatibility and NPM module sizes.
- The new system uses Deno Language Server (DenoLS) in cloud containers, improving performance and compatibility.
- DenoLS runs remotely, handling NPM dependencies server-side, reducing browser load.
- The architecture includes a WebSocket-based LSP protocol, inspired by existing solutions but optimized for Val Town.
- A custom CodeMirror LSP client was built to support WebSockets, external renderers, and callbacks.
- Cloudflare Containers are used for deployment, ensuring user isolation and session persistence.
- The solution leverages Cloudflare's durable objects for routing and lifecycle management without custom stateful routing.
- Future improvements include Val Town-specific language server features and diagnostics.
- The entire system is open-sourced as vtlsp, including client, server, and proxy components.