Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run bare rust CLI binary, no node #88

Closed
alexeagle opened this issue Sep 23, 2022 · 8 comments · Fixed by #158
Closed

Run bare rust CLI binary, no node #88

alexeagle opened this issue Sep 23, 2022 · 8 comments · Fixed by #158
Labels
enhancement New feature or request funding needed Contribute to https://opencollective.com/aspect-build help wanted Aspect isn't prioritizing this, but the community could

Comments

@alexeagle
Copy link
Member

It's slow to start a NodeJS process for every spawn of swc, and it's extra weight to send to remote execution service.

SWC has a binary codenamed "swcx" which is the bare Rust binary without the node binding. This should be suitable for use in Bazel.

#57 has some longstanding WIP for this, but it needs a sponsor to fund the rest of the work.

@alexeagle
Copy link
Member Author

Note, https://github.com/swc-project/swc/releases/tag/v1.3.25 contains all of @realtimetodie fixes so we should be unblocked now.

@alexeagle
Copy link
Member Author

#57 has landed, thanks @realtimetodie

@binoche9
Copy link

binoche9 commented Jan 31, 2023

Hi, I noticed that this changed removed the @aspect_rules_swc//swc:cli target even though it's still referenced in the documentation for using rules_swc in a custom rule

Is using rules_swc in a custom rule no longer supported, or is there some other cli tool exposed through rules_swc that I can use for a custom ctx.actions.run()?

update: I think I'm able to get it working with ctx.toolchains["@aspect_rules_swc//swc:toolchain_type"].swcinfo.swc_binary but probably worth updating the documentation

@realtimetodie
Copy link
Contributor

@binoche9 I'm sorry. This is only a documentation error. The Bazel target was renamed to -> @aspect_rules_swc//swc:swc_compile.

rules_swc/swc/defs.bzl

Lines 18 to 20 in ee7ca02

swc_compile = rule(
doc = """Underlying rule for the `swc` macro.

The reason is, that the Bazel rule implementation only uses the compile command of the SWC cli. I think this is more sound.

In the future, there will also be a Bazel @aspect_rules_swc//swc:swc_bundle target and a Bazel @aspect_rules_swc//swc:swc_minify target, but these features are not yet implemented in the Rust-based SWC cli.

https://github.com/swc-project/swc/blob/61397267bbd672fabd83baba0f9980e3d1d84ccf/bindings/swc_cli/src/commands/bundle.rs#L10

https://github.com/swc-project/swc/blob/61397267bbd672fabd83baba0f9980e3d1d84ccf/bindings/swc_cli/src/commands/minify.rs#L10

@binoche9
Copy link

Yeah I believe that should give me enough to work with for now. Thanks for the quick response!

@alexeagle
Copy link
Member Author

reopened since I think the doc fix wasn't right.

@binoche9
Copy link

binoche9 commented Feb 1, 2023

Actually I'm still seeing no such target '@aspect_rules_swc//swc:swc_compile': target 'swc_compile' not declared in package 'swc' - it seems that swc_compile (in swc/defs.bzl) isn't exposed in swc/BUILD.bazel?

@alexeagle
Copy link
Member Author

swc_compile is a rule, not a binary target.
Like the doc says "mimic swc/private/swc.bzl" - so you were right earlier, you need to lookup the swc toolchain and then get the swcinfo.swc_binary which will be a binary target in some external repo for the resolved platform.
https://github.com/aspect-build/rules_swc/blob/main/swc/private/swc.bzl#L202-L212

It does look like we should maybe expose the _swc_action function in the swc struct declared at the end of that file.

@gregmagolan gregmagolan moved this to 📋 Backlog in Open Source Feb 6, 2023
@gregmagolan gregmagolan added funding needed Contribute to https://opencollective.com/aspect-build and removed need: funding labels Feb 6, 2023
alexeagle added a commit that referenced this issue Feb 6, 2023
alexeagle added a commit that referenced this issue Feb 6, 2023
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Open Source Feb 6, 2023
@gregmagolan gregmagolan removed this from Open Source Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request funding needed Contribute to https://opencollective.com/aspect-build help wanted Aspect isn't prioritizing this, but the community could
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants