Skip to content

Commit c0de75e

Browse files
authored
fix(next): withPayload wrapper next.js 16 support (#14473)
Next.js 16 throws the following error: ```ts ERROR: This build is using Turbopack, with a `webpack` config and no `turbopack` config. This may be a mistake. As of Next.js 16 Turbopack is enabled by default and custom webpack configurations may need to be migrated to Turbopack. NOTE: your `webpack` config may have been added by a configuration plugin. To configure Turbopack, see https://nextjs.org/docs/app/api-reference/next-config-js/turbopack TIP: Many applications work fine under Turbopack with no configuration, if that is the case for you, you can silence this error by passing the `--turbopack` or `--webpack` flag explicitly or simply setting an empty turbopack config in your Next config file (e.g. `turbopack: {}`). ``` This PR fixes this error by adding a turbopack property to our next.js config wrapper.
1 parent 9f2adeb commit c0de75e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packages/next/src/withPayload.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @returns {import('next').NextConfig}
77
* */
88
export const withPayload = (nextConfig = {}, options = {}) => {
9-
const env = nextConfig?.env || {}
9+
const env = nextConfig.env || {}
1010

1111
if (nextConfig.experimental?.staleTimes?.dynamic) {
1212
console.warn(
@@ -44,20 +44,23 @@ export const withPayload = (nextConfig = {}, options = {}) => {
4444
const toReturn = {
4545
...nextConfig,
4646
env,
47+
turbopack: {
48+
...(nextConfig.turbopack || {}),
49+
},
4750
outputFileTracingExcludes: {
48-
...(nextConfig?.outputFileTracingExcludes || {}),
51+
...(nextConfig.outputFileTracingExcludes || {}),
4952
'**/*': [
50-
...(nextConfig?.outputFileTracingExcludes?.['**/*'] || []),
53+
...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),
5154
'drizzle-kit',
5255
'drizzle-kit/api',
5356
],
5457
},
5558
outputFileTracingIncludes: {
56-
...(nextConfig?.outputFileTracingIncludes || {}),
57-
'**/*': [...(nextConfig?.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],
59+
...(nextConfig.outputFileTracingIncludes || {}),
60+
'**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],
5861
},
5962
// We disable the poweredByHeader here because we add it manually in the headers function below
60-
...(nextConfig?.poweredByHeader !== false ? { poweredByHeader: false } : {}),
63+
...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),
6164
headers: async () => {
6265
const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []
6366

@@ -78,13 +81,13 @@ export const withPayload = (nextConfig = {}, options = {}) => {
7881
key: 'Critical-CH',
7982
value: 'Sec-CH-Prefers-Color-Scheme',
8083
},
81-
...(nextConfig?.poweredByHeader !== false ? [poweredByHeader] : []),
84+
...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),
8285
],
8386
},
8487
]
8588
},
8689
serverExternalPackages: [
87-
...(nextConfig?.serverExternalPackages || []),
90+
...(nextConfig.serverExternalPackages || []),
8891
'drizzle-kit',
8992
'drizzle-kit/api',
9093
'pino',

0 commit comments

Comments
 (0)