Thanks to visit codestin.com
Credit goes to github.com

Skip to content

--turbopack causing problems with next-translate #76944

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

Open
kahur opened this issue Mar 10, 2025 · 1 comment
Open

--turbopack causing problems with next-translate #76944

kahur opened this issue Mar 10, 2025 · 1 comment
Labels
Internationalization (i18n) Related to Internationalization with Next.js. Turbopack Related to Turbopack with Next.js.

Comments

@kahur
Copy link

kahur commented Mar 10, 2025

Link to the code that reproduces this issue

https://github.com/kahur/nextjs-translate-turbopack-reproduction

To Reproduce

  1. Create next-js app
  2. install next-translate & next-translate-plugin
  3. Add default configurations for both or you can use this one:

i18n.json

{
  "locales": ["en", "de", "sk", "pl"],
  "defaultLocale": "en",
  "pages": {
    "*": ["common"]
  }
}

next.config.ts

import nextTranslate from 'next-translate-plugin';

const nextConfig = nextTranslate( {
  /* config options here */
    output: "standalone",
    reactStrictMode: true
});

nextConfig.i18n = undefined;

export default nextConfig;
  1. Create server page.tsx component
  2. Try to use translation hook inside the component.

It will result in error:
TypeError: (0 , {imported module [project]/nodemodules/next/dist/server/route-modules/app-page/vendored/rsc/react.js [app-rsc] (ecmascript)}.useContext) is not a function
The issue disappears, when you force page to render as client by "use client".

Current vs. Expected behavior

Current: Using useTranslate hook in server component will cause error
Expected: Using useTranslate hooks works as in client component.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
  Available memory (MB): 65536
  Available CPU cores: 10
Binaries:
  Node: 21.5.0
  npm: 10.8.2
  Yarn: 1.22.21
  pnpm: 8.14.3
Relevant Packages:
  next: 15.2.1 // Latest available version is detected (15.2.1).
  eslint-config-next: 15.2.1
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.8.2
Next.js Config:
  output: standalone

Which area(s) are affected? (Select all that apply)

Runtime

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

I have tested this issue also with turning off --turbopack and it works as expected. So this is related to turbo.

@github-actions github-actions bot added the Runtime Related to Node.js or Edge Runtime with Next.js. label Mar 10, 2025
@samcx samcx added Internationalization (i18n) Related to Internationalization with Next.js. Turbopack Related to Turbopack with Next.js. and removed Runtime Related to Node.js or Edge Runtime with Next.js. labels Mar 12, 2025
@timneutkens
Copy link
Member

Looking at the plugin there is no setup for Turbopack, which may explain why it breaks: https://app.unpkg.com/[email protected]/files/lib/esm/index.js#L52. Can you report it to the library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internationalization (i18n) Related to Internationalization with Next.js. Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

No branches or pull requests

3 participants