From 321eab07daa8df2ceebf3bfa48c789e7d2af1532 Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Mon, 17 Nov 2025 09:44:40 -0800 Subject: [PATCH 1/2] fix --- packages/next/src/withPayload.js | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/packages/next/src/withPayload.js b/packages/next/src/withPayload.js index fdc8aee6767..654193f1094 100644 --- a/packages/next/src/withPayload.js +++ b/packages/next/src/withPayload.js @@ -15,6 +15,43 @@ export const withPayload = (nextConfig = {}, options = {}) => { env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true' } + if (process.env.PAYLOAD_PATCH_TURBOPACK_WARNINGS !== 'false') { + // TODO: This warning is thrown because we cannot externalize the entry-point package for client-s3, so we patch the warning to not show it. + // We can remove this once Next.js implements https://github.com/vercel/next.js/discussions/76991 + const turbopackWarningText = + 'Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.\nTry to install it into the project directory by running' + + // TODO 4.0: Remove this once we drop support for Next.js 15.2.x + const turbopackConfigWarningText = "Unrecognized key(s) in object: 'turbopack'" + + const consoleWarn = console.warn + console.warn = (...args) => { + // Force to disable serverExternalPackages warnings: https://github.com/vercel/next.js/issues/68805 + if ( + (typeof args[1] === 'string' && args[1].includes(turbopackWarningText)) || + (typeof args[0] === 'string' && args[0].includes(turbopackWarningText)) + ) { + return + } + + // Add Payload-specific message after turbopack config warning in Next.js 15.2.x or lower. + // TODO 4.0: Remove this once we drop support for Next.js 15.2.x + const hasTurbopackConfigWarning = + (typeof args[1] === 'string' && args[1].includes(turbopackConfigWarningText)) || + (typeof args[0] === 'string' && args[0].includes(turbopackConfigWarningText)) + + if (hasTurbopackConfigWarning) { + consoleWarn(...args) + consoleWarn( + 'Payload: You can safely ignore the "Invalid next.config" warning above. This only occurs on Next.js 15.2.x or lower. We recommend upgrading to a newer version of Next.js to resolve this warning.', + ) + return + } + + consoleWarn(...args) + } + } + const poweredByHeader = { key: 'X-Powered-By', value: 'Next.js, Payload', From a7d9341f2bc9a026e57a4dbfe396e9abbb93130e Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Mon, 17 Nov 2025 09:51:38 -0800 Subject: [PATCH 2/2] recommend specific version --- packages/next/src/withPayload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/withPayload.js b/packages/next/src/withPayload.js index 654193f1094..e005d3e12e7 100644 --- a/packages/next/src/withPayload.js +++ b/packages/next/src/withPayload.js @@ -43,7 +43,7 @@ export const withPayload = (nextConfig = {}, options = {}) => { if (hasTurbopackConfigWarning) { consoleWarn(...args) consoleWarn( - 'Payload: You can safely ignore the "Invalid next.config" warning above. This only occurs on Next.js 15.2.x or lower. We recommend upgrading to a newer version of Next.js to resolve this warning.', + 'Payload: You can safely ignore the "Invalid next.config" warning above. This only occurs on Next.js 15.2.x or lower. We recommend upgrading to Next.js 15.4.7 to resolve this warning.', ) return }