Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions packages/next/src/withPayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 Next.js 15.4.7 to resolve this warning.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a GitHub discussion or issue we can link to so users don't have to go searching for updates?

Copy link
Member Author

@AlessioGr AlessioGr Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only this PR - there won't be any updates though and I have no plans to fix this warning on Next.js 15.2.3 as of now

For the other, turbopack externals error, there is vercel/next.js#76991 and #14456

)
return
}

consoleWarn(...args)
}
}

const poweredByHeader = {
key: 'X-Powered-By',
value: 'Next.js, Payload',
Expand Down
Loading