Skip to content

Lasm 0.5.0

Choose a tag to compare

@github-actions github-actions released this 05 Nov 17:49
· 1509 commits to main since this release
e2e23e0

Lasm 0.5.0

A breaking release. Upgrade with npm install -D @lasm/cli@0.5.0; ^0.4.0 does not pick it up. Three changes need migration (below): Lasm.UI handlers run in the bubble phase, Attr.onWith is removed, and --output names the platform directory for edge, WASI and browser targets. Waits inside synchronous JavaScript callbacks now fail at once instead of hanging.

Breaking changes

  • Lasm.UI handlers run in the bubble phase. The applier now listens on the mount element in the bubble phase instead of the capture phase (docs/UI.md, "Event order"). A handler that stops propagation no longer keeps the event from its target's own listeners (including a web component's or widget's), from JavaScript listeners inside the app, or from the app's link routing; it still stops the outer Lasm handlers and listeners on the page around the app (document, window). The order changes: JavaScript listeners on the target and on elements inside the app now run before the Lasm handlers (as with React's root delegation), and a JavaScript listener inside the app that calls stopPropagation() now keeps the event from the Lasm handlers. Events that do not bubble (focus, blur, mouseenter, …) still reach their handler; their stopPropagation is no longer applied, since such an event goes no further than its target. In an application, a link whose handler stops propagation (without preventing the default) is now routed. Migration: code that relied on a Lasm handler running before JavaScript listeners inside the app should move that logic into Lean or listen in the capture phase.

  • Attr.onWith is removed. It has been the same as on since 0.4.0. Migration: Attr.onWith e d → on e d.

  • --output names the deployable directory for edge, WASI and browser targets. lasm build Main.lean --target workers --output DIR (likewise bun, deno, deno-deploy, supabase-edge, wasi, wasi-http, fastly, browser) now writes that target's directory to DIR. Without --output each target writes its usual directory in the project (workers/, bun/, wasi/, …), and no Node build is written to dist/: the Node build these targets relink stays in the build cache. vercel-edge and netlify-edge refuse --output, since the platform fixes their layout. node and the function platforms (lambda, vercel, …) are unchanged.

    Migration:

    • Drop --output from platform builds that used it to move the Node build out of the way (lasm build Server.lean --target workers --output dist/server → lasm build Server.lean --target workers), or keep it if you want the platform directory there and update your platform config (for example main in wrangler.toml).
    • If you ran or packaged the dist/ that a platform build wrote, build it explicitly: lasm build Main.lean --target node (or lasm build Main.lean under Node).
    • Delete a stale Node build left at a platform --output; Lasm refuses to replace it and says so.

Fixes

  • Lasm.JS: waits inside synchronous callbacks fail at once instead of never finishing. Inside a Function.ofSyncFn callback, waiting for a Lean task that makes host calls (including Async run with .block), or for a timer, DNS lookup or socket read started in the callback, used to hang the program. It now ends the callback with an error that says what it waited for, as soon as every other Lean thread waits too (JavaScript gets the error; a Lean try inside the callback cannot catch it). Value.await and the …Await forms still fail as errors the callback can catch. A wait for a task that needs nothing from Node still works, and Value.toTask without waiting no longer fails: the promise settles after the callback returns. Measured per-call costs (Lean→JS calls, synchronous callbacks, finished-task waits, promise awaits) show no slowdown.

Changes

Documentation

  • Bun, Deno and the edge: long Async loops. An Async loop (a recursion, for, List.mapM) of steps that complete at once overflows the JavaScript stack with RangeError: Maximum call stack size exceeded. Such steps are synchronous host calls, IO actions and pure values. The limit is about 2,000 steps on Deno and Workers and 8,000 on Bun; Node has no such limit. Awaited host calls are not affected. The limit and the workaround (Std.Async.sleep 0 every 100 steps, or fewer host calls) are now documented in docs/BUN_DENO.md, docs/EDGE.md and FUNDAMENTAL_LIMITATIONS.md (#90).

Testing (no change to how programs build or run)

  • Async loop depth in CI. The new async-depth job (differential.yml, scripts/ci/async-depth.mjs) measures the deepest Async loop on Node, Deno, Bun and workerd for each kind of step. It fails if a limit drops below half its measured value, or if the Std.Async.sleep 0 workaround stops completing 100,000 steps (#90).