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(render,tailwind): render JSX to strings without relying on React DOM #36
Conversation
… relying on React DOM
Thanks a lot for opening the PR. We've been looking at alternatives for a while now. A few thoughts that are up for discussion:
Lot's of comments above, but this is a big change and one we want to get right. Thanks again for taking the lead on this. If you'd like me to jump in and make the changes talked about above, please let me know. I'm happy to help push this forward. |
Ok, from Hyperons I pinched renderToString stringifyStyles and the tests. I copied escapeHtml from React DOM as React escapes some things differently.
👍 will add a comment.
👍
Not at the moment, they have a different representation for JSX elements. I assume the intent of this project at the moment is to continue to support a subset of React, rather than using a completely different JSX runtime? If my assumption is wrong then that would open up a lot of different possibilities, at the expense of breaking backwards compatibility.
👍
I'm not sure what to do on this one?
|
ah, I remembered why I made this a separate package - |
That extra export sounds good to me. No worries on the tests/snapshots. Let me know when I can step in and I'll handle that. Don't worry about failing CI in the mean time. |
Firstly, This is really amazing work. Thank you @phpnode Secondly, I totally agree that this should be a part of Can't wait for this to ship! |
This looks phenomenal. I'm going to pull it down and run through everything locally, but this looks ready to go. Will let you know if anything comes up locally. Really big step for the project, thanks a lot. |
@phpnode I added some tests for the renderer upstream, and updated your branch to run the jsxToString on the same tests, and we've got some failures with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it's good to go to me. Awesome stuff. @lordelogos please clone the fork and verify on your end. We have a few new tests against the demo templates in this PR now, which were created off of main
so we can be somewhat confident that the old renderer output matches the new output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phpnode This is awesome
@phpnode something I was thinking about today - do you know off hand if these changes support async components? |
@shellscape they don't support async at the moment. It's doable, but we'll need to decide what should happen if the caller uses |
All good questions. My gut says that the option throwing an error for async For reference, |
@phpnode I pushed a major version for
We can now :) I tried plugging in Seeing about what it would take to update jsxToString to support |
Component / Package Name: jsx-to-string
This PR contains:
Are tests included?
Breaking Changes?
If yes, please include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers:
Description
This PR adds a separate package for rendering JSX to strings. It's based on https://github.com/i-like-robots/hyperons but uses React's string escaping and doesn't support some features such as context. This change is necessary because using React's
renderToStaticMarkup
is not permitted within React server components.