-
Notifications
You must be signed in to change notification settings - Fork 394
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. |
I have production ready variant in my package https://github.com/Azq2/js-lingui-solid But the current version is very difficult to maintain, since I had to create fork of the packages: The reason for the fork is only to add support for Then I can adequately support the SolidJS version in my own separate package. |
@Bubz43 would you please 🙏 share a gist with this component you're mentioning here? And also the specific configuration for That would be super helpful for me, as I really like Lingui and I'm also trying to use it with Solid, it seems the best alternative out there but this is a real blocker for me. Also, I don't want to use a fork of this library, so I'd prefer to just copy a macro implementation if somebody already implemented it. I'm just looking for the simplest solution to this. Thanks! |
@Azq2 The main reason this PR is on hold is that I believe the existing Lingui code could be refactored to reduce duplication. However, to propose meaningful changes, I need to fully understand the context of this task and review everything thoroughly. The main concern here is the increased maintenance surface if this package is added. Also, I don’t have experience with SolidJS and honestly don’t want to take on that maintenance burden. A separate package seems like a good approach. From my side, I’m fully committed to making the necessary changes in If you have any ideas or additional configurations that could help reduce duplication, I’m open to implementing them. |
@Azq2 here is list (not complete) of changes need to be done to lingui to reduce duplication with your package:
Also looking for a way to reuse typings (props, and so on) between react / other jsx libs, but it seems the hassle is not worth the effort. |
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