Replies: 2 comments 1 reply
-
I'm afraid if there might be a misunderstanding, which I should have noticed earlier. btw, our internals don't even depend on Hono.
I'm not a big fan of it.
This sounds good. Maybe
My goal is to move deploy plugins out of this repo or at least a separate package. So, something like |
Beta Was this translation helpful? Give feedback.
-
OK. This blog post got me thinking about it. I thought the React Router worker code looked clean. https://blog.cloudflare.com/introducing-the-cloudflare-vite-plugin/ const requestHandler = createRequestHandler(
() => import("virtual:react-router/server-build"),
import.meta.env.MODE
);
export default {
async fetch(request, env, ctx) {
return requestHandler(request, {
cloudflare: { env, ctx },
});
},
} satisfies ExportedHandler<CloudflareEnvironment>;
Right. importHono and serverEngine are available from "waku/unstable_hono". I guess this request is more about moving code from cli.ts to unstable_node or unstable_hono so custom servers can reuse it. startServer, loadConfig, notFound, serveStatic would be useful utilities to reuse when setting up a custom server.
Maybe serverEngine could return a function that takes a With Cloudflare, workerd will run a file that exports a handler that takes a request object so Hono wouldn't even be a dependency for the deployed code. Vercel edge functions are similar. https://github.com/wintercg/proposal-functions-api/tree/main/docs/implementations There seems to be something limiting about Waku's context API, which is partly why I reach for Hono's context. Maybe the serverEngine options can include additional context data? That seems helpful for custom servers to just pass some resources down into the context rather than go through middleware. It would also be nice to have access to the live Response object from anywhere. It is useful to know we know if headers have been sent as well as have the ability to manipulate headers on the response object immediately before the server component has finished rendering... with all the caveats about React suspense and concurrency. That's the other main reason I find a need for Hono's context. Maybe the Request and Response objects should go directly on the context and be accessible from server components and middleware.
Yeah, that works. I think we can get started on that now. Would you want it in the wakujs org? It could also be possible to move it there later. (edit: or could be part of the waku monorepo as a separate package.) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I don't love the
unstable_honoEnhancer
API. What if we supported an optionalsrc/server.ts
file? I think we could also refactor some of the code in cli.ts into a 'waku/server/node' module. If the server.ts file is not present, it could use this managed default:A Cloudflare deploy could look like this:
The 'waku/server/cloudflare' createApp function would incorporate the code from our current deploy plugin that uses Cloudflare APIs instead of node:fs. https://github.com/wakujs/waku/blob/v0.22.4/packages/waku/src/lib/plugins/vite-plugin-deploy-cloudflare.ts#L24-L75
Eventually, maybe we can get our dev server integrated with Vite's environment API so we can use Cloudflare's module runner. It would use the src/server.ts file as its entrypoint. https://github.com/cloudflare/workers-sdk/blob/wrangler%404.13.0/packages/vite-plugin-cloudflare/src/runner-worker/module-runner.ts#L90
Beta Was this translation helpful? Give feedback.
All reactions