-
-
Notifications
You must be signed in to change notification settings - Fork 760
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 possibility to define next-i18next.config as json file #1384
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/isaachinman/next-i18next/CjhujYUC9Cu9MEmpHJGpNdTtwA9B |
Can we use a |
unfortunately no... it behaves the same as import |
Sorry, currently out of office – is there an issue on the NextJs repo to track this? |
no rush... It's still the same issue as described in #1202 and based on Next.js it's by design, so no issue 🤷♂️ vercel/next.js#25077 |
If this is an intentional choice by the Vercel team, then I'd prefer to fix this in the "right" way. Can't we hardcore the config path to satisfy that requirement? |
If you know how, without any errors.... |
@isaachinman any idea on how to hardcode the config so this could work? |
How can that be true? Are you saying that with webpack 5, all NodeJs requires are broken if they use a variable or template literal? |
userConfig = await import('./next-i18next.config.js') Will not work, because relatively that file really does not exist. btw: also the build step is erroring: src/serverSideTranslations.ts:51:33 - error TS2307: Cannot find module './next-i18next.config.js' or its corresponding type declarations.
51 userConfig = await import('./next-i18next.config.js') Regarding the require... it behaves exactly the same as await import... userConfig = await import(path.resolve(`${DEFAULT_CONFIG_PATH}.js`))
userConfig = require(path.resolve(`${DEFAULT_CONFIG_PATH}.js`)) I tried everything... 😢 |
I haven't had a chance to deep dive into webpack 5 yet, but I assume there must be a way of designating true NodeJs entry points via |
@adrai Well, failing any first-class solution, something like this should work: userConfig = eval(fs.readFileSync(path.resolve(DEFAULT_CONFIG_PATH), 'utf-8')) |
Unfortunately this would not work if the config includes some require statement... 😥 |
And how would that use case be supported by a JSON file? |
Not at all, that's why I was thinking of making it clear with a JSON file 🤷♂️ |
Do you have some direct connection to the Next.js team to ask for their advice? |
@adrai Whatever solution we decide on should work regardless of a user's specific requirements.
Yes, I'll ping them via Slack. |
@adrai I was told it sounds related to this issue, which is actively being worked on: vercel/next.js#24700 |
I'm already subscribed to that issue ;-) |
fyi: tried also with 11.1.3-canary.41 and the new experimental property outputFileTracing 😢 |
Seems to be only an issue if linking next-i18next: #1202 (comment) |
This will help when using next-i18next (simple configurations only) with Next.js >= 10.2.x and prevents the issue #1202