You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to use a scheduled handler alongside a fetch handler created with HonoX.
However, @hono/vite-build/cloudflare-workers currently only supports the fetch handler. This is because the current implementation wraps the Hono instance that is default-exported in the entry point with a new Hono instance.
Furthermore, if the object that is default-exported in the entry point is directly default-exported in the built output file, it would make the behavior more intuitive.
What do you think?
The text was updated successfully, but these errors were encountered:
As a workaround, I was able to implement an additional handler using entryContentAfterHooks in vite.config.ts.
import{defineConfig}from'vite'importbuildfrom'@hono/vite-build/cloudflare-workers'exportdefaultdefineConfig({plugins: [build({entryContentAfterHooks: [(content)=>{return`const handlerModules = import.meta.glob('/app/handlers.ts', { eager: true }) for (const [, handlers] of Object.entries(handlerModules)) { if (handlers) { for (const [name, handler] of Object.entries(handlers)) {${content}[name] = handler } } }`},],})],})
It seems that the current implementation of getEntryContent is designed to support multiple entry points.
However, handlers other than fetch are not Hono instances, which means that only one of them can be defined. This creates a conflict with the intended functionality of getEntryContent.
What do you think about supporting an additional entry point specifically for Cloudflare Workers handlers, as shown in the workaround above?
For example, vite.config.ts could specify an additional entry point for handlers like this:
I would like to use a scheduled handler alongside a fetch handler created with HonoX.
However,
@hono/vite-build/cloudflare-workers
currently only supports the fetch handler. This is because the current implementation wraps the Hono instance that is default-exported in the entry point with a new Hono instance.vite-plugins/packages/build/src/entry/index.ts
Lines 51 to 79 in 4894ad5
This makes difficult to use handlers other than fetch in Cloudflare Workers.
As shown in the Hono documentation, it would be better if the following implementation could be supported in the entry point:
Furthermore, if the object that is default-exported in the entry point is directly default-exported in the built output file, it would make the behavior more intuitive.
What do you think?
The text was updated successfully, but these errors were encountered: