Skip to content

Web (wasm32): CI guard, shared launcher, cargo xtask web - #31

Merged
samitbasu merged 2 commits into
mainfrom
web-wasm
Nov 8, 2026
Merged

samitbasu merged 2 commits into
mainfrom
web-wasm

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

Closes #29.

What

  • CI guard: cargo xtask ci gains a wasm step (cargo check --target wasm32-unknown-unknown --lib --examples) and a clock step. The clock step fails on Instant or SystemTime in non-test library code, because both panic on wasm. ci.yml installs the target.
  • One launcher: common::launch(title, inner_size, ui_fun) runs eframe::run_ui_native on native and eframe's WebRunner on the bullseye_canvas canvas on wasm32. All 20 examples build for the web with no exclusions. Each example's main is the same code for both targets.
  • cargo xtask web NAME [--release] [--port N]: builds the example for wasm32, runs wasm-bindgen --target web into target/web/NAME/, writes an index.html, and serves it from a small std-only server inside xtask, which runs until Ctrl+C. Before building, it checks that the installed wasm-bindgen CLI matches the version pinned in Cargo.lock.
  • known_gaps scans no fonts on the web and shows its "no weighted faces" note.
  • Dependencies: one new wasm32-only dev-dependency, wasm-bindgen-futures. The library's own dependencies are unchanged.
  • Docs: README and CLAUDE.md say how to run an example on the web, and that browser try-outs are part of review for UI changes.

Not yet verified

The page itself has not been loaded in a browser. The dev machine's wasm-bindgen is 0.2.127 and the lock pins 0.2.130, so xtask web correctly stopped at the version check. To try it:

cargo install wasm-bindgen-cli --version 0.2.130 --locked
cargo xtask web todo        # then open the printed URL

Tests

  • Server: path-traversal refusal, MIME types, serving and 404, and the canvas id matching the examples'.
  • clock check: comments, test items, and resuming after a test module. It also asserts that the real library is clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up

samitbasu and others added 2 commits November 8, 2026 13:22
common::launch is the single place an example becomes an eframe app:
run_ui_native on the host, WebRunner on a canvas on wasm32. The examples
with their own loops (chat_shell, kaolin, todo, known_gaps, hello) and the
shared shell now end in it, so the two builds cannot diverge. known_gaps
scans no font directories on wasm and shows its "no weighted faces" note.

Only new dev-dependency: wasm-bindgen-futures, wasm32-only. The library's
dependencies are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
cargo xtask ci now checks the library and every example for
wasm32-unknown-unknown (ci.yml installs the target), and fails if non-test
library code names std::time::Instant or SystemTime, which panic in the
browser. The check is a built-in step with unit tests.

Add cargo xtask web NAME to try an example in the browser (#29)

Builds the example for wasm32, runs the wasm-bindgen CLI into
target/web/NAME/, writes an index.html with the canvas, and serves it from a
std-only static server in xtask until Ctrl+C (no child outlives xtask).
Refuses with the exact install command when wasm-bindgen is missing or does
not match the version Cargo.lock pins. README and CLAUDE.md document it and
make browser try-outs part of UI review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
@samitbasu
samitbasu merged commit 7a0f0e3 into main Nov 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web (wasm32) support: CI check and examples runnable in the browser

1 participant