Skip to content

Conversation

scottmarchant
Copy link
Contributor

@scottmarchant scottmarchant commented Jun 25, 2025

These changes are now available in 3.33.1

Summary

This PR adds support for compiling sql-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

  • Removed unused NIO dependency in Package.swift. This repo compiles fine without that, but having it breaks wasm compilation.
  • Refined scope of exports to be NIOCore instead of the broader NIO.

Notes

  • Compiling to wasm requires specific versions of swift-nio. Because swift-nio still doesn't have wasm targets in it's CI, the wasm build breaks often. That issue will be resolved soon. Regardless, we don't want to bump the minimum nio requirement in the manifest, because that would be a breaking change for many using this repo. It is fine to leave the minimum nio requirement as-is. Developers trying to compile for wasm will almost certainly be aware of the issues compiling nio, and will soon have many wasm-compatible versions of nio to select.

Testing done

  • Verified unit tests still pass with these changes
  • Verified swift build completes without errors
  • Verified no new compiler warnings are added with these changes
  • Verified swift build --swift-sdk wasm32-unknown-wasi completes without errors, when using a compatible nio version.
  • Verified swift build --swift-sdk wasm32-unknown-wasip1-threads completes without errors, when using a compatible nio version.
  • Verified a third-party executable can build this library as part of a larger wasm executable using the command swift package --swift-sdk wasm32-unknown-wasip1-threads js --use-cdn
  • Verified these changes compile in CI, using yet-to-be merged additions to vapor's CI. See See https://github.com/PassiveLogic/sql-kit/actions/runs/15886122859/job/44798410586?pr=1

Impact Risk

There is a chance the changes to the manifest and exports could be a breaking change somewhere, if downstream dependencies relied on those pieces for their one and only intrinsic inclusion of the entire NIO dependency beyond NIOCore.

There are solutions to narrow the scope to just wasm compilation for those changes, if that is an issue. But I chose to leave them this way since it is a little cleaner solution.

… a newer version of swift-nio that supports wasm, and needed to narrow scope from the broad NIO dependency to the true dependency of just NIOCore.
Those compiling for wasm will need to find their own version of nio that compiles to wasm. In the near future, most latest versions of nio will compile to wasm, so this shouldn't be an issue.
@scottmarchant scottmarchant marked this pull request as ready for review June 25, 2025 02:43
@scottmarchant scottmarchant requested a review from gwynne as a code owner June 25, 2025 02:43
…atform. Otherwise, leave exports and dependencies unchanged to minimize any disruption to downstream dependencies.
…is a release containing the latest wasm compilation fixes.
…dependencies. Latest testing indicates this won't be breaking to scope down to just NIOCore.
@gwynne gwynne added the semver-patch Internal changes only label Jul 28, 2025
@gwynne gwynne changed the title fix: Resolves issues breaking Swift Wasm builds for sql-kit. Resolve issues breaking Swift Wasm builds for sql-kit Jul 28, 2025
@gwynne gwynne merged commit 0169d06 into vapor:main Jul 28, 2025
19 checks passed
@scottmarchant
Copy link
Contributor Author

scottmarchant commented Jul 29, 2025

Note, if anyone encounters issues with this change due to reliance on the sql-kit export of NIO, then after consuming this change, you may need to add the following import if previously relying on the implicit import.

import NIOCore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-patch Internal changes only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants