honojs / hono

Web framework built on Web Standards
https://hono.dev
MIT License
18.25k stars 515 forks source link

documentation at https://hono.dev/guides/jsx seems out of date #2818

Open bkerin opened 3 months ago

bkerin commented 3 months ago

What version of Hono are you using?

4.2.4 I think. you know the web just keeps getting wilder

What runtime/platform is your app running on?

deno

What steps can reproduce the bug?

If I use the the jsx.tsx from https://github.com/honojs/examples/blob/main/deno/jsx.tsx (and no compiler options in my deno.jsonc) things work.

If I add the second pragma suggested on https://hono.dev/guides/jsx like so:

/** @jsx jsx */
/** @jsxImportSource hono/jsx */

then deno errors on deno task dev:

error: Relative import path "hono/jsx/jsx-runtime" not prefixed with / or ./ or ../
    at file:///var/www/betatest.mydomain.com/html/deno_tsx_test.tsx:3:22

So it looks like the example is right and the docs wrong.

If I use the the compiler configuration that the docs seem to be saying can be used instead of the pragmas I get a similar error but at a different location:

error: Relative import path "hono/jsx/jsx-runtime" not prefixed with / or ./ or ../
    at file:///var/www/betatest.mydomain.com/html/deno_tsx_test.tsx:1:1

What is the expected behavior?

The docs should work like the example I think

What do you see instead?

Please see above

Additional information

No response

yusukebe commented 3 months ago

Hi @bkerin

If you set up the project property, the Pragmas will work correctly. I've updated the example with the latest settings:

https://github.com/honojs/examples/tree/main/deno

But, in the project, deno.json defines the JSX runtime; you don't have to write the Pragmas.

willismonroe commented 1 month ago

@bkerin I'm not sure if this was your issue, but I was using Hono from the JSR, so I had to change the jsxImportSource property in deno.json to @hono/hono/jsx. It made the example work but didn't get rid of the error message.