Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC: feat(jsx/dom): introduce jsx/dom/tiny. Some features are omit in this runtime, but the size is very small. #3295

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

usualoma
Copy link
Member

There are currently no plans to include this, but it is a PoC to show that it is possible to reduce the size.

The size of "jsx/dom" has increased considerably with the changes in #2960. For apps that do not need the features of #2960, it is possible to provide a smaller sized runtime that omits those features.

Usage

with full feature

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "hono/jsx/dom",
  }
}

without title/script/style/meta elements feature https://react.dev/reference/react-dom/components

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "hono/jsx/dom/tiny",
  }
}

Result

Compared with the code used in js-framework-benchmark.

% ls -lSr solid/dist/main.js preact/dist/main.js react-hooks/dist/main.js hono/dist/index.js hono-tiny/dist/index.js | awk '{print $NF, $5}'
solid/dist/main.js 11288
hono-tiny/dist/index.js 11930
hono/dist/index.js 16108
preact/dist/main.js 16612
react-hooks/dist/main.js 145439

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

@usualoma
Copy link
Member Author

The current ‘hono/jsx/dom’ is small enough that I see no need to merge this PR, but if this becomes an important point of comparison with other frameworks, I would consider merging it.

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 95.55556% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.22%. Comparing base (17c3b9e) to head (e0546f1).

Files Patch % Lines
src/jsx/dom/jsx-dev-runtime.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3295      +/-   ##
==========================================
- Coverage   96.31%   96.22%   -0.09%     
==========================================
  Files         151      154       +3     
  Lines       15368    15394      +26     
  Branches     2685     2696      +11     
==========================================
+ Hits        14801    14813      +12     
- Misses        567      581      +14     

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

@yusukebe
Copy link
Member

Hi @usualoma

Interesting. I also will consider it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants