Wasm Support

An update on the current status: if you don't care about binary size, it's more or less usable right now as in this demo. Swift can't run dead code elimination on unused protocol conformances yet, so the minimum produced binary size is ~10M raw and ~1.5M when optimized and compressed with 3rd-party tools, as tracked in swiftwasm/swift#7. Building with SwiftPM works, as long as you don't use Foundation or Dispatch due to a few technical reasons (swiftwasm/swift#592, swiftwasm/swift#658, swiftwasm/swift#647), but I hope that a minimalistic bare-bones subset of Foundation can alleviate that pain in the meantime.

Interacting with DOM works through JavaScriptKit built by @kateinoigakukun, also big thanks to him for the Game of Life demo. I honestly didn't expect that we actually have SwiftPM and DOM interaction working at this point before I saw the demo in action :star_struck:

swift test doesn't work yet, but I was able to get a subset of XCTest without expectations, waiters and parallel testing compiling, but not working yet due to a library path issue on Linux. I think I got it working on macOS, but need to verify that with a proper snapshot build. XCTest is one of my top priorities right now, as lack of XCTest blocks people from verifying how well their libraries work when compiled by SwiftWasm.

Overall, I think it's in the state now where any help from the community would be greatly appreciated. Everyone can now install the SwiftWasm toolchain and SDK locally with swiftenv and check if their package works. I hope to get a GitHub action with the toolchain preinstalled working ASAP so that people can start adding this to their CI. Now that upstream 5.3 has been branched, I'd like to start making 5.3 SwiftWasm snapshots, which hopefully converge to something stable by the time upstream Swift 5.3 toolchain is released. Upstreaming the changes would also tremendously help, as it would reduce the maintenance burden we have due to re-appearing merge conflicts. Technical writing and doing basic "DevRel tasks" is also something that would help a lot. I personally work on this full-time right now, but would be deeply grateful for any help and contributions.

Thanks for reading this :slightly_smiling_face:

56 Likes