The JavaScript kit returns a wrong result when using Hono's html helper
Angelmmiguel opened this issue · comments
Describe the bug
I developed an application that uses the html
helper from Hono. The original code is the following one (before bundling it with esbuild
):
import { Hono } from 'hono'
import { html } from 'hono/html'
const app = new Hono()
app.get('/:username', (c) => {
const { username } = c.req.param()
return c.html(
html`<!DOCTYPE html>
<h1>Hello! ${username}!</h1>`
);
})
export default app;
Wasm Workers Server returns an "error running the function" message.
Reproduction steps
-
Create a new folder
-
Create an
index.js
file with the content above -
Bundle it with esbuild:
npx esbuild index.js --format=esm --bundle --outfile=dist/[...app].js
-
Run the current
main
branch of the project and pass thedist
folder as an argument:cargo run -- ../PATH_TO_HONO_PROJECT_FOLDER/dist
-
Try to access http://localhost:8080/hi
Expected behavior
The following application returns a correct HTML code instead of an error.
Additional context
No response
The error comes from the Response
type in the JS kit shims. Currently, we store the body
parameter as it is regardless of the type. We assumed this variable would be always a string
. However, Hono is returning an String
object, which is slightly different than string primitives.