Skip to content

Commit 03e3e3c

Browse files
authored
feat(iroh-relay): Make the client side of iroh-relay compile & run in browsers (#3119)
## Description <!-- A summary of what this pull request achieves and a rough list of changes. --> Allows compiling and running `iroh-relay` in browsers (as long as the `server` feature is disabled). By default uses websockets to connect to relays when compiling for the `wasm32-unknown-unknown` target. If configured to `Protocol::Relay` specifically, it'll error out. Test it yourself: `cargo rustc -p iroh-relay --no-default-features --target=wasm32-unknown-unknown --crate-type=cdylib` ## Breaking Changes - iroh: `iroh-quinn` re-exports are now updated from version 0.12 to version 0.13 ## Notes & open questions **Note:** This updates *all* crate's versions to `iroh-quinn` 0.13! (Because we need them to be consistent between crates in this workspace.) ## TODO - [x] Add CI check to make sure the built .wasm is `(import "env" ...)`-free - [x] Need a new release of `iroh-quinn` with my browser PR in - [x] ~~**Blocking this from merging**: Need a new `netwatch` release with the `quinn-udp = "0.5.5"` version bound relaxed~~ it's already relaxed ## Change checklist - [x] Self-review. - [x] All breaking changes documented.
1 parent a8d058f commit 03e3e3c

File tree

20 files changed

+775
-563
lines changed

20 files changed

+775
-563
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,21 @@ jobs:
160160
- name: Add wasm target
161161
run: rustup target add wasm32-unknown-unknown
162162

163+
- name: Install wasm-tools
164+
uses: bytecodealliance/actions/wasm-tools/setup@v1
165+
163166
- name: wasm32 build (iroh-base)
164-
run: cargo build -p iroh-base --all-features --target wasm32-unknown-unknown
167+
run: cargo build --target wasm32-unknown-unknown -p iroh-base --all-features
168+
169+
- name: wasm32 build (iroh-relay)
170+
run: cargo build --target wasm32-unknown-unknown -p iroh-relay --no-default-features
171+
172+
# If the Wasm file contains any 'import "env"' declarations, then
173+
# some non-Wasm-compatible code made it into the final code.
174+
- name: Ensure no 'import "env"' in iroh-relay Wasm
175+
run: |
176+
! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/iroh_relay.wasm | grep 'import "env"'
177+
165178

166179
check_semver:
167180
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)