Open Blankeos opened 4 months ago
this is not an issue in bun. you cannot use connect middleware directly with Bun.serve
. you should use express
or polka
or fastify
with @fastify/middie
After some experimenting, this one actually works: https://github.com/vikejs/vike-node/blob/main/packages/vike-node/src/runtime/adapters/connectToWeb.ts
it's by @nitedani. Here's my current code with working Bun + Vite HMR + Custom Websocket handler + Watching of backend changes (like in controllers).
Only caveats I noticed (reproducible in the above example):
bun run --watch server.ts
will cause an infinite loop when Vite.createServer
is called (Basically same problem as this https://github.com/oven-sh/bun/issues/5278#issuecomment-1816083713). So I'm using nodemon because it can exclude watching of other files).Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
What is the problem this feature would solve?
Since
Bun.serve
doesn't havehttp.Incoming
andhttp.ServerResponse
, I'm wondering how to implement an equivalent of this Node code in Bun.In Node:
What is the feature you are proposing to solve the problem?
Maybe an adapter for Bun.serve with
http.Incoming
andhttp.ServerResponse
if it's possible?What alternatives have you considered?
No response