Skip to content

Commit cd5b344

Browse files
authored
fix: graphql version error in production (#14622)
A graphql version error may be thrown in production, as we're no longer externalizing the graphql dependency. This PR fixes this by adding back graphql to `serverExternalPackages`. [PAYL-397](https://linear.app/figma-trial/issue/PAYL-397/graphql-version-issue-in-364-due-to-serverexternalpackages)
1 parent 802a21a commit cd5b344

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/next/src/withPayload.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ export const withPayload = (nextConfig = {}, options = {}) => {
128128
'@payloadcms/payload-cloud',
129129
// External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.
130130
'@sentry/nextjs',
131+
// Can be externalized, because we require users to install graphql themselves - we only rely on it as a peer dependency.
132+
// WHY: without externalizing graphql, a graphql version error will be thrown
133+
// during runtime ("Ensure that there is only one instance of \"graphql\" in the node_modules\ndirectory.")
134+
'graphql',
131135
// TODO: We need to externalize @payloadcms/storage-s3 as well, once Next.js has the ability to exclude @payloadcms/storage-s3/client from being externalized.
132136
// Do not bundle additional server-only packages during dev to improve compilation speed
133137
...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages === false

0 commit comments

Comments
 (0)