I have a newly-published open source utility published by my employer, which is very exciting for me! It's a babashka pod, written in Typescript, which allows querying Neptune graph databases. Here is the link: https://github.com/SouthwestAir/queryblast
Wow, this might be the very first pod written in JavaScript / TypeScript! :)
Thanks! I'm very pleased about it! I would like to add this pod to the pod-registry, if at all possible
and I can see that I'll need to publish a release first, before I can add it to the pod-registry
so in any case, I still have a bit more work to do
but I'm very excited about today's milestone anyway!
so far the pod registry makes sense if you produce standalone binaries for several OS-es. I haven't really thought about how to combine this with JS
having manifests in the pod registry point you to where bb can download the binaries
I guess we could make something for "pod scripts" perhaps by just adding them to the classpath instead of doing it via the pod registry
not sure, haven't thought about this deeply
I've got this working locally now:
(require '[babashka.pods :as pods])
(pods/load-pod ".esbuild/.build/src/queryblast.js")
(require 'queryblast)
(prn (ns-publics 'queryblast))I tried compiling to a self-contained executable using bun and deno but their netstring libraries aren't working properly like the one in node, I think maybe a flushing issue or so
Ooh nice progress, thanks for your help & attention
this could be another way to do it on node but looks complicated: https://nodejs.org/api/single-executable-applications.html
Wow and using the code from yamlscript!
this tool works for sure, it even works for non-node script runners like babashka: https://github.com/AppThreat/caxa
works with caxa:
npx caxa --input .esbuild/.build/src --output mypod -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/queryblast.js"
(require '[babashka.pods :as pods])
(pods/load-pod "./mypod")
#_(pods/load-pod ".esbuild/.build/src/queryblast.js")
(require 'queryblast)
(prn (ns-publics 'queryblast))oh this is rad, I'll try this now
this yields a 34mb binary which is ok in the world of pods
(it just packages the node binary along with the script)
this just returns nil without any error, don't know if that is expected:
(prn (queryblast/query! "MATCH (n) RETURN n LIMIT 1"))
I haven't set any env varsthis is after you loaded it in the babashka repl, is that right?
just a script:
(require '[babashka.pods :as pods])
(pods/load-pod "./mypod")
#_(pods/load-pod ".esbuild/.build/src/queryblast.js")
(require 'queryblast)
(prn (ns-publics 'queryblast))
(prn (queryblast/query! "MATCH (n) RETURN n LIMIT 1"))Thanks for pointing that out, that nil response behavior could be improved with a usage string describing the required environment variables
I'll be making some changes, for producing the release binary and getting it ready to add to the pod registry, can I use this bb script and your other suggestions?
of course!
Thank you!
I think I know what's wrong when running the pod on deno. I ran into this with #nbb + bencode as well for nREPL: https://github.com/babashka/nbb/commit/5f800c95068b2ad4f02cbb13bbc01f157e4fb740 This thing here: https://github.com/isolomak/bencodec/blob/bd0ab57131bce2f2259e77f5866c9a6d663489c6/src/BencodeEncoder.ts#L70 doesn't work in deno. So perhaps if we change this we can compile to self-contained executables in deno.
Does Deno make a better binary than caxa? I'm only mildly familiar with Deno
don't know yet
I made a single JS file with esbuild and then compiled it to an exec with deno. This is just for the bencode demo.
$ ./standalone
5:hello
hello
The binary is 70mb, a bit biganyway it's good to have options
with bun I get:
57669360as the output size
last time I couldn't get either to work due to the bugfix above
with bun (and deno) it seems very easy to build multiplatform executables:
bun build --compile --target=bun-linux-x64 ./standalone.jsoh yeah in that case, since we'll need those executables on various platforms, this is a great step
thanks for making the MR!
I hope the maintainer takes note of it
or you could copy paste the compiled output into your project (disable the REPL button for more optimized code)
good suggestion
Within the next month or so, I want to have the project ready for inclusion in the pod registry
I'll be diving in as time allows
I was working on this today, but found that process.stdin.on() was not working the way I expected in bun
I recreated the project using bun init and I copied in the source file and the demo script, and I added my dependencies, and now I'm doing bun build --compile --target=bun-darwin-arm64 ./src/queryblast.ts
but when I run
#!/usr/bin/env ys-0
queryblast =: pods/load-pod('./queryblast')
I'm seeing it hang forever, seemingly as if there is nothing coming from stdinlet me try the bb script that you posted above in this thread
(require '[babashka.pods :as pods])
(pods/load-pod "./queryblast")
Puzzlingly, I'm seeing this hang forever when I run it in the bb repl