vite-plugins icon indicating copy to clipboard operation
vite-plugins copied to clipboard

.render() does not work with @hono/vite-build

Open muningis opened this issue 11 months ago • 3 comments

(initially was created as a bug, but now it's clear it's documentation issue. Original issue content is below)

https://hono.dev/docs/getting-started/bun#change-port-number States that to change port, we should do

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

while that's fine while it's only running in bun runtime, perhaps it would be better to clarify that when, for example building with vite, it might cause conflicts?


Original issue

### What version of Hono are you using?

4.6.1

What runtime/platform is your app running on? (with version if possible)

[email protected], [email protected]

What steps can reproduce the bug?

  1. Use .render()
  2. Build with vite + @hono/vite-build
  3. Try running built server (you will get undefined is not an object (evaluating '*.routes.map'))

Reproduction repo: https://github.com/muningis/hono-issue-3917-reproduction

What is the expected behavior?

Server runs successfuly

What do you see instead?

undefined is not an object (evaluating '*.routes.map')

Additional information

Unminified JS: https://gist.github.com/muningis/0809a25b13580d5c48b854417868b841

Error happens on line 541, following declarations, you can see that routes are gone from export - however, that was written as in example here: https://hono.dev/docs/api/hono#fetch. Seems like to be incorrect documentation. However, even if

export default {
  ...app,
  port: 3001
};

is done, it still uses 300

muningis avatar Feb 12 '25 17:02 muningis

Hi @muningis

Thank you for the issue. As you said, it will confuse.

This is not a issue in this honojs/hono but I think it will be okay to add the documents to README of @hono/vite-dev-server and @hono/vite-build.

yusukebe avatar Feb 13 '25 00:02 yusukebe

This is honojs/vite-plugin side issue. I'll transfer this issue to there.

yusukebe avatar Mar 03 '25 05:03 yusukebe

Hi @muningis

This issue was fixed since the new version @hono/[email protected].

yusukebe avatar Mar 24 '25 12:03 yusukebe