I'm very delighted to announce that the first version of
carton is ready to use.
carton is a development tool for your SwiftWasm apps that watches your code, builds it when it changes, and serves the resulting WebAssembly binary via an HTTP server.
carton does not require any config files for these basic development scenarios, while some configuration may be supported in the future, for example for complex asset pipelines if needed. The only requirement is that your
Package.swift contains at least a single executable product, which then will be compiled for WebAssembly and served when you start
carton dev in the directory where
Package.swift is located.
The main motivation for
carton came after I had enough struggles with webpack.js, trying to make its config file work, looking for appropriate plugins. I'm convinced that the required use of
webpack in SwiftWasm projects could limit the wider adoption of SwiftWasm itself. Hopefully, with
carton you can avoid using
carton dev works relatively well in my projects, and it doesn't require Node.js to be installed (as compared to
webpack). You only need the official Swift 5.2 toolchain installed to build
carton itself, and the SwiftWasm toolchain to build your projects with
carton, see the installation guide for more details.
carton is built with Vapor, SwiftNIO, swift-tools-support-core, and OpenCombine, and supports both macOS and Linux. (Many thanks to everyone supporting and maintaining those projects!)
Since a subset of Foundation and XCTest already work and are supplied in the latest snapshots of SwiftWasm SDK, the next top priority for
carton is to allow running your XCTest suites directly in browsers and receiving test results back to the HTTP server, so that test results can be reported in CLI. This was blocked by
XCTest not allowing customized test report formats, which is now partially resolved with a new argument available on
XCTMain and a custom JSON test reporter. After a few other issues are resolved with the SwiftWasm toolchain, I'll get
carton test fully working with XCTest.
There are a few more commands on the roadmap to be implemented, such as
carton init for initializing basic SwiftWasm projects (potentially with configurable templates),
carton bundle to produce an optimized production deployment bundle, SwiftPM resources support for bundled assets,
carton sdk command for SDK installation and management and much more.
As cross-compiling to WebAssembly and running apps and tests remotely is not too dissimilar to Android development, or even development on macOS for Linux through Docker,
carton could potentially become a generic tool for cross-platform Swift developers. I'm not developing any Android apps currently, but if there are interested Swift for Android developers, I'd be very happy to review and merge their contributions enabling that.
As they say at certain events "we can't wait to see what you build with this". Any feedback, criticism and contributions are much appreciated!