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

feat(jsx/server): introduce jsx/dom/server module for compatibility with react-dom/server #2930

Merged
merged 4 commits into from
Jun 12, 2024

Conversation

usualoma
Copy link
Member

@usualoma usualoma commented Jun 7, 2024

Implement React compatible renderToString and renderToReadableStream.
This component is used to create an alias in #2925

Is the name jsx/dom/server appropriate?

As it is a component that provides stringify function, I don't think it is related to “DOM", but I chose this name because it is easier to understand if it corresponds to "react-dom/server".

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

Copy link

codecov bot commented Jun 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.45%. Comparing base (fe7cfcf) to head (147223f).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2930      +/-   ##
==========================================
+ Coverage   94.42%   94.45%   +0.03%     
==========================================
  Files         136      137       +1     
  Lines       13343    13424      +81     
  Branches     2219     2236      +17     
==========================================
+ Hits        12599    12680      +81     
  Misses        744      744              

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

@usualoma usualoma changed the title POC: feat(jsx/server): introduce jsx/server module for compatibility with react-dom/server feat(jsx/server): introduce jsx/server module for compatibility with react-dom/server Jun 7, 2024
@usualoma usualoma changed the title feat(jsx/server): introduce jsx/server module for compatibility with react-dom/server feat(jsx/server): introduce jsx/dom/server module for compatibility with react-dom/server Jun 7, 2024
@usualoma usualoma marked this pull request as ready for review June 7, 2024 22:17
@usualoma
Copy link
Member Author

usualoma commented Jun 7, 2024

@yusukebe Would you please review?

@yusukebe
Copy link
Member

yusukebe commented Jun 8, 2024

Hi @usualoma !

I don't know if it will be the best way but have you ever thought about implementing renderToString and renderToReadableStream in @hono/react-compat? I think if these are used only for that module, it will be a good idea. Though if jsx/dom/server will be used in other places e.g. vite.config.ts, we have to implement this in hono package.

@usualoma
Copy link
Member Author

usualoma commented Jun 8, 2024

@yusukebe Thanks for your comment!

In my opinion, the best way to do this is to "not include any implementation in @hono/react-compat". The only code included is re-export in “@hono/react-compat".

export * from 'hono/jsx'.

But I also see your point. You mean that this PR code is "just a wrapper for React compatibility, it doesn't add any new value", so does it really need to be added to "hono"?

It could be used in "vite.config.ts" or "honox", but, well, I don't have any concrete ideas at the moment.

I know there are different opinions, but I would prefer this code to be in "hono" instead of "@hono/react-compat".

@usualoma
Copy link
Member Author

usualoma commented Jun 8, 2024

Oh, just to say, "@hono/react-compat" is currently aliased to "hono/jsx", but if it is aliased to "hono/jsx/dom" and aimed at something "client-side only, but very very small", it is possible that this pull request's implementation is not needed in the first place.

@yusukebe
Copy link
Member

yusukebe commented Jun 8, 2024

Hi @usualoma

You mean that this PR code is "just a wrapper for React compatibility, it doesn't add any new value", so does it really need to be added to "honor"?

Yeah, definitely. But it's okay to merge this PR! It was not a big problem for me. With this PR, the code in @hono/react-compat will be minimal, and jsx/dom/server may be used in other places.

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

Can you update jsr.json too?

@usualoma
Copy link
Member Author

usualoma commented Jun 9, 2024

@yusukebe
Thank you.
I updated jsr.json in 3f2dcfc.

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe
Copy link
Member

yusukebe commented Jun 9, 2024

@usualoma Thanks!

I'll leave this not merging because this is a feat. But, I may include this change in a patch version since this is not a big feature for end-users.

@yusukebe yusukebe changed the base branch from main to next June 12, 2024 02:59
@yusukebe yusukebe merged commit c910923 into honojs:next Jun 12, 2024
14 checks passed
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