-
Notifications
You must be signed in to change notification settings - Fork 390
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: add SolidJS support #2101
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
Thanks for contribution, that looks interesting. Could you highlight what the key difference between react and solidjs integration? |
Key differences:
All tests are ported from React, except:
This is not ported to SolidJS:
P.S. SolidJS and React code are still similar
|
Thanks for details explanation, from the PR file listing (i haven't dug into this properly yet) it looks like many code duplication with React, is there something that could be extracted and reused? Maintaining few copies in the long run isn't a very pleasant experience. |
I'm not sure. The reactive model and data types are dramatically different. It just looks similar, but the details are completely different. |
Done at this moment:
What else is needed for merging PR? Documentation? Examples? CI? |
Also, macro plugin don't work with runtimeConfigModule: {
Trans: ["@lingui/solid", "Trans"],
useLingui: ["@lingui/solid", "useLingui"],
} I think that it would be ideal to automatically determine the required package. |
Another question.
But in SolidJS, we use signals. They are always function calls.
It's okay? Or can I change the logic of macros? Better variant for SolidJS:
But... breaking change for other integrations. Of course, is not critical, working SolidJS integration is still cool even without named macros for signals. |
I understand that inside these two frameworks are different. But some implementation details of a library are very similar. And because of the code duplication this will increase a maintenance burden for the maintainers. So i'm really want to avoid this at any cost. Take for example the format function. Is there any difference from the react version? If it's almost the same, we can move it to some shared package and reuse between both. The same is for other parts. Note regarding macro. There is also a SWC version of it, is there any configurations where solid can be used with a SWC? if yes, then SWC version should also be updated.
There is a PR for labeled placeholders, it might help in this case:
|
https://gist.github.com/Azq2/fb6a5485242746a6e62318f1b959b728
|
Another way - I can develop solidjs integration by myself, unofficially, in a separate package/organization. But with official support in:
This is required for normal work. |
For what its worth, I've been using |
@Bubz43 Can you show an example? I'll be surprised if this works with TS. |
Apologies, I should have specified that by default the component's props don't work with TS autocomplete/typechecking (though the JSDoc comments still work) but it also doesn't have any errors for the common use case of To get actual TS support you can override declare module "@lingui/react/macro" {
import type { ParentComponent } from "solid-js";
/**
* Trans is the basic macro for static messages,
* messages with variables, but also for messages with inline markup
*
* @example
* ```
* <Trans>Hello {username}. Read the <a href="/docs">docs</a>.</Trans>
* ```
* @example
* ```
* <Trans id="custom.id">Hello {username}.</Trans>
* ```
*/
export const Trans: ParentComponent<{
id?: string;
comment?: string;
context?: string;
}>;
} I'm not suggesting this is reasonable for the average end user to do, just wanted to share in case it sparks an idea for an easier way forward that lowers the surface area for maintenance and/or for supporting solid-js from an external package. |
Description
Basic SolidJS integration ported from @lingui/react
All tests passed.
Types of changes
Checklist
Testing
My package for testing: https://github.com/Azq2/js-lingui-solid