oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.3k stars 2.69k forks source link

Add support for relevant cli flags (and bunfig) to single-file executables #8927

Open infrahead opened 7 months ago

infrahead commented 7 months ago

What is the problem this feature would solve?

Currently unable to set smol mode for example, or get bunfig.toml to apply at all, when running a compiled binary.

What is the feature you are proposing to solve the problem?

When runtime compiled to single-file executable will look for --smol and --config arguments (and perhaps --define and --port also relevant in this context). While there will be no way to separate bun args from any other process args, I think this is acceptable for these small number of documented flags.

What alternatives have you considered?

Less desirable would be documented env vars to achieve the same.

paperdave commented 7 months ago

i like this idea a lot, perhaps something like --compile --compile-exec-argv "--smol" to mirror process.execArgv. maybe something else.

i don't think it would be too incredibly difficult, just not super duper easy

infrahead commented 7 months ago

What about --compile --compile-config=example.toml, where example.toml can be a bunfig with the top-level/runtime settings.

Although now I'm wondering if the right approach is "baking this in" as we are discussing here, or if you'd want to be able to change things like smol and especially logLevel on existing executables. i.e. bun build --compile --outfile example and then ./example --logLevel=debug or ./example --bunfig=example.toml