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

Examples upgrade #1393

Open
9 of 12 tasks
andrii-bodnar opened this issue Feb 2, 2023 · 20 comments · Fixed by #1558, #1550, #1506, #1684 or #1752
Open
9 of 12 tasks

Examples upgrade #1393

andrii-bodnar opened this issue Feb 2, 2023 · 20 comments · Fixed by #1558, #1550, #1506, #1684 or #1752

Comments

@andrii-bodnar
Copy link
Contributor

andrii-bodnar commented Feb 2, 2023

The examples are extremely outdated and need to be upgraded

@timofei-iatsenko
Copy link
Collaborator

  • Also we should create 2 examples for next-js (with and without SWC)
  • Add an example with Jest (show how to mock out catalogs)
  • add example with Vite (with vite-react-plugin and without)

@andrii-bodnar
Copy link
Contributor Author

Also we should create 2 examples for next-js (with and without SWC)

We have without SWC - js-lingui/examples/next-js, with SWC - swc-plugin/examples/nextjs-13, isn't it?

@timofei-iatsenko
Copy link
Collaborator

Correct, but it is hard to discover when they exist in two different repos, and it's hard to understand a difference between them.

I would suggest:

create two folders with distinctive name:
examples/next-js-with-babel
examples/next-js-with-swc

And either move nextjs example from SWC repo to here, or create in examples/next-js-with-swc just a readme file with reference to swc-plugin repo example.

It's quite handy when you have all examples in one place, like there https://github.com/vercel/next.js/tree/canary/examples

Also nextjs example in the main repo is broken. Here i posted an explanation #1265

@andrii-bodnar
Copy link
Contributor Author

Yeah, it's better to have all the examples in one place and additionally we should consider adding a small section with the links so users will be able to easily find all these examples.

@andrii-bodnar
Copy link
Contributor Author

https://github.com/vercel/next.js/tree/canary/examples/with-lingui

@bafxyz
Copy link

bafxyz commented Mar 17, 2023

I would be happy to see at least one working example with nodejs, typescript and extract parser. So far could not find anything, or lingui is not intended to work with nodejs without hacks?

@timofei-iatsenko
Copy link
Collaborator

@bafxyz if you accepting to use babel or swc for precompiling you backend code, everything should work without any hacks. but bear in mind that lingui is made mostly for frontend code and some solutions might be overengenireed for backend code.

@bafxyz
Copy link

bafxyz commented Mar 17, 2023

Yes it works perfectly fine with nextjs for me, but at the same time i could not make it work in nodejs. Would be great to see codesandbox with swc, typescript

@timofei-iatsenko
Copy link
Collaborator

the nodejs example is too wide. it all depends on the frameworks you use. For example, nestjs and express would be completely different examples.

@bafxyz
Copy link

bafxyz commented Mar 17, 2023

I'm not using any frameworks. Pure nodejs BE written in typescript which i'm running with https://www.npmjs.com/package/tsx but parser can be replaced with swc it's not a problem. I was writing simple bot for telegram messenger and because of my love to PO file format i tried to use lingui. But yeah, it was not easy to find some examples

@gpessa
Copy link

gpessa commented Mar 18, 2023

I would be happy to see at least one working example with nodejs, typescript and extract parser. So far could not find anything, or lingui is not intended to work with nodejs without hacks?

@andrii-bodnar
Are we sure that with this example the server side page is generated?
It use useEffect which only called on the client side.

@timofei-iatsenko
Copy link
Collaborator

@gpessa that's why this task exists. It has to be updated.

This was linked to pull requests Mar 23, 2023
@andrii-bodnar andrii-bodnar pinned this issue Mar 24, 2023
@andrii-bodnar andrii-bodnar linked a pull request May 4, 2023 that will close this issue
7 tasks
@cbratschi
Copy link

Is there a Next.js App Router example?

@bafxyz
Copy link

bafxyz commented May 12, 2023

Is there a Next.js App Router example?

Try this one https://github.com/sultan99/next.js-v13

@cbratschi
Copy link

@bafxyz thanks, trying it right now. Just failed with adapting the SWC example code.

@cbratschi
Copy link

Well, if I use a client component, the following error occurs:

./node_modules/babel-plugin-macros/node_modules/cosmiconfig/dist/readFile.js:9:0
Module not found: Can't resolve 'fs'

And in case of a server component, t is not defined as a function.

Is this supposed to support both cases? At least the middleware checks both cases and the used provider should also support it but the lingui code fails.

@timofei-iatsenko
Copy link
Collaborator

@cbratschi that means you're trying to use Macro without actual transpiling Macro. To use macro you have to use either babel-plugin-macros or @lingui/swc-plugin

@cbratschi
Copy link

@thekip thanks, the SWC plugin works fine for client components (first failed but after switching to server component and back to client component suddenly was working).

Are Server Components supported too? I am getting a useContext() error.

@andrii-bodnar andrii-bodnar linked a pull request May 31, 2023 that will close this issue
7 tasks
@Collinbrown95
Copy link
Contributor

Would an example with RSpack be useful?

I made a separate issue for this (#1749), but this issue might be more appropriate (in which case I can close #1749 in favour of this one).

@andrii-bodnar andrii-bodnar linked a pull request Sep 6, 2023 that will close this issue
7 tasks
@sohamnandi77
Copy link

@thekip , please add some turborepo + vite + react examples as well, monorepo docs are not much clear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment