honojs / hono

Web framework built on Web Standards
https://hono.dev
MIT License
18.98k stars 539 forks source link

Bunjs support #344

Closed ansarizafar closed 2 years ago

ansarizafar commented 2 years ago

Is there any plan for Bunjs support https://bun.sh/

yusukebe commented 2 years ago

Yes, or most are already done! Because Bun has Web standard API such as Request and Response like a Cloudflare or Deno. I've tried to run the minimal app using Hono on Bun. It works well! You can run the same script:

https://gist.github.com/yusukebe/0822c1629fc05027dcc8302ddaafc932

Maybe some middleware such as jsx are not working now (Currently, JSX Pragma is not supported on Bun). But, almost are working.

You will be able to start using Hono right away if you want. And the day of support for Bun completely is coming soon.

ethndotsh commented 2 years ago

While attempting to use your demo, I found that if you try to return/res json that it breaks. Very important in my opinion, so it should be looked into. Here is my code: https://gist.github.com/cursecodes/ace9e61658b95aa4dc2d99e4fd6bffbd

yusukebe commented 2 years ago

Hi @cursecodes

Try to write return:

app.get("/", (c) => {
  return c.json({ message: "Hello Bun!" });
});
ethndotsh commented 2 years ago

Haha yes I was missing that. Unfortunately, this did not fix it.

yusukebe commented 2 years ago

Hi @cursecodes

This code works well in my environment. I can't reproduce your error.

import { Hono } from 'hono'

const app = new Hono()

app.get('/', (c) => {
  return c.json({ message: 'Hello Bun!' })
})

export default {
  port: 3000,
  fetch: app.fetch,
}

// Run the script on bun
// bun run ./hello.ts
samatzp commented 5 months ago

$ bun run --hot src/index.ts error: Cannot find module "hono/dist/hono-base.js" from "C:\Users\PC\Downloads\my-dev\bun-hono-test\my-bun\node_modules\hono\dist\hono.js"

but hono-base.js is available in node-modules

andresito87 commented 1 month ago

Hi, I got the same problem and I could fix it, following those steps: