Skip to content

Conversation

@scottmarchant
Copy link

@scottmarchant scottmarchant commented Dec 12, 2025

Summary

This PR adds support for compiling async-kit to wasm using the Swift SDK for WebAssembly.

This PR is part of a larger effort by a company called PassiveLogic to enable broad support for Swift WebAssembly.

Details

  • Enables WASM compilation
  • Adds configuration to compile WASM in CI
  • Introduces conditional dependency on DispatchAsync for WASI platforms only, to work around the missing Dispatch support in the Swift SDK for WebAssembly
  • Removes all imports for NIOEmbedded and NIOPosix from the AsyncKit target. These imports are only used in the test target.
  • Update swift-nio dependency to a version that supports the WASI platform.

Testing done

  • Verified unit tests still pass
  • Verified no new warnings are created
  • Verified swift build --swift-sdk swift-6.3-DEVELOPMENT-SNAPSHOT-2025-12-07-a_wasm --target AsyncKit completes without errors. This is the latest daily snapshot of the swift toolchain.
  • Verified a third-party executable can build this library as part of a larger wasm executable, and run sqlite in the browser.
  • Verified these changes compile in CI. See https://github.com/PassiveLogic/async-kit/actions/runs/20180458445/job/57939351648?pr=1.

Usage notes

The current Swift 6.2.x breaks certain wasm executors that make testing wasm executables like this impossible. To fully test this running in the browser, recommend using Swift 6.3.x or later.

Impact Risk

If anyone depends solely on the removed exports for their documentation, their builds may break. But since NIOPosix and NIOEmbedded aren't used in the target anymore, it makes sense to remove those exports from the AsyncKit target.

@0xTim
Copy link
Member

0xTim commented Dec 12, 2025

@scottmarchant as mentioned in the other PR, we can't consider adding any dependencies until they hit at least a 1.0

@scottmarchant
Copy link
Author

@scottmarchant as mentioned in the other PR, we can't consider adding any dependencies until they hit at least a 1.0

@0xTim If the new wasm-only dependencies were released as version 1.0 or later, would there be any other issues regarding adding the new dependencies?

@scottmarchant
Copy link
Author

Per conversations with vapor core team, moving this to draft until a version of swift-nio is merged that supports the needed changes here. Please ignore changes pushed here while in draft. I'll mention reviewers in a comment once I move this back out of draft.

@scottmarchant scottmarchant marked this pull request as draft January 16, 2026 16:38
@scottmarchant scottmarchant force-pushed the feat/swift-wasm-support-v2 branch from f230f36 to 5a09ab7 Compare January 16, 2026 18:11
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.

2 participants