Skip to content

Impossible to use next-intl with Turbopack dev flag #1779

@joshverd

Description

@joshverd

Description

It seems like using the --turbo flag with the Nextjs dev server is currently not possible. There appears to be a mismatch with how the config file is resolved at different points in the dev server operation.

If I start the Next dev server without --turbo and the following config, everything works great:

/**
 * This works for Webpack
 * 
 * But NOT for starting the Turbo dev server
 */
const withNextIntl = createNextIntlPlugin(
  'i18n/request.ts',
);

But this does NOT work with turbo:

Error: [next-intl] Could not find i18n config at i18n/request.ts, please provide a valid path.

Second, I tried setting up another config file path, starting from src/ this time:

/**
 * This works for STARTING the Turbo dev server
 * 
 * But this will throw an error in layout.tsx when loading localhost:3000
 */
const withNextIntl = createNextIntlPlugin(
  'src/i18n/request.ts',
);

The dev server starts just fine, but once I load the project in the browser it throws an error in layout.tsx:

 ✓ Compiled / in 1295ms
 ⨯ Error: Couldn't find next-intl config file. Please follow the instructions at https://next-intl.dev/docs/getting-started/app-router
    at RootLayout (src/app/layout.tsx:20:31)
  18 |   children: React.ReactNode
  19 | }) {
> 20 |   const locale = await getLocale();

This could be related to how I structure my projects. All Nextjs frontend code is contained within the src/ dir. Check package.json in the repro repository to see the scripts I am using to start Next.

Verifications

Mandatory reproduction URL

https://github.com/joshverd/next-intl-bug-repro

Reproduction description

  1. Clone repro repository
  2. Run npm i
  3. Open src/next.config.ts
  4. Run npm run dev-turbo

Expected behaviour

I expect the dev server to 1) start properly and 2) render my layout.tsx and page.tsx files correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions