stricli + bun single-file executable build = ❤️
inakiabt opened this issue · 4 comments
Is your feature request related to a problem? Please describe.
No
Describe the solution you'd like
It'd be great to add documentation on how to use bun's single-file executable build for generating a standalone binary of a stricli app.
Describe alternatives you've considered
No
Additional context
I've already tried it and it worked!
I had to install my cli's dependencies using bun
:
bun install --ignore-scripts
And then I followed the steps in bun's docs and that was all:
bun build src/bin/cli.ts --compile --outfile cli
./cli
USAGE
cavaco-cli subdir
cavaco-cli nested foo|bar ...
cavaco-cli --help
cavaco-cli --version
Stricli command line application
FLAGS
-h --help Print help information and exit
-v --version Print version information and exit
COMMANDS
subdir Command in subdirectory
nested Nested commands
@inakiabt Nice! I was able to do the same thing with deno compile
! The main issue in its current state is the size of the binary - a simple CLI I wrote with stricli
comes in at a whopping ~80MB.
The binary size isn't stricli
's fault, but seems like a byproduct of the way {bun,deno} compile
works under the hood. FWIW deno's hello world example comes in at ~58MB (re: blog).
Yeah, totally agree, stricli's default template compiled with bun is ~58MB. It seems like too much, but in some cases it could be better than having node installed + tons of MBs in node_modules
.
I share your enthusiasm for (as Node calls them) Single Executable Applications (SEA) - it's so cool how easy it is to encapsulate all of your business logic and dependencies in a single executable! A shame that they're on the large side at the moment, this is presumably mostly (citation needed?) the interpreter itself.
It looks like you didn't have to do anything specific to make Stricli work in either Bun or Deno, so I'm not sure that this is something that Stricli needs to document. If there were special steps/considerations needed then for sure we should document or remediate those. Can you confirm that it "Just Worked™"?
Hopefully this usage pattern is one that will stay simple! Closing for now