Idea: use caxa-like idea to package bb itself + sources into executable
Closed this issue · 5 comments
See https://www.youtube.com/watch?v=JRwxx2jc2zU&t=1186s&ab_channel=LeandroFacchinetti for how caxa works.
I've used caxa to produce a self-contained executable from an nbb app:
https://github.com/babashka/nbb/tree/main/doc/caxa
Perhaps we could port caxa to something that works with babashka and then the GraalVM step could be made optional.
Feel free to convert this issue to a Discussion once you have enabled Discussions on this repo.
Oh, hey, it already works!
$ echo '(println "Hello world!")' > foo.clj
$ bash <(curl https://raw.githubusercontent.com/babashka/babashka/master/install) --version 0.7.6-SNAPSHOT --dir .
$ ./bb foo.clj
Hello world!
$ npx caxa --input . --output hello -- "{{caxa}}/bb" "{{caxa}}/foo.clj"
npx: installed 96 in 4.544s
$ ./hello
Hello world!
Oh nice that's a cool idea! I hadn't come across caxa before, but have been playing with a similar approach in another project I'm getting ready to release (https://github.com/nikvdp/1bin). Since it seems caxa can package more than just nodejs apps seems worth investigating as a replacement for warp (the tool I'm using in 1bins) with too.
Might be interesting to add an extra build-caxa
task to the bb.edn
in this repo that can build a babashkabin through caxa if node/npx is present.
Seems like with the caxa approach it might even be possible to package up any babashka pods used by an app into the resulting binary which would be pretty nifty. (actually now that I think of it I wonder if the GraalVM approach used thus far supports pods, I haven't actually tested that 😂 !)
FWIW, my cli-matic PR also got merged, so it's now compatible with babashka too.
excellent, will be a pleasure to remove that rather hairy macro this was relying on previously