Open ghivert opened 2 months ago
Oh that's interesting, thanks for bringing this up!
I have been thinking about the exit behaviours and I wonder if I should have glint return a result or exit code rather than exiting on its own, that would let the user determine what behaviour best fits for them and then removes any target-specific code from glint
How does the typing of that new exit function work? I would need to modify it so that glint returns a result I think?
After more thoughts, I think the best would be to simply return a Result(a, Error)
and let the user handle the value as you suggest.
In the CLI, we can probably just use the exit function I wrote and return null
instead of gleam.Error
. So the typing will be the same. Node always make sure that running Promise finishes before shutting down the process. So it will ensures process.exit
will be called.
Hi! Thanks for glint, the package is really nice!
I'm wondering about embedding of a gleam runtime in frontend. Currently, when targeting JS, the compiler will output a
import * as process from 'node:process'
in glint. This means that even if you don't use any functions from glint, the code will crash in browser. Do you think there's a way to avoid this? 🙂To give a little more context, my idea would be to present only one package, that could be used as a CLI or programmatically, whether in Node/Deno/Bun or in browser. I.e. a universal package, able to be used everywhere.
For example, I'm wondering if we could modify the
exit
function (which is the only one that requiresnode:process
) to something like:In Node & other runtimes, it would not change anything (because
process.exit
would be called everytime), while in browser it will return anError
in Gleam.