From 84d0abd4d209765416be271431975f39fbffccc2 Mon Sep 17 00:00:00 2001 From: Scott Marchant Date: Tue, 24 Jun 2025 20:10:58 -0600 Subject: [PATCH 1/6] fix: Resolve issues breaking wasm build in sql-kit. Needed to require 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. --- Package.swift | 5 +++-- Sources/SQLKit/Exports.swift | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index 0dadd40a..fcc0b117 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,9 @@ let package = Package( dependencies: [ .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"), .package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"), - .package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0"), + // TODO: SM: Require a minimum swift-nio version once latest nio core fixes are versionized. + // .package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0.TBD"), + .package(url: "https://github.com/apple/swift-nio.git", branch: "main"), ], targets: [ .target( @@ -24,7 +26,6 @@ let package = Package( dependencies: [ .product(name: "Collections", package: "swift-collections"), .product(name: "Logging", package: "swift-log"), - .product(name: "NIO", package: "swift-nio"), .product(name: "NIOCore", package: "swift-nio"), ], swiftSettings: swiftSettings diff --git a/Sources/SQLKit/Exports.swift b/Sources/SQLKit/Exports.swift index 3fbde01f..370dd880 100644 --- a/Sources/SQLKit/Exports.swift +++ b/Sources/SQLKit/Exports.swift @@ -1,3 +1,3 @@ -@_documentation(visibility: internal) @_exported import protocol NIO.EventLoop -@_documentation(visibility: internal) @_exported import class NIO.EventLoopFuture +@_documentation(visibility: internal) @_exported import protocol NIOCore.EventLoop +@_documentation(visibility: internal) @_exported import class NIOCore.EventLoopFuture @_documentation(visibility: internal) @_exported import struct Logging.Logger From 75e28b6de7ea6f4c36670b9dc718c4aba639e1a1 Mon Sep 17 00:00:00 2001 From: Scott Marchant Date: Tue, 24 Jun 2025 20:32:50 -0600 Subject: [PATCH 2/6] fix: Don't require a bump in the minimum swift-nio version. 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. --- Package.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index fcc0b117..23398eaf 100644 --- a/Package.swift +++ b/Package.swift @@ -16,9 +16,11 @@ let package = Package( dependencies: [ .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"), .package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"), - // TODO: SM: Require a minimum swift-nio version once latest nio core fixes are versionized. - // .package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0.TBD"), - .package(url: "https://github.com/apple/swift-nio.git", branch: "main"), + // NOTE: Compiling to wasm requires specific versions of swift-nio. + // This older version is left as-is to avoid placing restrictions + // on other targets. But to compile for wasm, make sure you have + // a version of swift-nio with a passing build for the NIOCore module. + .package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0"), ], targets: [ .target( From f0c7fa6a9776def6db1c6d8a5490138f7d2389b1 Mon Sep 17 00:00:00 2001 From: Scott Marchant Date: Mon, 14 Jul 2025 11:15:40 -0600 Subject: [PATCH 3/6] refactor: Only elide the full NIO dependency if WASI is the target platform. Otherwise, leave exports and dependencies unchanged to minimize any disruption to downstream dependencies. --- Package.swift | 16 ++++++++++++++++ Sources/SQLKit/Exports.swift | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/Package.swift b/Package.swift index 23398eaf..fbb3f3e0 100644 --- a/Package.swift +++ b/Package.swift @@ -1,6 +1,21 @@ // swift-tools-version:5.10 import PackageDescription +let nonWASIPlatforms: [Platform] = [ + .macOS, + .macCatalyst, + .iOS, + .tvOS, + .watchOS, + .visionOS, + .driverKit, + .linux, + .windows, + .android, + // .wasi, // Everything but WASI + .openbsd, +] + let package = Package( name: "sql-kit", platforms: [ @@ -28,6 +43,7 @@ let package = Package( dependencies: [ .product(name: "Collections", package: "swift-collections"), .product(name: "Logging", package: "swift-log"), + .product(name: "NIO", package: "swift-nio", condition: .when(platforms: nonWASIPlatforms)), .product(name: "NIOCore", package: "swift-nio"), ], swiftSettings: swiftSettings diff --git a/Sources/SQLKit/Exports.swift b/Sources/SQLKit/Exports.swift index 370dd880..e72eae18 100644 --- a/Sources/SQLKit/Exports.swift +++ b/Sources/SQLKit/Exports.swift @@ -1,3 +1,8 @@ +#if os(WASI) @_documentation(visibility: internal) @_exported import protocol NIOCore.EventLoop @_documentation(visibility: internal) @_exported import class NIOCore.EventLoopFuture +#else +@_documentation(visibility: internal) @_exported import protocol NIO.EventLoop +@_documentation(visibility: internal) @_exported import class NIO.EventLoopFuture +#endif @_documentation(visibility: internal) @_exported import struct Logging.Logger From 26ec6d1d1272899ce4b8ba1a1125b9700dd6c066 Mon Sep 17 00:00:00 2001 From: Scott Marchant Date: Mon, 14 Jul 2025 11:28:09 -0600 Subject: [PATCH 4/6] chore: Update minimum required version of swift-nio to 2.84.0, which is a release containing the latest wasm compilation fixes. --- Package.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Package.swift b/Package.swift index fbb3f3e0..1961fcb6 100644 --- a/Package.swift +++ b/Package.swift @@ -31,11 +31,7 @@ let package = Package( dependencies: [ .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"), .package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"), - // NOTE: Compiling to wasm requires specific versions of swift-nio. - // This older version is left as-is to avoid placing restrictions - // on other targets. But to compile for wasm, make sure you have - // a version of swift-nio with a passing build for the NIOCore module. - .package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0"), + .package(url: "https://github.com/apple/swift-nio.git", from: "2.84.0"), ], targets: [ .target( From b7622d7c26b4dfb3861ce9fdc5b4eb48d25d7ebf Mon Sep 17 00:00:00 2001 From: Scott Marchant Date: Wed, 25 Jun 2025 13:19:05 -0600 Subject: [PATCH 5/6] ci: Adds wasm build to CI. --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e6713b7..ff277424 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,7 @@ jobs: secrets: inherit with: with_android: true + with_wasm: true pure-fluent-integration-test: if: ${{ !(github.event.pull_request.draft || false) }} From f0c57cbb53c838571d97a04839b8a6675fe604bb Mon Sep 17 00:00:00 2001 From: Scott Marchant Date: Mon, 28 Jul 2025 13:08:50 -0600 Subject: [PATCH 6/6] chore: Clean out backwards compatibility provisions for NIO implicit dependencies. Latest testing indicates this won't be breaking to scope down to just NIOCore. --- Package.swift | 16 ---------------- Sources/SQLKit/Exports.swift | 5 ----- 2 files changed, 21 deletions(-) diff --git a/Package.swift b/Package.swift index 1961fcb6..0812b450 100644 --- a/Package.swift +++ b/Package.swift @@ -1,21 +1,6 @@ // swift-tools-version:5.10 import PackageDescription -let nonWASIPlatforms: [Platform] = [ - .macOS, - .macCatalyst, - .iOS, - .tvOS, - .watchOS, - .visionOS, - .driverKit, - .linux, - .windows, - .android, - // .wasi, // Everything but WASI - .openbsd, -] - let package = Package( name: "sql-kit", platforms: [ @@ -39,7 +24,6 @@ let package = Package( dependencies: [ .product(name: "Collections", package: "swift-collections"), .product(name: "Logging", package: "swift-log"), - .product(name: "NIO", package: "swift-nio", condition: .when(platforms: nonWASIPlatforms)), .product(name: "NIOCore", package: "swift-nio"), ], swiftSettings: swiftSettings diff --git a/Sources/SQLKit/Exports.swift b/Sources/SQLKit/Exports.swift index e72eae18..370dd880 100644 --- a/Sources/SQLKit/Exports.swift +++ b/Sources/SQLKit/Exports.swift @@ -1,8 +1,3 @@ -#if os(WASI) @_documentation(visibility: internal) @_exported import protocol NIOCore.EventLoop @_documentation(visibility: internal) @_exported import class NIOCore.EventLoopFuture -#else -@_documentation(visibility: internal) @_exported import protocol NIO.EventLoop -@_documentation(visibility: internal) @_exported import class NIO.EventLoopFuture -#endif @_documentation(visibility: internal) @_exported import struct Logging.Logger