sql-kit
sql-kit copied to clipboard
fix: Resolves issues breaking Swift Wasm builds for sql-kit.
Summary
This PR adds support for compiling sql-kit to wasm using the SwiftWasm sdk.
This PR is part of a larger effort by a company called PassiveLogic to enable broad support for SwiftWasm.
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
NIOCoreinstead of the broaderNIO.
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
- [x] Verified unit tests still pass with these changes
- [x] Verified
swift buildcompletes without errors - [x] Verified no new compiler warnings are added with these changes
- [x] Verified
swift build --swift-sdk wasm32-unknown-wasicompletes without errors, when using a compatible nio version. - [x] Verified
swift build --swift-sdk wasm32-unknown-wasip1-threadscompletes without errors, when using a compatible nio version. - [x] 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 - [x] 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.