Replies: 1 comment
-
@yume-chan Thanks for deep dive into this issue. Indeed SolidJs using an interesting method for SSR. Anyway, could you prepare a PoC runtime component which would work both in the react and solid (that caould be 2 diffrent versions) which will accept this signature:
For macro transpiler it's simple change, most of the work would be in the runtime part. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm investigating migrating my Solid.js project from Format.js (react-intl) to lingui.
Details about my current setup
Currently I'm not using Format.js's
<FormattedMessage>
component, I write messages using theformatMessage
method, and I have a custom component that's very similar to lingui's real<Trans>
component which parses the HTML syntaxes in the message and create components for them.Lingui's
<Trans>
macro provides much better DX, so I want to give it a try.I have tested Azq2/js-lingui-solid, but it doesn't support Solid's SSR mode. I have filed Azq2/js-lingui-solid#1, but since the root cause is in
@lingui/babel-plugin-lingui-macro
, and the intention seems to be supporting many frameworks natively without requiring forking the code (#2196), I want to get some direct feedback from lingui team.To put it simple, in Solid.js SSR, components are compiled into string concatenations, that generates HTML code directly:
(code for rehydration, escaping and contexts are omitted)
Also you may notice, it only generates for what you write. If you say an element won't have dynamic children, it will skip generating interpolation for
props.children
.So when compiling the
<Trans>
macro:Then passes through Solid compiler:
As
components[0]
is literally a string, it's not possible to insert its children ("docs"
) into it. (in this simple case it's possible to parse the string as HTML and insert the children, but it will not work for components that returns multiple elements)One way I think should work is Format.js way. The macro compiler needs to create factory methods for each component:
and an example for components:
Beta Was this translation helpful? Give feedback.
All reactions