Closed alexeagle closed 1 year ago
Okay this has been hard and I haven't found much focus time for it.
As far as I know, https://github.com/swc-project/swc/issues/5171 was the last bug preventing Bazel from using the pure-rust CLI.
We will have some rules_swc API changes:
integrity_hashes={"darwin-arm64": "sha512-DuB...
to be passed along with version number in WORKSPACE so users don't have to rely on our mirroringUpdate: it's still necessary to provide a fake tty to make the swcx binary accept a folder, now trying to make a tty_binary
rule in https://github.com/aspect-build/bazel-lib/pull/251
This keeps getting stuck because it's a side-project for me. We need some sponsorship for this work. Filed #88 so that the PR has an associated issue.
I'm working on this
Fixed an upstream bug, see https://github.com/aspect-build/rules_swc/issues/88
awesome, LMK if you'd like some help getting this rebased or anything
Yes, I already made a rebase in https://github.com/realtimetodie/rules_swc/tree/swc_rust and got bazel build //...
running with a custom swc cli and the changes from https://github.com/swc-project/swc/pull/6708. In addition, I found new bugs in the swc cli and will create subsequent PRs upstream.
bazel test //...
13 tests pass and 3 fail locally. All failed tests are related to the --output-dir
option of the swc cli compile command. It is due to the cwd. The cwd is set to the execroot directory and the swc cli can not find the auto-generated mock test files that are written into the bazel-out directory. But I think this might be related to my custom binary location, see
Test summary
//docs:update_test (cached) PASSED in 0.0s
//examples/custom_outs:tests_0_test (cached) PASSED in 0.1s
//examples/custom_outs:tests_1_test (cached) PASSED in 0.0s
//examples/macro:test_test (cached) PASSED in 0.0s
//examples/opaque_src:test_test (cached) PASSED in 0.1s
//examples/out_dir:check_outputs (cached) PASSED in 0.1s
//examples/paths:test_test (cached) PASSED in 0.1s
//examples/rc/src:tests_0_test (cached) PASSED in 0.1s
//examples/rc/src:tests_1_test (cached) PASSED in 0.0s
//examples/root_dir:check_outputs (cached) PASSED in 0.1s
//examples/simple:test_test (cached) PASSED in 0.1s
//examples/transitive:assertion_test (cached) PASSED in 0.0s
//swc/tests:versions_test_test_0 (cached) PASSED in 0.1s
//examples/directory:minify_test FAILED in 0.0s
//examples/directory:out_dir_test FAILED in 0.0s
//examples/filegroup:check_outputs FAILED in 0.0s
merry christmas
Fixed an upstream bug, see https://github.com/aspect-build/rules_swc/issues/88
The tests are now passing 🎉
hey @realtimetodie this is fantastic, I'm watching those upstream PRs. In theory we could use rules_rust to allow a from-source swc toolchain here, then users could point to an unreleased branch of swc (or they could vendor swc sources into their monorepo so they can make local modifications, though that's essentially a fork) That's probably not worth it though, the upstream maintainers are active and responsive so I bet you'll be able to get an official swc release that works 100% with Bazel.
Yes, the swc team is very responsive. The changes for symbolic links were merged upstream.
I refactored repositories.bzl. The binaries are now downloaded from GitHub releases instead from npm.
Node.js: All remaining rules_nodejs and npm artifacts were removed. Now, Node.js is only required to run some of the examples.
In addition, the rule accepts a dictionary to dynamically generate the swrc configuration file.
I added tests to validate that the generated configuration works
https://github.com/realtimetodie/rules_swc/tree/swc_rust/examples/rcdict
While doing all this, I oriented myself on the existing aspect-build rules and followed the general coding style.
Upgrade: The swc
macro is unchanged 🎉 and users do need to upgrade their targets.
As this is a breaking change, I used the opportunity to do some house cleaning (please bear with me).
I renamed the underlying rule from swc_transpile
-> swc_compile
. This matches the wording of the SWC project (I think the word "transpile" was originally inspired by the Node-based TypeScript compiler, but this is different in the SWC world).
Checklist
Breaking changes will be documented in the final PR.
Blocked by https://github.com/swc-project/swc/pull/6714
@realtimetodie SWC just cut a release that includes your last fix, so I think it's time to merge this!
@realtimetodie do you mind signing that CLA so I can include your commits without any fear of licensing issues?
signed
wow nice, the build is green let's goo
I'm doing another review/cleanup pass on it. The k8-fastbuild
is going to be a portability problem
https://github.com/aspect-build/rules_swc/pull/57/files#diff-d1df27564968f40aec96caf8b7e3f176263984b5c8f12dc418a9ea61a19f5073R18
The solution to obtain the bazel runfiles directory as an environment variable is very elegant, I like it
look for .swcrc in the package and use it if present, like we do for tsconfig.json in ts_project
This doesn't actually seem to work, if I drop the swcrc = ".swcrc"
attribute from an swc_compile
then it stops using the config file. I'll fix in a follow-up, doesn't really have to be in-scope here as it wasn't a feature before either.
BREAKING CHANGES:
swc_compile
matching the command we runswc compile ...