bun icon indicating copy to clipboard operation
bun copied to clipboard

Suggestion: Convert this to a Vercel Runtime package

Open TooTallNate opened this issue 2 years ago • 2 comments

Currently this repo provides a script that is invoked as part of the Project's Build script to compile an individual endpoint to the Build Output API.

It would be a better fit into the Vercel model to instead have this repo conform to the Runtime API. This would allow for the endpoints within the api directory to be configured to use this Runtime and vc build would automatically download + invoke this Runtime when the project is configured to do so. Example:

// in `vercel.json`
{
  "functions": {
    "api/*.ts": {
      "runtime": "[email protected]"
    }
  }
}

You could see the Deno Runtime (or any of the other repos in this vercel-community org) for inspiration on implementation.

TooTallNate avatar Sep 15 '23 17:09 TooTallNate

I think this is a good idea.

Bun has come a very long way since this issue has been raised, and there currently still is no way to run Vercel Functions in Bun. Next.js for example works flawlessly on Bun nowadays, so I think this repo should get more attention and also be converted to a real community runtime, like @TooTallNate suggested.

motz0815 avatar Apr 01 '25 07:04 motz0815

I used this repo, the patterns from the other community runtimes (especially Deno), and the bun-lambda package to create a proper Vercel custom runtime with the Runtime API Interface.

The code is here: https://github.com/johnny-woodtke/vercel-bun

I've deployed the example here: https://vercel-bun-nine.vercel.app

  • /api: https://vercel-bun-nine.vercel.app/api
  • /api/hello: https://vercel-bun-nine.vercel.app/api/hello?firstName=Johnny&lastName=Woodtke

As you can find in the README, and like @TooTallNate suggested, all you need to do to enable this Bun runtime is add a few lines to your vercel.json and add your serverless functions in your /api folder.

johnny-woodtke avatar May 23 '25 14:05 johnny-woodtke