-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
After upgrading to the latest version of Next.js and enabling Turbopack, I am facing an import alias issue related to Contentlayer. The error occurs when trying to import contentlayer/generated
inside a page component.
Error Message
Module not found: Can't resolve 'contentlayer/generated'
Full error:
Steps to Reproduce
- Upgrade to the latest Next.js version with Turbopack enabled.
- Use
@/.contentlayer/generated
in an import statement. - Run
next dev
ornext build
. - Encounter the import alias resolution issue.
Expected Behavior
The alias @/.contentlayer/generated
should resolve correctly without errors.
Current Workaround (Not Working)
I attempted to fix this by modifying my next.config.js
as follows:
turbo: {
root: "./",
resolveAlias: {
"contentlayer/generated": "./.contentlayer/generated",
},
resolveExtensions: [".mdx", ".tsx", ".ts", ".jsx", ".js", ".json"],
}
Despite this, the issue persists.
Configuration Details
- tsconfig.json
{
"compilerOptions": {
"paths": {
"@/*": ["./*"],
"contentlayer/generated": ["./.contentlayer/generated"]
}
},
"include": [".contentlayer/generated"]
}
- next.config.js
import { withContentlayer } from "next-contentlayer";
const nextConfig = {
experimental: {
turbo: {
resolveAlias: {
"contentlayer/generated": "./.contentlayer/generated",
}
}
}
};
export default withContentlayer(nextConfig);
System Info
- Next.js Version: 15.2.4
- Node.js Version: 21.4.0
- Operating System:mac os
Additional Context
- The issue seems to be related to Turbopack's module resolution.
- It works fine with Webpack, but breaks with Turbopack.
contentlayer
is properly generated inside.contentlayer/generated
.
Would appreciate any guidance on fixing this!
Metadata
Metadata
Assignees
Labels
No labels