Skip to content

Conversation

@yusukebe
Copy link
Member

@yusukebe yusukebe commented Mar 4, 2025

WIP

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@codecov
Copy link

codecov bot commented Mar 4, 2025

Codecov Report

Attention: Patch coverage is 6.33484% with 207 lines in your changes missing coverage. Please review.

Project coverage is 89.58%. Comparing base (8796371) to head (f7e02d3).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
src/jsx/action/index.ts 0.00% 111 Missing ⚠️
src/jsx/action/client.ts 0.00% 93 Missing ⚠️
src/utils/url.ts 77.77% 2 Missing ⚠️
src/jsx/intrinsic-element/components.ts 75.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (6.33%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3973      +/-   ##
==========================================
- Coverage   91.29%   89.58%   -1.72%     
==========================================
  Files         168      170       +2     
  Lines       10772    10981     +209     
  Branches     3057     3148      +91     
==========================================
+ Hits         9834     9837       +3     
- Misses        937     1143     +206     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yusukebe
Copy link
Member Author

yusukebe commented Mar 4, 2025

Hey @usualoma !

Shall we work on Hono Action as just POC? I think Hono Action will be super helpful with using HonoX.

In this PR, it throws the following error. Can you take a look at it?

App:

import { Hono } from '../../src'
import { createAction } from '../../src/jsx/action'
import { jsxRenderer } from '../../src/middleware/jsx-renderer'

const renderer = jsxRenderer(
  ({ children }) => {
    return (
      <html>
        <body>
          <main>{children}</main>
        </body>
      </html>
    )
  },
  {
    stream: true,
  }
)

const app = new Hono()

app.use(renderer)

const [action, Component] = createAction(app, async (data, c) => {
  return <></>
})

app.get('/', (c) => {
  return c.render(
    <section>
      <form>
        <Component />
      </form>
    </section>
  )
})

export default app

Error:

CleanShot 2025-03-04 at 16 33 49@2x

@usualoma
Copy link
Member

usualoma commented Mar 5, 2025

I'll check; give me a few days.

@usualoma
Copy link
Member

Hi @yusukebe.

Sorry for the delay. I have not been able to reproduce the error you indicated.

It requires a bit adjustment to get it working, and I have confirmed that it works with the following PR content.
#4008

With the following source code and settings,

$ wrangler dev hono-action.tsx

Ran and worked.

/** @jsxRuntime automatic @jsxImportSource ./src/jsx */
import { Hono } from './src/'
import { createAction } from './src/jsx/action'
import { jsxRenderer } from './src/middleware/jsx-renderer'

const renderer = jsxRenderer(
  ({ children }) => {
    return (
      <html>
        <body>
          <main>{children}</main>
        </body>
      </html>
    )
  },
  {
    stream: true,
  }
)

const app = new Hono()

app.use(renderer)

const [action, Component] = createAction(app, async (data, c) => {
  return (
    <>
      Hello {data?.name}
      <input type='text' name='name' />
      <input type='submit' value='Submit' />
    </>
  )
})

app.get('/', (c) => {
  return c.render(
    <section>
      <form action={action}>
        <Component />
      </form>
    </section>
  )
})

export default app
{
    "$schema": "node_modules/wrangler/config-schema.json",
    "name": "test",
    "compatibility_date": "2025-03-17",
    "observability": {
        "enabled": true
    },
    "compatibility_flags": [
        "nodejs_compat_v2"
    ]
}
CleanShot.2025-03-18.at.19.58.33.mp4

@yusukebe
Copy link
Member Author

@usualoma Thank you for the response!

It requires a bit adjustment to get it working, and I have confirmed that it works with the following PR content.
#4008

I haven't investigated it, so this is just my opinion. Wrangler uses esbuild internally, and esbuild may compile the client's JS. Anyway, I think you know it, but the implementation may be not so good.

However, I want to merge #4008 with this branch. Can you remove the commit 36243d1 then I'll merge it.

@yusukebe
Copy link
Member Author

@usualoma

The reason it didn't work was that the JSX settings were wrong! Sorry!

src/hono-base.ts Outdated
path = mergePath(this._basePath, path)
const r: RouterRoute = { path, method, handler }
this.router.add(method, path, [handler, r])
const r: RouterRoute = { path: path, method: method, handler: handler }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const r: RouterRoute = { path: path, method: method, handler: handler }
const r: RouterRoute = { path, method, handler }

I think this section should be written in shorthand property.
(#3640)

@usualoma
Copy link
Member

Hi @yusukebe.

Thanks for checking!
I have deleted 36243d1 from #4008.

@github-actions

This comment has been minimized.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/hono@3973

commit: 3f03573

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Bundle size check

main (f7d272a) #3973 (2e19413) +/-
Bundle Size (B) 18,377B 18,381B 4B
Bundle Size (KB) 17.95K 17.95K 0K

Compiler Diagnostics (tsc)

main (f7d272a) #3973 (2e19413) +/-
Files 303 303 0
Lines 141,166 141,178 12
Identifiers 128,937 128,959 22
Symbols 269,498 269,515 17
Types 202,695 202,702 7
Instantiations 609,801 609,801 0
Memory used 348,245K 342,003K -6,242K
I/O read 0.03s 0.03s 0s
I/O write 0s 0s 0s
Parse time 0.73s 0.71s -0.02s
Bind time 0.33s 0.3s -0.03s
Check time 2.9s 2.43s -0.47s
Emit time 0s 0s 0s
Total time 3.96s 3.44s -0.52s

Compiler Diagnostics (typescript-go)

main (f7d272a) #3973 (2e19413) +/-
Files 303 303 0
Lines 141,168 141,180 12
Identifiers 128,900 128,922 22
Symbols 390,634 387,992 -2,642
Types 372,898 372,905 7
Instantiations 984,004 984,004 0
Memory used 254,286K 253,770K -516K
Memory allocs 2,553,316 2,553,530 214
Config time 0.001s 0.001s 0s
Parse time 0.089s 0.088s -0.001s
Bind time 0.034s 0.018s -0.016s
Check time 0.606s 0.605s -0.001s
Emit time 0s 0s 0s
Total time 0.782s 0.793s 0.011s

Reported by octocov

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

HTTP Performance Benchmark

Framework Runtime Average Ping Query Body
hono (origin/main) bun 35,922.03 50,519.29 30,707.79 26,539.00
hono (current) bun 34,054.15 47,497.62 28,792.00 25,872.84
Change -5.20% -5.98% -6.24% -2.51%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants