Previously, the file we need to include with the build to enable the stack overflow sanitizer was written as a temporary file. This didn't happen though on watcher rebuilds with `carton dev` and caused crashes when a code line containing `try!` relying on this file to be present was executed.
I think it's easier and more efficient to bundle this file in the `static.zip` file that already includes our JS entrypoints. We require `static.zip` to be downloaded and unpacked successfully into `~/.carton/static` before every build anyway. It makes more sense to sense the sanitizer file in `~/.carton/static/so_sanitizer.wasm` and use that instead writing and deleting it at a temporary path on every build.
I've also updated the JSKit dependency and cleaned up some linter warnings by moving large tuple values into a separate `BuildDescription` type.
Resolves https://github.com/swiftwasm/carton/issues/42.
Also updates JavaScriptKit dependency to 0.9.0.
* Demangle and print Firefox stacktraces in terminal
* Update the entrypoints archive URL, rename file
* Add missing newline to `ProcessRunner.swift`
* Remove redundant `console.log` call from `dev.js`
* Detect destination env from `User-Agent` header
* Silence linter in tests where it can't be avoided
* Add support for basic testing in browsers
* Add a browser message on finish, shut down server
* Update JavaScriptKit to 0.9.0
Every Swift package with test targets has an implicit test product with `"\(package.name)PackageTests"` name. `swift build --build-tests` builds all products in a given package including the implicit test product. This doesn't work in situations where some of the products can't be compiled for Wasm, even when they are excluded with `condition: .when(platforms: [.macOS, .linux])` from test dependencies. This prevents tests from being built at all in such packages. OpenCombine is the primary victim of this problem.
Fortunately, the implicit test product can be accessed through the `--product` option passed to `swift build`. When using that option, only the test product and its dependencies are built. Products (and therefore their underlying targets) that aren't needed for tests are excluded from such builds. We should explicitly pass `--product` option to `swift build` instead of `--build-tests` in the `carton test` implementation to resolve the issue.
I've also added a new task to `tasks.json` that I previously used for testing `carton dev -v`.
`Dockerfile` has been updated to use the same toolchain as it does in `DefaultToolchain.swift`.
* Build only test product and its deps for testing
* Reuse product name interpolation
* Update `Dockerfile`
TTY terminal output is unavailable on CI, or when users redirect output to a file or a pipe. In those cases `TerminalController` initializer returns `nil`. SwiftPM has a wrapper `InteractiveWriter` class for it, which writes output to stdout directly in that case. I've copied that, and replaced all uses of `TerminalController` with it. A VSCode task is added to test that.
In my testing it looks like download progress reporting is quite spammy, so it now has `removeDuplicates` Combine operator added to make it output only when values differ significantly from each other.
Additionally, SDK installs can hit GitHub API rate limit on CI nodes, so `carton` now reads `GITHUB_TOKEN` environment variable, which gives much higher limits to authenticated API users.
We can now also run various `carton` commands on CI for basic end-to-end testing.
Resolves#112.
Allows passing a path to your custom `index.html` as `--custom-index-page` to `carton dev` and `carton bundle`. The entrypoint script is then injected into this file with a simple text substitution looking for a closing `</head>` tag. The assumption is that your custom `<body>` is not supposed to contain an unescaped `<head></head>`, and adding a dependency on a proper HTML parser to implement this injection is too costly.
Depends on #97.
Resolves#100.
New `bundle.js` entrypoint is added, which only differs from `dev.js` in the lack of the WebSocket hot reloading bit.
`wabt` and `binaryen` Homebrew dependencies are added as required for `wasm-strip` and `wasm-opt` respectively that reduce the resulting bundle binary size.
All resulting bundle files except `index.html` are named by their content hashes to enable [cache busting](https://www.keycdn.com/support/what-is-cache-busting).
Resolves#16.
Currently, when `carton dev` is launched in any subdirectory of the package not containing `Package.swift` it crashes. It's caused by `traverseRecursively` precondition failing when a non-directory (or non-existent) path is passed to it. I think `traverseRecursively` can handle non-existing paths well by returning an empty array, and the path itself when it's a file and not a directory. Thus the precondition check is not needed at all.
Non-existent paths were created due to a wrong assumption that the root package directory is always the current directory. This is now fixed by adding a new `inferManifestDirectory` function, which correctly calculates absolute paths of source directories before passing them to the watcher.
Additionally the watcher code in the `TSCBasic` code has its own precondition for non-empty path arrays passed to it. To avoid triggering it and staying extra-safe, we check for an empty watcher paths array and avoid watching anything at all.