sqlite-kit icon indicating copy to clipboard operation
sqlite-kit copied to clipboard

feat: Add support for wasm compilation when using an in-memory sqlite database configuration

Open scottmarchant opened this issue 1 month ago • 0 comments

Summary

This PR adds support for compiling sqlite-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 NIOAsyncRuntime for WASI platforms only, to work around the NIOPosix dependency (which does not compile to wasm).
  • Conditionalizes the usage of NIOPosix using canImport
  • Update swift-nio dependency to a version that supports the WASI platform.

Testing done

  • [x] Verified unit tests still pass
  • [x] Verified no new warnings are created
  • [x] Verified swift build --swift-sdk swift-6.3-DEVELOPMENT-SNAPSHOT-2025-12-07-a_wasm --target SQL completes without errors. This is the latest daily snapshot of the swift toolchain.
  • [x] Verified a third-party executable can build this library as part of a larger wasm executable, and run sqlite in the browser.
  • [x] Verified these changes compile in CI. The exception is a dependency check, which can't be completed until dependent PR's in async-kit and sqlite-nio are merged. See https://github.com/PassiveLogic/sqlite-kit/actions/runs/20180692292/job/57940103176?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

No known impact risk

PR Dependencies

The following PR's must be merged and released before this PR can be reviewed and merged. It will remain in draft state until then.

https://github.com/vapor/sqlite-nio/pull/98 https://github.com/vapor/async-kit/pull/111

scottmarchant avatar Dec 12 '25 22:12 scottmarchant