Bun support in Workers
Is it possible to use Bun as a runtime in CloudFlare worker? As I understand by now, no, it isn't: there is this discussion. But also there is this PR https://github.com/cloudflare/workers-sdk/pull/4065, which fixes this issue https://github.com/cloudflare/workers-sdk/issues/3941 and added "bun support" to wrangler, I suppose. So which is true? In what form Bun is supported now in Workers?
4 Replies
Only as a package manager. Not as a runtime
So is it possible then to run an identical backend code on CloudFlare Worker as serverless and local on Bun? Runtimes is different and it will be super easy to switch between them if needed.
So is it possible then to run an identical backend code on CloudFlare Worker as serverless and local on Bun?No. Workers do not, and might never, support Bun as a runtime. If you're developing workers locally, you should use wrangler, which uses the workers runtime (called workerd) under the hood. That being said, Bun does (afaik) generally try to stick to standard APIs such as fetch, which are also supported by workerd, so copying code over should work mostly, but having identical code will likely not work.
Thank you a lot!