Expose native and platform modules only when unix or windows#51
Merged
chipsenkbeil merged 1 commit intochipsenkbeil:mainfrom Jul 7, 2025
Merged
Expose native and platform modules only when unix or windows#51chipsenkbeil merged 1 commit intochipsenkbeil:mainfrom
chipsenkbeil merged 1 commit intochipsenkbeil:mainfrom
Conversation
cdmurph32
added a commit
to cdmurph32/typed-path
that referenced
this pull request
Jan 21, 2026
After PR chipsenkbeil#51 added the requirement `any(windows, unix)` to expose native and platform modules, and Rust changed WASI targets to set the `unix` cfg (rust-lang/rust#147572), typed-path now attempts to compile code using `std::os::wasi` for WASI targets. However, this is an unstable feature requiring `#![feature(wasip2)]` when targeting wasm32-wasip2. This commit adds the wasip2 feature flag conditionally only for wasip2 targets (target_env = "p2"), allowing the crate to compile with nightly Rust for wasm32-wasip2 while maintaining compatibility with wasm32-wasip1 which does not have or need this feature. Also fixes an unused import warning for `std::io` on wasm targets where the `absolutize` function (which uses `io`) is not available. Tested on both wasm32-wasip1 and wasm32-wasip2 targets - all 160 tests pass on both platforms.
cdmurph32
added a commit
to cdmurph32/typed-path
that referenced
this pull request
Jan 21, 2026
After PR chipsenkbeil#51 added the requirement `any(windows, unix)` to expose native and platform modules, and Rust changed WASI targets to set the `unix` cfg (rust-lang/rust#147572), typed-path now attempts to compile code using `std::os::wasi` for WASI targets. However, this is an unstable feature requiring `#![feature(wasip2)]` when targeting wasm32-wasip2. This commit adds the wasip2 feature flag conditionally only for wasip2 targets (target_env = "p2"), allowing the crate to compile with nightly Rust for wasm32-wasip2 while maintaining compatibility with wasm32-wasip1 which does not have or need this feature. Also fixes an unused import warning for `std::io` on wasm targets where the `absolutize` function (which uses `io`) is not available. Successfully tested on both wasm32-wasip1 and wasm32-wasip2 targets.
chipsenkbeil
pushed a commit
that referenced
this pull request
Jan 22, 2026
After PR #51 added the requirement `any(windows, unix)` to expose native and platform modules, and Rust changed WASI targets to set the `unix` cfg (rust-lang/rust#147572), typed-path now attempts to compile code using `std::os::wasi` for WASI targets. However, this is an unstable feature requiring `#![feature(wasip2)]` when targeting wasm32-wasip2. This commit adds the wasip2 feature flag conditionally only for wasip2 targets (target_env = "p2"), allowing the crate to compile with nightly Rust for wasm32-wasip2 while maintaining compatibility with wasm32-wasip1 which does not have or need this feature. Also fixes an unused import warning for `std::io` on wasm targets where the `absolutize` function (which uses `io`) is not available. Successfully tested on both wasm32-wasip1 and wasm32-wasip2 targets.
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.
The
nativeandplatformmodules assume that either windows or unix is a target. There are preexisting guards against exposing these modules when compiling with a wasm target, but there are other possible targets that are not either windows or unix (e.g. embedded targets). Currently, typed-path will not compile on these other targets.This PR requires that either windows or unix be a target when exposing the
nativeandplatformmodules.