Skip to content
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

Can't configure turbopack in next.config.ts file #71902

Open
FarzadMohtasham opened this issue Oct 26, 2024 · 3 comments
Open

Can't configure turbopack in next.config.ts file #71902

FarzadMohtasham opened this issue Oct 26, 2024 · 3 comments
Labels
bug Issue was opened via the bug report template. Turbopack Related to Turbopack with Next.js.

Comments

@FarzadMohtasham
Copy link

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/exciting-matsumoto-go8s7s

To Reproduce

  1. install @svgr/webpack leader
  2. add turbopack config to next.config.ts file

`
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
turbo: {
rules: {
".svg": {
loaders: ["@svgr/webpack"],
as: "
.js",
},
},
},
};

export default nextConfig;
`

  1. run next project using next dev --turbo
  2. error:

`
yarn run v1.22.22
$ next dev --turbo
▲ Next.js 15.0.2-canary.6 (Turbopack)

✓ Starting...
⚠ Invalid next.config.ts options detected:
⚠ Unrecognized key(s) in object: 'turbo'
⚠ See more info here: https://nextjs.org/docs/messages/invalid-next-config
✓ Ready in 3.3s
`

Current vs. Expected behavior

In api-reference/next-config-js/turbo i used this config in my next.config.ts file:
module.exports = { turbo: { rules: { '*.svg': { loaders: ['@svgr/webpack'], as: '*.js', }, }, }, }
But i recived errors that are mentioned in above field

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 24408
  Available CPU cores: 16
Binaries:
  Node: 22.10.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.0.2-canary.6 // There is a newer canary version (15.0.2-canary.7) available, please upgrade! 
  eslint-config-next: 15.0.0-rc.1
  react: 19.0.0-rc-1631855f-20241023
  react-dom: 19.0.0-rc-1631855f-20241023
  typescript: 5.6.3
Next.js Config:
  output: {
  turbo: {
    rules: {
      "*.svg": {
        loaders: ["@svgr/webpack"],
        as: "*.js",
      },
    },
  },
}

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

Turbopack

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

next dev (local), next build (local), next start (local)

Additional context

No response

@FarzadMohtasham FarzadMohtasham added the bug Issue was opened via the bug report template. label Oct 26, 2024
@github-actions github-actions bot added the Turbopack Related to Turbopack with Next.js. label Oct 26, 2024
@mfaux
Copy link

mfaux commented Oct 26, 2024

In the meantime, you can use turbo under experimental:

const nextConfig: NextConfig = {
  experimental: {
    turbo: {
      rules: {
        /* your rules here*
      },
    },
  },
};

@FarzadMohtasham
Copy link
Author

Thanks, the problem is fixed. Is this due to using Next 15.0.2-canary.6? In the stable version of Next, we can configure Turbopack outside of the experimental, correct?

@dualdetail
Copy link

The docs are just wrong, I ran into the same thing. They just didn't update the type def to match the documentation update. In the docs turbo was no longer experimental since V15.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

No branches or pull requests

3 participants