-
Notifications
You must be signed in to change notification settings - Fork 385
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
SSR generating an emtpy body on next.js #1265
Comments
Same issue |
1 similar comment
Same issue |
This is something we should improve asap, a @lingui/ssr package, that compiles the t`` macros on server side. |
There are no issue with lingui itself, the problem in the example code. It activates a language in The example should be updated, no other changes needed. |
Here is an updated example where SSR is working. What I've changed:
|
BTW is still some work should be done to update example in this repo to avoid confusing people. |
is it really necessary to load the catalog on each page? |
You need to call i18n activate with locale data in server code BEFORE component will start render. It's not required to be on the each page, but should be in the place where this call could be awaited. Unfortunately, nextjs doesn't provide us with an obvious way how to do that. Each different method has advantages and disadvantages. You may try to implement |
@gpessa @Barik85 @brucexu-eth Could you please post what version of Next.js you used? I used the lingui/next.js example, updated the React version to |
@Martin005 that's very strange, it should not work on any version of react + nextjs. Because What is really needs is create another, working example in the repo, that users may start from it. Current example is outdated. It also would be great to create an example of usage with nextjs 13 app folder. |
@thekip so you have a custom webpack config into Seems to work in nextjs app, but failing when running server side loading tests with jest, producing such an error: Also, when using And hen I add such webpackFinal configuration into Storybook, then I get an error about cannot find module webpackFinal: async (config, { isServer }) => {
if (!isServer) {
config.resolve ||= {};
config.resolve.fallback ||= {};
config.resolve.fallback.fs = false;
}
config.module.rules.push({
test: /\.po/,
use: ["@lingui/loader"],
});
return config;
}, So far, if I follow the white rabbit 🐇 and update webpack lingui preset like that I still get such an error:
In definitive, I'm kinda stuck because of storybook not behaving the same way witch webpack 5 depending I use babel or swc. Any idea on how to fix that? |
You reporting bunch of different issues here. Issues from storybook pointing to the fact you don't get a babel macro plugin and storybook trying to bundle code which is not designed to be in runtime. You need to check sb configuration and make sure all required babel plugins provided. |
Thank you. I'm not familiar at all with this notation, could you point me to some ressource that explains how to mock it?
Was exactly that, thanks! FTR, I had |
I writing from the smartphone, so it's hard to provide you with a real code snippet. But as starting point you can read here https://stackoverflow.com/questions/46898638/importing-images-breaks-jest-test You need to tell Jest to use some js mock instead of *.po files, similarly as images in the SO answer. This mock could be as simple as exports = {messages: {}} Then lingui would render with default messages (usually english) |
@gpessa removing the message, not sure this is a good idea as anyway it's indexed and maybe useful for someone. But I'm ok to end this thread here 💯 |
Can we reopen this bug, is not solved and the example is still wrong @andrii-bodnar . |
thank you! |
new examples were added #1550 |
Describe the bug
Using the lingui / next.js example seems that the page is not generated server side.
If I inspect the source code of a generated page the body is empty.
An example can be found here:
https://stackblitz.com/github/akellbl4/next.js/tree/examples/with-lingui-update/examples/with-lingui?file=pages%2F_app.js
To Reproduce
Expected behavior
I should have the generated HTML
The text was updated successfully, but these errors were encountered: