Description
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 requires node:process
) to something like:
export function exit(code) {
import('node:process').then(process => process.exit(code))
return new gleam.Error('process.exit')
}
In Node & other runtimes, it would not change anything (because process.exit
would be called everytime), while in browser it will return an Error
in Gleam.
Activity