-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
Not working with Next.js >= 10.2.x (probably because of webpack 5, dynamic imports are handled differently) #1202
Comments
Yea, this seems to be the case as I can't get it working either. It just keeps on loading my localhost page and does NOT throw any error. As soon as I run "yarn build" it builds perfectly fine and the production build also does work, at least semi good. it seems to be loading for forever until it finally works. 10 seconds loading for a <100kb website is just not acceptable. Can we get any support from anyone knowledgeable, maybe even the creator? |
The code block in question is here. It seems like I am not sure what exactly the root cause is, but I do know the Vercel team had to do a lot of webpack trickery to get this v5 release stable enough. I assume they are manipulating the fs in an unexpected way. I won't have much time to debug this for the next week or so, and would appreciate if any contributor wants to help out. |
this may be related: vercel/next.js#24700 |
It may have been that the snippet in question was previously transpiled by Webpack in order for it to work. I believe this to be the case. @isaachinman That being said, it is possible for the environment to add module loaders capable of handling, for example, JSON files. It's likely that Webpack injected this behavior before because I suggest the snippet is refactored to use EDIT: It doesn't appear to be as simple as editing the lines. Whatever is read in from the file must be validated in order to determine its type. |
Yes, we should refactor to only rely on the built-in |
It's not as simple as replacing let userConfig: UserConfig | null;
userConfig = readFileSync(DEFAULT_CONFIG_PATH, "utf8");
// ^
// Contains "asdfasdfasdfasfd" |
I tried out to upgrade to NextJS v11 and set |
I found a temporary fix until vercel/next.js#24700 gets addressed in Next.js Iteration 22 or 23, 24, 25, etc...
I just tested this on Next.js v11.0.1 and it seems to work. i.e. |
The last 7.x release of this package does not work with Next.js >= 10.2.x as well. When I run our app on Vercel with
That one is also mentioned here #661 (comment). And it is not related to the folders missing, mentioned in that issue. When I downgrade to |
We did something similar to get it working: rename the config file and pass the config in manually. |
Hi @paneidos, thanks for the update. But this only works with |
@natterstefan we're using 8.5.1 indeed |
Thanks for the info. Too bad, as this solution will probably not work with 7.x. Let's see. |
@adrai Would you be willing to open a PR with that quick fix on the |
* only import default config if no userConfig is passed #1202 * test: only import default config if no userConfig is passed
Thanks @adrai. I believe this is simply a NextJs bug at this point – passing your config into |
@isaachinman, the issue is described with full context in #1202 (comment). It does not exist upstream. Next.js (through Webpack) was transpiling the incorrect usage of
This issue should be reopened to better guide a future PR. |
I get this webpack error upon production build on Vercel unfortunately. I can't downgrade to webpack4 because my project is already complex & uses a lot of webpack5 features. The funny thing is everything works well in development environment |
@cvrlnolan are you sure? did you change your code like this? |
Yes I did all the basic steps & it ran twice on development. But on deployment it causes that error, maybe I omitted something but I don't think so. I had to look for another solution. Forgot to mention I'm working with next >= 11 |
@cvrlnolan just tried it again on the provided simple example and it worked... so must be something on your code... 🤷♂️ |
fyi: still no luck with next.js v11.1.0 😢 |
I have good news: |
Just want to be clear that |
sorry, not a Next pro ;-) |
No worries! As long as users are implementing |
Hello , seems to me that your trick for langage detection doesn't work . I have clone your project , build it "scripts": {
"dev": "next",
"build": "next build && next export",
"export": "next export",
"out": "npm run build && npm run export",
"start": "next start -p ${PORT:=3000}"
}, |
It's just an example... |
@SSylvain1989 Internationalized Routing does not integrate with |
|
for me this works good: https://github.com/adrai/next-static-i18n-test/blob/01bd6d2a3ed610ef21202479779ff65c69d439d7/pages/index.js#L25 |
First of all, thanks for sharing all of these! The caveat is that, after turning off webpack5, a new Reference:
DownsideThe only downside of this approach is we have to disable Original comment
|
For those not following #1384, this has been linked to a bug in NextJs: vercel/next.js#24700 |
Hi, I took another look at this and it seems loading the config file is resolved in the latest canary of Next.js Changing these lines to below should resolve this: const namespacesByLocale = Object.keys(initialI18nStore)
.map(locale => {
return fs.readdirSync(
path.join(process.cwd(), `public/locales/${locale}`)
)
.map(file => file.replace(`.${localeExtension}`, ''))
}) I would recommend against allowing a custom |
if not linking next-i18next this issue does not seem to occur anymore: vercel/next.js#24700 (comment) |
Can confirm that the issue seems resolved in Once this lands in a stable NextJs release, I'll make a few changes to the If end users are happy to install next@canary, they should now be unblocked. Here is an example, deployed on Vercel. |
Describe the bug
Seems with the update to Next.js 10.2, Next.js is by default using webpack 5: https://nextjs.org/blog/next-10-2#webpack-5
Occurs in next-i18next version
next-i18next: v8.5.1
Next.js: >= v10.2.x
Steps to reproduce
Just update the next version in the simple example: https://github.com/isaachinman/next-i18next/blob/master/examples/simple/package.json#L12
Error
I have no idea on how this works behind the scene, it may be Next.js itself needs to do something.
Currently an error like this is occurred:
Error: Cannot find module '/Users/user/Projects/next-i18next/examples/simple/next-i18next.config.js'
MODULE_NOT_FOUND
(happens on dev)
Additional context
I'm not very familiar with Next.js and/or webpack 5, so if someone wants to invest a bit of time to investigate, this would be really good.
Currently next-i18next only works with Next.js <= v10.1.x if not passing the userConfig in explicitely
There is also an issue in the Next.js repo: vercel/next.js#24729
➡️ Seems like this is breaking because webpack 5 is handling dynamic imports differently: vercel/next.js#25077
https://nextjs.org/docs/advanced-features/dynamic-import
The text was updated successfully, but these errors were encountered: