Support a portable WASI Preview 1 command-line build - #3997
Open
Matei02355 wants to merge 3 commits into
Open
Conversation
Matei02355
marked this pull request as ready for review
September 7, 2026 18:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.