Skip to content

Support a portable WASI Preview 1 command-line build - #3997

Open
Matei02355 wants to merge 3 commits into
sharkdp:masterfrom
Matei02355:wasi-command-line-2661-20260907
Open

Support a portable WASI Preview 1 command-line build#3997
Matei02355 wants to merge 3 commits into
sharkdp:masterfrom
Matei02355:wasi-command-line-2661-20260907

Conversation

@Matei02355

@Matei02355 Matei02355 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Add a wasi-application feature bundle for compiling bat's command-line interface to wasm32-wasip1 on stable Rust. It uses the existing Rust-only regex backend and embedded assets, without native pagers, Git, external preprocessors or asset rebuilding.

Separate native-only dependencies and I/O identification from the WASI implementation. Preserve circular input/output detection with safe rustix APIs, including the empty-input case. Resolve guest filesystem paths without path_abs's nightly-only WASI requirement. Use host-provided directory environment variables, retain lazy syntax mapping on the single-threaded runtime, and report an explicit error for forced paging.

Include a Node.js launcher, build instructions and a WASI runtime test suite. Add stable and MSRV build/runtime jobs to the existing CI gate. This targets the WASI Preview 1 command-line interface; it does not introduce a browser DOM API or promise compatibility with every iOS host. The existing regex-fancy backend's syntax compatibility limitations remain applicable.

Validation: compiled the actual wasm32-wasip1 executable with official Rust 1.91.1 and ran 28 checks under both Node.js 22.23.2 and 24's WASI runtimes, with each command in a separate host process, covering files, Unicode paths, stdin, CRLF, empty input, ten highlighting languages, line ranges, numbering, wrapping, configuration, missing files, forced-pager errors and circular-output protection. All 473 native all-feature tests passed (7 ignored), along with all-target/all-feature Clippy with warnings denied, the minimal library build, formatting and whitespace checks.

Fixes #2661.

@Matei02355
Matei02355 marked this pull request as ready for review September 7, 2026 18:10
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.

WASI / WASM support

1 participant