@payloadcms/next 3.68.0-internal.2b8df4a → 3.68.0-internal.a53e749

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,237 +0,0 @@
1
- /**
2
- * @param {import('next').NextConfig} nextConfig
3
- * @param {Object} [options] - Optional configuration options
4
- * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false
5
- *
6
- * @returns {import('next').NextConfig}
7
- * */ "use strict";
8
- Object.defineProperty(exports, "__esModule", {
9
- value: true
10
- });
11
- function _export(target, all) {
12
- for(var name in all)Object.defineProperty(target, name, {
13
- enumerable: true,
14
- get: Object.getOwnPropertyDescriptor(all, name).get
15
- });
16
- }
17
- _export(exports, {
18
- get default () {
19
- return _default;
20
- },
21
- get withPayload () {
22
- return withPayload;
23
- }
24
- });
25
- const withPayload = (nextConfig = {}, options = {})=>{
26
- const env = nextConfig.env || {};
27
- if (nextConfig.experimental?.staleTimes?.dynamic) {
28
- console.warn('Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.');
29
- env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true';
30
- }
31
- if (process.env.PAYLOAD_PATCH_TURBOPACK_WARNINGS !== 'false') {
32
- // 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.
33
- // We can remove this once Next.js implements https://github.com/vercel/next.js/discussions/76991
34
- 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';
35
- // TODO 4.0: Remove this once we drop support for Next.js 15.2.x
36
- const turbopackConfigWarningText = "Unrecognized key(s) in object: 'turbopack'";
37
- const consoleWarn = console.warn;
38
- console.warn = (...args)=>{
39
- // Force to disable serverExternalPackages warnings: https://github.com/vercel/next.js/issues/68805
40
- if (typeof args[1] === 'string' && args[1].includes(turbopackWarningText) || typeof args[0] === 'string' && args[0].includes(turbopackWarningText)) {
41
- return;
42
- }
43
- // Add Payload-specific message after turbopack config warning in Next.js 15.2.x or lower.
44
- // TODO 4.0: Remove this once we drop support for Next.js 15.2.x
45
- const hasTurbopackConfigWarning = typeof args[1] === 'string' && args[1].includes(turbopackConfigWarningText) || typeof args[0] === 'string' && args[0].includes(turbopackConfigWarningText);
46
- if (hasTurbopackConfigWarning) {
47
- consoleWarn(...args);
48
- 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.');
49
- return;
50
- }
51
- consoleWarn(...args);
52
- };
53
- }
54
- const isBuild = process.env.NODE_ENV === 'production';
55
- const isTurbopackNextjs15 = process.env.TURBOPACK === '1';
56
- const isTurbopackNextjs16 = process.env.TURBOPACK === 'auto';
57
- if (isBuild && (isTurbopackNextjs15 || isTurbopackNextjs16)) {
58
- throw new Error('Payload does not support using Turbopack for production builds. If you are using Next.js 16, please use `next build --webpack` instead.');
59
- }
60
- const poweredByHeader = {
61
- key: 'X-Powered-By',
62
- value: 'Next.js, Payload'
63
- };
64
- /**
65
- * @type {import('next').NextConfig}
66
- */ const toReturn = {
67
- ...nextConfig,
68
- env,
69
- turbopack: {
70
- ...nextConfig.turbopack || {}
71
- },
72
- outputFileTracingExcludes: {
73
- ...nextConfig.outputFileTracingExcludes || {},
74
- '**/*': [
75
- ...nextConfig.outputFileTracingExcludes?.['**/*'] || [],
76
- 'drizzle-kit',
77
- 'drizzle-kit/api'
78
- ]
79
- },
80
- outputFileTracingIncludes: {
81
- ...nextConfig.outputFileTracingIncludes || {},
82
- '**/*': [
83
- ...nextConfig.outputFileTracingIncludes?.['**/*'] || [],
84
- '@libsql/client'
85
- ]
86
- },
87
- // We disable the poweredByHeader here because we add it manually in the headers function below
88
- ...nextConfig.poweredByHeader !== false ? {
89
- poweredByHeader: false
90
- } : {},
91
- headers: async ()=>{
92
- const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : [];
93
- return [
94
- ...headersFromConfig || [],
95
- {
96
- source: '/:path*',
97
- headers: [
98
- {
99
- key: 'Accept-CH',
100
- value: 'Sec-CH-Prefers-Color-Scheme'
101
- },
102
- {
103
- key: 'Vary',
104
- value: 'Sec-CH-Prefers-Color-Scheme'
105
- },
106
- {
107
- key: 'Critical-CH',
108
- value: 'Sec-CH-Prefers-Color-Scheme'
109
- },
110
- ...nextConfig.poweredByHeader !== false ? [
111
- poweredByHeader
112
- ] : []
113
- ]
114
- }
115
- ];
116
- },
117
- serverExternalPackages: [
118
- // serverExternalPackages = webpack.externals, but with turbopack support and an additional check
119
- // for whether the package is resolvable from the project root
120
- ...nextConfig.serverExternalPackages || [],
121
- // Can be externalized, because we require users to install graphql themselves - we only rely on it as a peer dependency => resolvable from the project root.
122
- //
123
- // WHY: without externalizing graphql, a graphql version error will be thrown
124
- // during runtime ("Ensure that there is only one instance of \"graphql\" in the node_modules\ndirectory.")
125
- 'graphql',
126
- // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.
127
- '@sentry/nextjs',
128
- ...process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true ? /**
129
- * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we
130
- * do not bundle server-only packages during dev for two reasons:
131
- *
132
- * 1. Performance: Fewer files to compile means faster compilation speeds.
133
- * 2. Turbopack support: Webpack's externals are not supported by Turbopack.
134
- *
135
- * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to
136
- * externalized packages that are not resolvable from the project root. So including a package like
137
- * "drizzle-kit" in here would do nothing - Next.js will ignore the rule and still bundle the package -
138
- * because it detects that the package is not resolvable from the project root (= not directly installed
139
- * by the user in their own package.json).
140
- *
141
- * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly
142
- * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).
143
- *
144
- *
145
- *
146
- * We should only do this during development, not build, because externalizing these packages can hurt
147
- * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the
148
- * same package.
149
- *
150
- * Example:
151
- * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)
152
- * - payload (not in bundle, external) -> installs qs-esm (external because of importer)
153
- * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.
154
- *
155
- * During development, these bundle size difference do not matter much, and development speed /
156
- * turbopack support are more important.
157
- */ [
158
- 'payload',
159
- '@payloadcms/db-mongodb',
160
- '@payloadcms/db-postgres',
161
- '@payloadcms/db-sqlite',
162
- '@payloadcms/db-vercel-postgres',
163
- '@payloadcms/db-d1-sqlite',
164
- '@payloadcms/drizzle',
165
- '@payloadcms/email-nodemailer',
166
- '@payloadcms/email-resend',
167
- '@payloadcms/graphql',
168
- '@payloadcms/payload-cloud',
169
- '@payloadcms/plugin-redirects'
170
- ] : []
171
- ],
172
- webpack: (webpackConfig, webpackOptions)=>{
173
- const incomingWebpackConfig = typeof nextConfig.webpack === 'function' ? nextConfig.webpack(webpackConfig, webpackOptions) : webpackConfig;
174
- return {
175
- ...incomingWebpackConfig,
176
- externals: [
177
- ...incomingWebpackConfig?.externals || [],
178
- /**
179
- * See the explanation in the serverExternalPackages section above.
180
- * We need to force Webpack to emit require() calls for these packages, even though they are not
181
- * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.
182
- *
183
- * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the
184
- * entry point packages, as explained in the serverExternalPackages section above.
185
- */ 'drizzle-kit',
186
- 'drizzle-kit/api',
187
- 'sharp',
188
- 'libsql',
189
- 'require-in-the-middle'
190
- ],
191
- resolve: {
192
- ...incomingWebpackConfig?.resolve || {},
193
- alias: {
194
- ...incomingWebpackConfig?.resolve?.alias || {}
195
- },
196
- fallback: {
197
- ...incomingWebpackConfig?.resolve?.fallback || {},
198
- /*
199
- * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):
200
- *
201
- * ⚠ Compiled with warnings in 8.7s
202
- *
203
- * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js
204
- * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'
205
- *
206
- * Import trace for requested module:
207
- * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js
208
- * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js
209
- * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js
210
- * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js
211
- * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js
212
- * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js
213
- * ./src/payload.config.ts
214
- * ./src/app/my-route/route.ts
215
- *
216
- **/ aws4: false
217
- }
218
- },
219
- plugins: [
220
- ...incomingWebpackConfig?.plugins || [],
221
- // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177
222
- new webpackOptions.webpack.IgnorePlugin({
223
- resourceRegExp: /^pg-native$|^cloudflare:sockets$/
224
- })
225
- ]
226
- };
227
- }
228
- };
229
- if (nextConfig.basePath) {
230
- toReturn.env.NEXT_BASE_PATH = nextConfig.basePath;
231
- }
232
- return toReturn;
233
- };
234
- const _default = withPayload;
235
-
236
-
237
- //# sourceMappingURL=withPayload.cjs.map
@@ -1,5 +1,11 @@
1
- export function withPayload(nextConfig?: import("next").NextConfig, options?: {
1
+ import type { NextConfig } from 'next';
2
+ /**
3
+ * @param {import('next').NextConfig} nextConfig
4
+ * @param {Object} [options] - Optional configuration options
5
+ * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false
6
+ * */
7
+ export declare const withPayload: (nextConfig?: NextConfig, options?: {
2
8
  devBundleServerPackages?: boolean;
3
- }): import("next").NextConfig;
9
+ }) => NextConfig;
4
10
  export default withPayload;
5
11
  //# sourceMappingURL=withPayload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withPayload.d.ts","sourceRoot":"","sources":["../src/withPayload.js"],"names":[],"mappings":"AAOO,yCANI,OAAO,MAAM,EAAE,UAAU,YAEjC;IAA0B,uBAAuB,GAAzC,OAAO;CAA6F,GAElG,OAAO,MAAM,EAAE,UAAU,CA0PrC"}
1
+ {"version":3,"file":"withPayload.d.ts","sourceRoot":"","sources":["../src/withPayload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAatC;;;;KAIK;AACL,eAAO,MAAM,WAAW,gBACV,UAAU,YACb;IAAE,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAAE,KAC7C,UA8MF,CAAA;AAED,eAAe,WAAW,CAAA"}
@@ -1,57 +1,25 @@
1
+ /* eslint-disable no-console */ /* eslint-disable no-restricted-exports */import { getNextjsVersion, supportsTurbopackExternalizeTransitiveDependencies } from './withPayload.utils.js';
2
+ import { withPayloadLegacy } from './withPayloadLegacy.js';
3
+ const poweredByHeader = {
4
+ key: 'X-Powered-By',
5
+ value: 'Next.js, Payload'
6
+ };
1
7
  /**
2
8
  * @param {import('next').NextConfig} nextConfig
3
9
  * @param {Object} [options] - Optional configuration options
4
10
  * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false
5
- *
6
- * @returns {import('next').NextConfig}
7
- * */export const withPayload = (nextConfig = {}, options = {}) => {
11
+ * */
12
+ export const withPayload = (nextConfig = {}, options = {}) => {
13
+ const nextjsVersion = getNextjsVersion();
14
+ const supportsTurbopackBuild = supportsTurbopackExternalizeTransitiveDependencies(nextjsVersion);
8
15
  const env = nextConfig.env || {};
9
16
  if (nextConfig.experimental?.staleTimes?.dynamic) {
10
17
  console.warn('Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.');
11
18
  env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true';
12
19
  }
13
- if (process.env.PAYLOAD_PATCH_TURBOPACK_WARNINGS !== 'false') {
14
- // 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.
15
- // We can remove this once Next.js implements https://github.com/vercel/next.js/discussions/76991
16
- 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';
17
- // TODO 4.0: Remove this once we drop support for Next.js 15.2.x
18
- const turbopackConfigWarningText = "Unrecognized key(s) in object: 'turbopack'";
19
- const consoleWarn = console.warn;
20
- console.warn = (...args) => {
21
- // Force to disable serverExternalPackages warnings: https://github.com/vercel/next.js/issues/68805
22
- if (typeof args[1] === 'string' && args[1].includes(turbopackWarningText) || typeof args[0] === 'string' && args[0].includes(turbopackWarningText)) {
23
- return;
24
- }
25
- // Add Payload-specific message after turbopack config warning in Next.js 15.2.x or lower.
26
- // TODO 4.0: Remove this once we drop support for Next.js 15.2.x
27
- const hasTurbopackConfigWarning = typeof args[1] === 'string' && args[1].includes(turbopackConfigWarningText) || typeof args[0] === 'string' && args[0].includes(turbopackConfigWarningText);
28
- if (hasTurbopackConfigWarning) {
29
- consoleWarn(...args);
30
- 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.');
31
- return;
32
- }
33
- consoleWarn(...args);
34
- };
35
- }
36
- const isBuild = process.env.NODE_ENV === 'production';
37
- const isTurbopackNextjs15 = process.env.TURBOPACK === '1';
38
- const isTurbopackNextjs16 = process.env.TURBOPACK === 'auto';
39
- if (isBuild && (isTurbopackNextjs15 || isTurbopackNextjs16)) {
40
- throw new Error('Payload does not support using Turbopack for production builds. If you are using Next.js 16, please use `next build --webpack` instead.');
41
- }
42
- const poweredByHeader = {
43
- key: 'X-Powered-By',
44
- value: 'Next.js, Payload'
45
- };
46
- /**
47
- * @type {import('next').NextConfig}
48
- */
49
- const toReturn = {
20
+ const baseConfig = {
50
21
  ...nextConfig,
51
22
  env,
52
- turbopack: {
53
- ...(nextConfig.turbopack || {})
54
- },
55
23
  outputFileTracingExcludes: {
56
24
  ...(nextConfig.outputFileTracingExcludes || {}),
57
25
  '**/*': [...(nextConfig.outputFileTracingExcludes?.['**/*'] || []), 'drizzle-kit', 'drizzle-kit/api']
@@ -60,6 +28,9 @@
60
28
  ...(nextConfig.outputFileTracingIncludes || {}),
61
29
  '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client']
62
30
  },
31
+ turbopack: {
32
+ ...(nextConfig.turbopack || {})
33
+ },
63
34
  // We disable the poweredByHeader here because we add it manually in the headers function below
64
35
  ...(nextConfig.poweredByHeader !== false ? {
65
36
  poweredByHeader: false
@@ -67,7 +38,6 @@
67
38
  headers: async () => {
68
39
  const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : [];
69
40
  return [...(headersFromConfig || []), {
70
- source: '/:path*',
71
41
  headers: [{
72
42
  key: 'Accept-CH',
73
43
  value: 'Sec-CH-Prefers-Color-Scheme'
@@ -77,20 +47,14 @@
77
47
  }, {
78
48
  key: 'Critical-CH',
79
49
  value: 'Sec-CH-Prefers-Color-Scheme'
80
- }, ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : [])]
50
+ }, ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : [])],
51
+ source: '/:path*'
81
52
  }];
82
53
  },
83
54
  serverExternalPackages: [
84
- // serverExternalPackages = webpack.externals, but with turbopack support and an additional check
85
- // for whether the package is resolvable from the project root
86
- ...(nextConfig.serverExternalPackages || []),
87
- // Can be externalized, because we require users to install graphql themselves - we only rely on it as a peer dependency => resolvable from the project root.
88
- //
89
55
  // WHY: without externalizing graphql, a graphql version error will be thrown
90
56
  // during runtime ("Ensure that there is only one instance of \"graphql\" in the node_modules\ndirectory.")
91
- 'graphql',
92
- // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.
93
- '@sentry/nextjs', ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true ?
57
+ 'graphql', ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true ?
94
58
  /**
95
59
  * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we
96
60
  * do not bundle server-only packages during dev for two reasons:
@@ -136,6 +100,11 @@
136
100
  * entry point packages, as explained in the serverExternalPackages section above.
137
101
  */
138
102
  'drizzle-kit', 'drizzle-kit/api', 'sharp', 'libsql', 'require-in-the-middle'],
103
+ plugins: [...(incomingWebpackConfig?.plugins || []),
104
+ // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177
105
+ new webpackOptions.webpack.IgnorePlugin({
106
+ resourceRegExp: /^pg-native$|^cloudflare:sockets$/
107
+ })],
139
108
  resolve: {
140
109
  ...(incomingWebpackConfig?.resolve || {}),
141
110
  alias: {
@@ -164,19 +133,23 @@
164
133
  **/
165
134
  aws4: false
166
135
  }
167
- },
168
- plugins: [...(incomingWebpackConfig?.plugins || []),
169
- // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177
170
- new webpackOptions.webpack.IgnorePlugin({
171
- resourceRegExp: /^pg-native$|^cloudflare:sockets$/
172
- })]
136
+ }
173
137
  };
174
138
  }
175
139
  };
176
140
  if (nextConfig.basePath) {
177
- toReturn.env.NEXT_BASE_PATH = nextConfig.basePath;
141
+ baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath;
142
+ }
143
+ if (!supportsTurbopackBuild) {
144
+ return withPayloadLegacy(baseConfig);
145
+ } else {
146
+ return {
147
+ ...baseConfig,
148
+ serverExternalPackages: [...(baseConfig.serverExternalPackages || []), 'drizzle-kit', 'drizzle-kit/api', 'sharp', 'libsql', 'require-in-the-middle',
149
+ // Prevents turbopack build errors by the thread-stream package which is installed by pino
150
+ 'pino']
151
+ };
178
152
  }
179
- return toReturn;
180
153
  };
181
154
  export default withPayload;
182
155
  //# sourceMappingURL=withPayload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withPayload.js","names":["withPayload","nextConfig","options","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","process","PAYLOAD_PATCH_TURBOPACK_WARNINGS","turbopackWarningText","turbopackConfigWarningText","consoleWarn","args","includes","hasTurbopackConfigWarning","isBuild","NODE_ENV","isTurbopackNextjs15","TURBOPACK","isTurbopackNextjs16","Error","poweredByHeader","key","value","toReturn","turbopack","outputFileTracingExcludes","outputFileTracingIncludes","headers","headersFromConfig","source","serverExternalPackages","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","resolve","alias","fallback","aws4","plugins","IgnorePlugin","resourceRegExp","basePath","NEXT_BASE_PATH"],"sources":["../src/withPayload.js"],"sourcesContent":["/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n *\n * @returns {import('next').NextConfig}\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n if (process.env.PAYLOAD_PATCH_TURBOPACK_WARNINGS !== 'false') {\n // 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.\n // We can remove this once Next.js implements https://github.com/vercel/next.js/discussions/76991\n const turbopackWarningText =\n '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'\n\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const turbopackConfigWarningText = \"Unrecognized key(s) in object: 'turbopack'\"\n\n const consoleWarn = console.warn\n console.warn = (...args) => {\n // Force to disable serverExternalPackages warnings: https://github.com/vercel/next.js/issues/68805\n if (\n (typeof args[1] === 'string' && args[1].includes(turbopackWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackWarningText))\n ) {\n return\n }\n\n // Add Payload-specific message after turbopack config warning in Next.js 15.2.x or lower.\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const hasTurbopackConfigWarning =\n (typeof args[1] === 'string' && args[1].includes(turbopackConfigWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackConfigWarningText))\n\n if (hasTurbopackConfigWarning) {\n consoleWarn(...args)\n consoleWarn(\n '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.',\n )\n return\n }\n\n consoleWarn(...args)\n }\n }\n\n const isBuild = process.env.NODE_ENV === 'production'\n const isTurbopackNextjs15 = process.env.TURBOPACK === '1'\n const isTurbopackNextjs16 = process.env.TURBOPACK === 'auto'\n\n if (isBuild && (isTurbopackNextjs15 || isTurbopackNextjs16)) {\n throw new Error(\n 'Payload does not support using Turbopack for production builds. If you are using Next.js 16, please use `next build --webpack` instead.',\n )\n }\n\n const poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n }\n\n /**\n * @type {import('next').NextConfig}\n */\n const toReturn = {\n ...nextConfig,\n env,\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n source: '/:path*',\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n },\n ]\n },\n serverExternalPackages: [\n // serverExternalPackages = webpack.externals, but with turbopack support and an additional check\n // for whether the package is resolvable from the project root\n ...(nextConfig.serverExternalPackages || []),\n // Can be externalized, because we require users to install graphql themselves - we only rely on it as a peer dependency => resolvable from the project root.\n //\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.\n '@sentry/nextjs',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev for two reasons:\n *\n * 1. Performance: Fewer files to compile means faster compilation speeds.\n * 2. Turbopack support: Webpack's externals are not supported by Turbopack.\n *\n * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to\n * externalized packages that are not resolvable from the project root. So including a package like\n * \"drizzle-kit\" in here would do nothing - Next.js will ignore the rule and still bundle the package -\n * because it detects that the package is not resolvable from the project root (= not directly installed\n * by the user in their own package.json).\n *\n * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly\n * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).\n *\n *\n *\n * We should only do this during development, not build, because externalizing these packages can hurt\n * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the\n * same package.\n *\n * Example:\n * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)\n * - payload (not in bundle, external) -> installs qs-esm (external because of importer)\n * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.\n *\n * During development, these bundle size difference do not matter much, and development speed /\n * turbopack support are more important.\n */\n [\n 'payload',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/drizzle',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/payload-cloud',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n // see: https://github.com/vercel/next.js/discussions/76991\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\n * See the explanation in the serverExternalPackages section above.\n * We need to force Webpack to emit require() calls for these packages, even though they are not\n * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.\n *\n * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the\n * entry point packages, as explained in the serverExternalPackages section above.\n */\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n }\n },\n }\n\n if (nextConfig.basePath) {\n toReturn.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n return toReturn\n}\n\nexport default withPayload\n"],"mappings":"AAAA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,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"withPayload.js","names":["getNextjsVersion","supportsTurbopackExternalizeTransitiveDependencies","withPayloadLegacy","poweredByHeader","key","value","withPayload","nextConfig","options","nextjsVersion","supportsTurbopackBuild","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","baseConfig","outputFileTracingExcludes","outputFileTracingIncludes","turbopack","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","resolve","alias","fallback","aws4","basePath","NEXT_BASE_PATH"],"sources":["../src/withPayload.ts"],"sourcesContent":["/* eslint-disable no-console */\n/* eslint-disable no-restricted-exports */\nimport type { NextConfig } from 'next'\n\nimport {\n getNextjsVersion,\n supportsTurbopackExternalizeTransitiveDependencies,\n} from './withPayload.utils.js'\nimport { withPayloadLegacy } from './withPayloadLegacy.js'\n\nconst poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n}\n\n/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n * */\nexport const withPayload = (\n nextConfig: NextConfig = {},\n options: { devBundleServerPackages?: boolean } = {},\n): NextConfig => {\n const nextjsVersion = getNextjsVersion()\n\n const supportsTurbopackBuild = supportsTurbopackExternalizeTransitiveDependencies(nextjsVersion)\n\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n const baseConfig: NextConfig = {\n ...nextConfig,\n env,\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev for two reasons:\n *\n * 1. Performance: Fewer files to compile means faster compilation speeds.\n * 2. Turbopack support: Webpack's externals are not supported by Turbopack.\n *\n * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to\n * externalized packages that are not resolvable from the project root. So including a package like\n * \"drizzle-kit\" in here would do nothing - Next.js will ignore the rule and still bundle the package -\n * because it detects that the package is not resolvable from the project root (= not directly installed\n * by the user in their own package.json).\n *\n * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly\n * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).\n *\n *\n *\n * We should only do this during development, not build, because externalizing these packages can hurt\n * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the\n * same package.\n *\n * Example:\n * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)\n * - payload (not in bundle, external) -> installs qs-esm (external because of importer)\n * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.\n *\n * During development, these bundle size difference do not matter much, and development speed /\n * turbopack support are more important.\n */\n [\n 'payload',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/drizzle',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/payload-cloud',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n // see: https://github.com/vercel/next.js/discussions/76991\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\n * See the explanation in the serverExternalPackages section above.\n * We need to force Webpack to emit require() calls for these packages, even though they are not\n * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.\n *\n * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the\n * entry point packages, as explained in the serverExternalPackages section above.\n */\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n ],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n }\n },\n }\n\n if (nextConfig.basePath) {\n baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n if (!supportsTurbopackBuild) {\n return withPayloadLegacy(baseConfig)\n } else {\n return {\n ...baseConfig,\n serverExternalPackages: [\n ...(baseConfig.serverExternalPackages || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n // Prevents turbopack build errors by the thread-stream package which is installed by pino\n 'pino',\n ],\n }\n }\n}\n\nexport default withPayload\n"],"mappings":"AAAA,gCACA,0CAGA,SACEA,gBAAgB,EAChBC,kDAAkD,QAC7C;AACP,SAASC,iBAAiB,QAAQ;AAElC,MAAMC,eAAA,GAAkB;EACtBC,GAAA,EAAK;EACLC,KAAA,EAAO;AACT;AAEA;;;;;AAKA,OAAO,MAAMC,WAAA,GAAcA,CACzBC,UAAA,GAAyB,CAAC,CAAC,EAC3BC,OAAA,GAAiD,CAAC,CAAC;EAEnD,MAAMC,aAAA,GAAgBT,gBAAA;EAEtB,MAAMU,sBAAA,GAAyBT,kDAAA,CAAmDQ,aAAA;EAElF,MAAME,GAAA,GAAMJ,UAAA,CAAWI,GAAG,IAAI,CAAC;EAE/B,IAAIJ,UAAA,CAAWK,YAAY,EAAEC,UAAA,EAAYC,OAAA,EAAS;IAChDC,OAAA,CAAQC,IAAI,CACV;IAEFL,GAAA,CAAIM,uCAAuC,GAAG;EAChD;EAEA,MAAMC,UAAA,GAAyB;IAC7B,GAAGX,UAAU;IACbI,GAAA;IACAQ,yBAAA,EAA2B;MACzB,IAAIZ,UAAA,CAAWY,yBAAyB,IAAI,CAAC,CAAC;MAC9C,QAAQ,C,IACFZ,UAAA,CAAWY,yBAAyB,GAAG,OAAO,IAAI,EAAE,GACxD,eACA;IAEJ;IACAC,yBAAA,EAA2B;MACzB,IAAIb,UAAA,CAAWa,yBAAyB,IAAI,CAAC,CAAC;MAC9C,QAAQ,C,IAAKb,UAAA,CAAWa,yBAAyB,GAAG,OAAO,IAAI,EAAE,GAAG;IACtE;IACAC,SAAA,EAAW;MACT,IAAId,UAAA,CAAWc,SAAS,IAAI,CAAC,CAAC;IAChC;IACA;IACA,IAAId,UAAA,CAAWJ,eAAe,KAAK,QAAQ;MAAEA,eAAA,EAAiB;IAAM,IAAI,CAAC,CAAC;IAC1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C,KAAA,EAAO;YACL,IAAIN,qBAAA,EAAuBK,OAAA,EAASC,KAAA,IAAS,CAAC,CAAC;UACjD;UACAC,QAAA,EAAU;YACR,IAAIP,qBAAA,EAAuBK,OAAA,EAASE,QAAA,IAAY,CAAC,CAAC;YAClD;;;;;;;;;;;;;;;;;;;YAmBAC,IAAA,EAAM;UACR;QACF;MACF;IACF;EACF;EAEA,IAAIjC,UAAA,CAAWkC,QAAQ,EAAE;IACvBvB,UAAA,CAAWP,GAAG,CAAC+B,cAAc,GAAGnC,UAAA,CAAWkC,QAAQ;EACrD;EAEA,IAAI,CAAC/B,sBAAA,EAAwB;IAC3B,OAAOR,iBAAA,CAAkBgB,UAAA;EAC3B,OAAO;IACL,OAAO;MACL,GAAGA,UAAU;MACbO,sBAAA,EAAwB,C,IAClBP,UAAA,CAAWO,sBAAsB,IAAI,EAAE,GAC3C,eACA,mBACA,SACA,UACA;MACA;MACA;IAEJ;EACF;AACF;AAEA,eAAenB,WAAA","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * This was taken and modified from https://github.com/getsentry/sentry-javascript/blob/15256034ee8150a5b7dcb97d23eca1a5486f0cae/packages/nextjs/src/config/util.ts
3
+ *
4
+ * MIT License
5
+ *
6
+ * Copyright (c) 2012 Functional Software, Inc. dba Sentry
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
9
+ * this software and associated documentation files (the "Software"), to deal in
10
+ * the Software without restriction, including without limitation the rights to
11
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12
+ * of the Software, and to permit persons to whom the Software is furnished to do
13
+ * so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+ /**
27
+ * Represents Semantic Versioning object
28
+ */
29
+ type SemVer = {
30
+ buildmetadata?: string;
31
+ /**
32
+ * undefined if not a canary version
33
+ */
34
+ canaryVersion?: number;
35
+ major?: number;
36
+ minor?: number;
37
+ patch?: number;
38
+ prerelease?: string;
39
+ };
40
+ /**
41
+ * Parses input into a SemVer interface
42
+ * @param input string representation of a semver version
43
+ */
44
+ export declare function parseSemver(input: string): SemVer;
45
+ /**
46
+ * Returns the version of Next.js installed in the project, or undefined if it cannot be determined.
47
+ */
48
+ export declare function getNextjsVersion(): SemVer | undefined;
49
+ /**
50
+ * Checks if the current Next.js version supports native debug ids for turbopack.
51
+ * This feature was first introduced in Next.js v15.6.0-canary.36 and marked stable in Next.js v16
52
+ *
53
+ * @param version - version string to check.
54
+ * @returns true if Next.js version supports native debug ids for turbopack builds
55
+ */
56
+ export declare function supportsTurbopackExternalizeTransitiveDependencies(version: SemVer | undefined): boolean;
57
+ export {};
58
+ //# sourceMappingURL=withPayload.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withPayload.utils.d.ts","sourceRoot":"","sources":["../src/withPayload.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAQH;;GAEG;AACH,KAAK,MAAM,GAAG;IACZ,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAMD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAmBjD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAQrD;AAED;;;;;;GAMG;AACH,wBAAgB,kDAAkD,CAChE,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,OAAO,CA+BT"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * This was taken and modified from https://github.com/getsentry/sentry-javascript/blob/15256034ee8150a5b7dcb97d23eca1a5486f0cae/packages/nextjs/src/config/util.ts
3
+ *
4
+ * MIT License
5
+ *
6
+ * Copyright (c) 2012 Functional Software, Inc. dba Sentry
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
9
+ * this software and associated documentation files (the "Software"), to deal in
10
+ * the Software without restriction, including without limitation the rights to
11
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12
+ * of the Software, and to permit persons to whom the Software is furnished to do
13
+ * so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */import { readFileSync } from 'fs';
26
+ function _parseInt(input) {
27
+ return parseInt(input || '', 10);
28
+ }
29
+ // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
30
+ const SEMVER_REGEXP = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*))*))?(?:\+([0-9a-z-]+(?:\.[0-9a-z-]+)*))?$/i;
31
+ /**
32
+ * Parses input into a SemVer interface
33
+ * @param input string representation of a semver version
34
+ */
35
+ export function parseSemver(input) {
36
+ const match = input.match(SEMVER_REGEXP) || [];
37
+ const major = _parseInt(match[1]);
38
+ const minor = _parseInt(match[2]);
39
+ const patch = _parseInt(match[3]);
40
+ const prerelease = match[4];
41
+ const canaryVersion = prerelease?.startsWith('canary.') ? parseInt(prerelease.split('.')[1] || '0', 10) : undefined;
42
+ return {
43
+ buildmetadata: match[5],
44
+ canaryVersion,
45
+ major: isNaN(major) ? undefined : major,
46
+ minor: isNaN(minor) ? undefined : minor,
47
+ patch: isNaN(patch) ? undefined : patch,
48
+ prerelease: match[4]
49
+ };
50
+ }
51
+ /**
52
+ * Returns the version of Next.js installed in the project, or undefined if it cannot be determined.
53
+ */
54
+ export function getNextjsVersion() {
55
+ try {
56
+ const pkgUrl = import.meta.resolve('next/package.json');
57
+ const pkgJson = JSON.parse(readFileSync(new URL(pkgUrl), 'utf8'));
58
+ return parseSemver(pkgJson.version);
59
+ } catch {
60
+ return undefined;
61
+ }
62
+ }
63
+ /**
64
+ * Checks if the current Next.js version supports native debug ids for turbopack.
65
+ * This feature was first introduced in Next.js v15.6.0-canary.36 and marked stable in Next.js v16
66
+ *
67
+ * @param version - version string to check.
68
+ * @returns true if Next.js version supports native debug ids for turbopack builds
69
+ */
70
+ export function supportsTurbopackExternalizeTransitiveDependencies(version) {
71
+ if (!version) {
72
+ return false;
73
+ }
74
+ const {
75
+ canaryVersion,
76
+ major,
77
+ minor
78
+ } = version;
79
+ if (major === undefined || minor === undefined) {
80
+ return false;
81
+ }
82
+ if (major > 16) {
83
+ return true;
84
+ }
85
+ if (major === 16) {
86
+ if (minor > 1) {
87
+ return true;
88
+ }
89
+ if (minor === 1) {
90
+ if (canaryVersion !== undefined) {
91
+ // 16.1.0-canary.15+
92
+ return canaryVersion >= 15;
93
+ } else {
94
+ // Assume that Next.js 16.1 inherits support for this feature from the canary release
95
+ return true;
96
+ }
97
+ }
98
+ }
99
+ return false;
100
+ }
101
+ //# sourceMappingURL=withPayload.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withPayload.utils.js","names":["readFileSync","_parseInt","input","parseInt","SEMVER_REGEXP","parseSemver","match","major","minor","patch","prerelease","canaryVersion","startsWith","split","undefined","buildmetadata","isNaN","getNextjsVersion","pkgUrl","import","meta","resolve","pkgJson","JSON","parse","URL","version","supportsTurbopackExternalizeTransitiveDependencies"],"sources":["../src/withPayload.utils.ts"],"sourcesContent":["/**\n * This was taken and modified from https://github.com/getsentry/sentry-javascript/blob/15256034ee8150a5b7dcb97d23eca1a5486f0cae/packages/nextjs/src/config/util.ts\n *\n * MIT License\n *\n * Copyright (c) 2012 Functional Software, Inc. dba Sentry\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n * of the Software, and to permit persons to whom the Software is furnished to do\n * so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { readFileSync } from 'fs'\n\nfunction _parseInt(input: string | undefined): number {\n return parseInt(input || '', 10)\n}\n\n/**\n * Represents Semantic Versioning object\n */\ntype SemVer = {\n buildmetadata?: string\n /**\n * undefined if not a canary version\n */\n canaryVersion?: number\n major?: number\n minor?: number\n patch?: number\n prerelease?: string\n}\n\n// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string\nconst SEMVER_REGEXP =\n /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*))*))?(?:\\+([0-9a-z-]+(?:\\.[0-9a-z-]+)*))?$/i\n\n/**\n * Parses input into a SemVer interface\n * @param input string representation of a semver version\n */\nexport function parseSemver(input: string): SemVer {\n const match = input.match(SEMVER_REGEXP) || []\n const major = _parseInt(match[1])\n const minor = _parseInt(match[2])\n const patch = _parseInt(match[3])\n\n const prerelease = match[4]\n const canaryVersion = prerelease?.startsWith('canary.')\n ? parseInt(prerelease.split('.')[1] || '0', 10)\n : undefined\n\n return {\n buildmetadata: match[5],\n canaryVersion,\n major: isNaN(major) ? undefined : major,\n minor: isNaN(minor) ? undefined : minor,\n patch: isNaN(patch) ? undefined : patch,\n prerelease: match[4],\n }\n}\n\n/**\n * Returns the version of Next.js installed in the project, or undefined if it cannot be determined.\n */\nexport function getNextjsVersion(): SemVer | undefined {\n try {\n const pkgUrl = import.meta.resolve('next/package.json')\n const pkgJson = JSON.parse(readFileSync(new URL(pkgUrl), 'utf8'))\n return parseSemver(pkgJson.version)\n } catch {\n return undefined\n }\n}\n\n/**\n * Checks if the current Next.js version supports native debug ids for turbopack.\n * This feature was first introduced in Next.js v15.6.0-canary.36 and marked stable in Next.js v16\n *\n * @param version - version string to check.\n * @returns true if Next.js version supports native debug ids for turbopack builds\n */\nexport function supportsTurbopackExternalizeTransitiveDependencies(\n version: SemVer | undefined,\n): boolean {\n if (!version) {\n return false\n }\n\n const { canaryVersion, major, minor } = version\n\n if (major === undefined || minor === undefined) {\n return false\n }\n\n if (major > 16) {\n return true\n }\n\n if (major === 16) {\n if (minor > 1) {\n return true\n }\n if (minor === 1) {\n if (canaryVersion !== undefined) {\n // 16.1.0-canary.15+\n return canaryVersion >= 15\n } else {\n // Assume that Next.js 16.1 inherits support for this feature from the canary release\n return true\n }\n }\n }\n\n return false\n}\n"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GA0BA,SAASA,YAAY,QAAQ;AAE7B,SAASC,UAAUC,KAAyB;EAC1C,OAAOC,QAAA,CAASD,KAAA,IAAS,IAAI;AAC/B;AAiBA;AACA,MAAME,aAAA,GACJ;AAEF;;;;AAIA,OAAO,SAASC,YAAYH,KAAa;EACvC,MAAMI,KAAA,GAAQJ,KAAA,CAAMI,KAAK,CAACF,aAAA,KAAkB,EAAE;EAC9C,MAAMG,KAAA,GAAQN,SAAA,CAAUK,KAAK,CAAC,EAAE;EAChC,MAAME,KAAA,GAAQP,SAAA,CAAUK,KAAK,CAAC,EAAE;EAChC,MAAMG,KAAA,GAAQR,SAAA,CAAUK,KAAK,CAAC,EAAE;EAEhC,MAAMI,UAAA,GAAaJ,KAAK,CAAC,EAAE;EAC3B,MAAMK,aAAA,GAAgBD,UAAA,EAAYE,UAAA,CAAW,aACzCT,QAAA,CAASO,UAAA,CAAWG,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,KAAK,MAC1CC,SAAA;EAEJ,OAAO;IACLC,aAAA,EAAeT,KAAK,CAAC,EAAE;IACvBK,aAAA;IACAJ,KAAA,EAAOS,KAAA,CAAMT,KAAA,IAASO,SAAA,GAAYP,KAAA;IAClCC,KAAA,EAAOQ,KAAA,CAAMR,KAAA,IAASM,SAAA,GAAYN,KAAA;IAClCC,KAAA,EAAOO,KAAA,CAAMP,KAAA,IAASK,SAAA,GAAYL,KAAA;IAClCC,UAAA,EAAYJ,KAAK,CAAC;EACpB;AACF;AAEA;;;AAGA,OAAO,SAASW,iBAAA;EACd,IAAI;IACF,MAAMC,MAAA,GAASC,MAAA,CAAAC,IAAA,CAAYC,OAAO,CAAC;IACnC,MAAMC,OAAA,GAAUC,IAAA,CAAKC,KAAK,CAACxB,YAAA,CAAa,IAAIyB,GAAA,CAAIP,MAAA,GAAS;IACzD,OAAOb,WAAA,CAAYiB,OAAA,CAAQI,OAAO;EACpC,EAAE,MAAM;IACN,OAAOZ,SAAA;EACT;AACF;AAEA;;;;;;;AAOA,OAAO,SAASa,mDACdD,OAA2B;EAE3B,IAAI,CAACA,OAAA,EAAS;IACZ,OAAO;EACT;EAEA,MAAM;IAAEf,aAAa;IAAEJ,KAAK;IAAEC;EAAK,CAAE,GAAGkB,OAAA;EAExC,IAAInB,KAAA,KAAUO,SAAA,IAAaN,KAAA,KAAUM,SAAA,EAAW;IAC9C,OAAO;EACT;EAEA,IAAIP,KAAA,GAAQ,IAAI;IACd,OAAO;EACT;EAEA,IAAIA,KAAA,KAAU,IAAI;IAChB,IAAIC,KAAA,GAAQ,GAAG;MACb,OAAO;IACT;IACA,IAAIA,KAAA,KAAU,GAAG;MACf,IAAIG,aAAA,KAAkBG,SAAA,EAAW;QAC/B;QACA,OAAOH,aAAA,IAAiB;MAC1B,OAAO;QACL;QACA,OAAO;MACT;IACF;EACF;EAEA,OAAO;AACT","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { NextConfig } from 'next';
2
+ /**
3
+ * Applies config options required to support Next.js versions before 16.1.0 and 16.1.0-canary.15.
4
+ */
5
+ export declare const withPayloadLegacy: (nextConfig?: NextConfig) => NextConfig;
6
+ //# sourceMappingURL=withPayloadLegacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withPayloadLegacy.d.ts","sourceRoot":"","sources":["../src/withPayloadLegacy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAEtC;;GAEG;AACH,eAAO,MAAM,iBAAiB,gBAAgB,UAAU,KAAQ,UA4D/D,CAAA"}
@@ -0,0 +1,44 @@
1
+ /* eslint-disable no-console */ /**
2
+ * Applies config options required to support Next.js versions before 16.1.0 and 16.1.0-canary.15.
3
+ */export const withPayloadLegacy = (nextConfig = {}) => {
4
+ if (process.env.PAYLOAD_PATCH_TURBOPACK_WARNINGS !== 'false') {
5
+ // 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.
6
+ // We can remove this once Next.js implements https://github.com/vercel/next.js/discussions/76991
7
+ 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';
8
+ // TODO 4.0: Remove this once we drop support for Next.js 15.2.x
9
+ const turbopackConfigWarningText = "Unrecognized key(s) in object: 'turbopack'";
10
+ const consoleWarn = console.warn;
11
+ console.warn = (...args) => {
12
+ // Force to disable serverExternalPackages warnings: https://github.com/vercel/next.js/issues/68805
13
+ if (typeof args[1] === 'string' && args[1].includes(turbopackWarningText) || typeof args[0] === 'string' && args[0].includes(turbopackWarningText)) {
14
+ return;
15
+ }
16
+ // Add Payload-specific message after turbopack config warning in Next.js 15.2.x or lower.
17
+ // TODO 4.0: Remove this once we drop support for Next.js 15.2.x
18
+ const hasTurbopackConfigWarning = typeof args[1] === 'string' && args[1].includes(turbopackConfigWarningText) || typeof args[0] === 'string' && args[0].includes(turbopackConfigWarningText);
19
+ if (hasTurbopackConfigWarning) {
20
+ consoleWarn(...args);
21
+ 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.');
22
+ return;
23
+ }
24
+ consoleWarn(...args);
25
+ };
26
+ }
27
+ const isBuild = process.env.NODE_ENV === 'production';
28
+ const isTurbopackNextjs15 = process.env.TURBOPACK === '1';
29
+ const isTurbopackNextjs16 = process.env.TURBOPACK === 'auto';
30
+ if (isBuild && (isTurbopackNextjs15 || isTurbopackNextjs16)) {
31
+ throw new Error('Your Next.js and Payload versions do not support using Turbopack for production builds. Please upgrade to Next.js 16.1.0-canary.15 or higher if you want to use Turbopack for builds.');
32
+ }
33
+ const toReturn = {
34
+ ...nextConfig,
35
+ serverExternalPackages: [
36
+ // serverExternalPackages = webpack.externals, but with turbopack support and an additional check
37
+ // for whether the package is resolvable from the project root
38
+ ...(nextConfig.serverExternalPackages || []),
39
+ // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.
40
+ '@sentry/nextjs']
41
+ };
42
+ return toReturn;
43
+ };
44
+ //# sourceMappingURL=withPayloadLegacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withPayloadLegacy.js","names":["withPayloadLegacy","nextConfig","process","env","PAYLOAD_PATCH_TURBOPACK_WARNINGS","turbopackWarningText","turbopackConfigWarningText","consoleWarn","console","warn","args","includes","hasTurbopackConfigWarning","isBuild","NODE_ENV","isTurbopackNextjs15","TURBOPACK","isTurbopackNextjs16","Error","toReturn","serverExternalPackages"],"sources":["../src/withPayloadLegacy.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport type { NextConfig } from 'next'\n\n/**\n * Applies config options required to support Next.js versions before 16.1.0 and 16.1.0-canary.15.\n */\nexport const withPayloadLegacy = (nextConfig: NextConfig = {}): NextConfig => {\n if (process.env.PAYLOAD_PATCH_TURBOPACK_WARNINGS !== 'false') {\n // 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.\n // We can remove this once Next.js implements https://github.com/vercel/next.js/discussions/76991\n const turbopackWarningText =\n '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'\n\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const turbopackConfigWarningText = \"Unrecognized key(s) in object: 'turbopack'\"\n\n const consoleWarn = console.warn\n console.warn = (...args) => {\n // Force to disable serverExternalPackages warnings: https://github.com/vercel/next.js/issues/68805\n if (\n (typeof args[1] === 'string' && args[1].includes(turbopackWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackWarningText))\n ) {\n return\n }\n\n // Add Payload-specific message after turbopack config warning in Next.js 15.2.x or lower.\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const hasTurbopackConfigWarning =\n (typeof args[1] === 'string' && args[1].includes(turbopackConfigWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackConfigWarningText))\n\n if (hasTurbopackConfigWarning) {\n consoleWarn(...args)\n consoleWarn(\n '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.',\n )\n return\n }\n\n consoleWarn(...args)\n }\n }\n\n const isBuild = process.env.NODE_ENV === 'production'\n const isTurbopackNextjs15 = process.env.TURBOPACK === '1'\n const isTurbopackNextjs16 = process.env.TURBOPACK === 'auto'\n\n if (isBuild && (isTurbopackNextjs15 || isTurbopackNextjs16)) {\n throw new Error(\n 'Your Next.js and Payload versions do not support using Turbopack for production builds. Please upgrade to Next.js 16.1.0-canary.15 or higher if you want to use Turbopack for builds.',\n )\n }\n\n const toReturn: NextConfig = {\n ...nextConfig,\n serverExternalPackages: [\n // serverExternalPackages = webpack.externals, but with turbopack support and an additional check\n // for whether the package is resolvable from the project root\n ...(nextConfig.serverExternalPackages || []),\n // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.\n '@sentry/nextjs',\n ],\n }\n\n return toReturn\n}\n"],"mappings":"AAAA,gCAGA;;kCAGA,OAAO,MAAMA,iBAAA,GAAoBA,CAACC,UAAA,GAAyB,CAAC,CAAC;EAC3D,IAAIC,OAAA,CAAQC,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 @@
1
1
  {
2
2
  "name": "@payloadcms/next",
3
- "version": "3.68.0-internal.2b8df4a",
3
+ "version": "3.68.0-internal.a53e749",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -86,7 +86,7 @@
86
86
  ]
87
87
  },
88
88
  "dependencies": {
89
- "@dnd-kit/core": "6.0.8",
89
+ "@dnd-kit/core": "6.3.1",
90
90
  "busboy": "^1.6.0",
91
91
  "dequal": "2.0.3",
92
92
  "file-type": "19.3.0",
@@ -97,9 +97,9 @@
97
97
  "qs-esm": "7.0.2",
98
98
  "sass": "1.77.4",
99
99
  "uuid": "10.0.0",
100
- "@payloadcms/ui": "3.68.0-internal.2b8df4a",
101
- "@payloadcms/graphql": "3.68.0-internal.2b8df4a",
102
- "@payloadcms/translations": "3.68.0-internal.2b8df4a"
100
+ "@payloadcms/graphql": "3.68.0-internal.a53e749",
101
+ "@payloadcms/ui": "3.68.0-internal.a53e749",
102
+ "@payloadcms/translations": "3.68.0-internal.a53e749"
103
103
  },
104
104
  "devDependencies": {
105
105
  "@babel/cli": "7.27.2",
@@ -107,22 +107,22 @@
107
107
  "@babel/preset-env": "7.27.2",
108
108
  "@babel/preset-react": "7.27.1",
109
109
  "@babel/preset-typescript": "7.27.1",
110
- "@next/eslint-plugin-next": "15.4.7",
110
+ "@next/eslint-plugin-next": "16.1.0-canary.15",
111
111
  "@types/busboy": "1.5.4",
112
- "@types/react": "19.2.1",
113
- "@types/react-dom": "19.2.1",
112
+ "@types/react": "19.2.7",
113
+ "@types/react-dom": "19.2.3",
114
114
  "@types/uuid": "10.0.0",
115
115
  "babel-plugin-react-compiler": "19.1.0-rc.3",
116
116
  "esbuild": "0.25.5",
117
117
  "esbuild-sass-plugin": "3.3.1",
118
118
  "swc-plugin-transform-remove-imports": "8.3.0",
119
119
  "@payloadcms/eslint-config": "3.28.0",
120
- "payload": "3.68.0-internal.2b8df4a"
120
+ "payload": "3.68.0-internal.a53e749"
121
121
  },
122
122
  "peerDependencies": {
123
123
  "graphql": "^16.8.1",
124
- "next": "^15.4.8",
125
- "payload": "3.68.0-internal.2b8df4a"
124
+ "next": "^15.4.8 || ^16.1.0",
125
+ "payload": "3.68.0-internal.a53e749"
126
126
  },
127
127
  "engines": {
128
128
  "node": "^18.20.2 || >=20.9.0"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/withPayload.js"],"names":["withPayload","nextConfig","options","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","process","PAYLOAD_PATCH_TURBOPACK_WARNINGS","turbopackWarningText","turbopackConfigWarningText","consoleWarn","args","includes","hasTurbopackConfigWarning","isBuild","NODE_ENV","isTurbopackNextjs15","TURBOPACK","isTurbopackNextjs16","Error","poweredByHeader","key","value","toReturn","turbopack","outputFileTracingExcludes","outputFileTracingIncludes","headers","headersFromConfig","source","serverExternalPackages","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","resolve","alias","fallback","aws4","plugins","IgnorePlugin","resourceRegExp","basePath","NEXT_BASE_PATH"],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;;;QA2PH;eAAA;;QA1PaA;eAAAA;;;AAAN,MAAMA,cAAc,CAACC,aAAa,CAAC,CAAC,EAAEC,UAAU,CAAC,CAAC;IACvD,MAAMC,MAAMF,WAAWE,GAAG,IAAI,CAAC;IAE/B,IAAIF,WAAWG,YAAY,EAAEC,YAAYC,SAAS;QAChDC,QAAQC,IAAI,CACV;QAEFL,IAAIM,uCAAuC,GAAG;IAChD;IAEA,IAAIC,QAAQP,GAAG,CAACQ,gCAAgC,KAAK,SAAS;QAC5D,4IAA4I;QAC5I,iGAAiG;QACjG,MAAMC,uBACJ;QAEF,gEAAgE;QAChE,MAAMC,6BAA6B;QAEnC,MAAMC,cAAcP,QAAQC,IAAI;QAChCD,QAAQC,IAAI,GAAG,CAAC,GAAGO;YACjB,mGAAmG;YACnG,IACE,AAAC,OAAOA,IA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E,YAAY,CAAC,CAAC;wBAClD;;;;;;;;;;;;;;;;;;cAkBE,GACFC,MAAM;oBACR;gBACF;gBACAC,SAAS;uBACHN,uBAAuBM,WAAW,EAAE;oBACxC,oFAAoF;oBACpF,IAAIP,eAAeF,OAAO,CAACU,YAAY,CAAC;wBACtCC,gBAAgB;oBAClB;iBACD;YACH;QACF;IACF;IAEA,IAAI9C,WAAW+C,QAAQ,EAAE;QACvBrB,SAASxB,GAAG,CAAC8C,cAAc,GAAGhD,WAAW+C,QAAQ;IACnD;IAEA,OAAOrB;AACT;MAEA,WAAe3B","file":"withPayload.cjs","sourcesContent":["/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n *\n * @returns {import('next').NextConfig}\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n if (process.env.PAYLOAD_PATCH_TURBOPACK_WARNINGS !== 'false') {\n // 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.\n // We can remove this once Next.js implements https://github.com/vercel/next.js/discussions/76991\n const turbopackWarningText =\n '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'\n\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const turbopackConfigWarningText = \"Unrecognized key(s) in object: 'turbopack'\"\n\n const consoleWarn = console.warn\n console.warn = (...args) => {\n // Force to disable serverExternalPackages warnings: https://github.com/vercel/next.js/issues/68805\n if (\n (typeof args[1] === 'string' && args[1].includes(turbopackWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackWarningText))\n ) {\n return\n }\n\n // Add Payload-specific message after turbopack config warning in Next.js 15.2.x or lower.\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const hasTurbopackConfigWarning =\n (typeof args[1] === 'string' && args[1].includes(turbopackConfigWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackConfigWarningText))\n\n if (hasTurbopackConfigWarning) {\n consoleWarn(...args)\n consoleWarn(\n '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.',\n )\n return\n }\n\n consoleWarn(...args)\n }\n }\n\n const isBuild = process.env.NODE_ENV === 'production'\n const isTurbopackNextjs15 = process.env.TURBOPACK === '1'\n const isTurbopackNextjs16 = process.env.TURBOPACK === 'auto'\n\n if (isBuild && (isTurbopackNextjs15 || isTurbopackNextjs16)) {\n throw new Error(\n 'Payload does not support using Turbopack for production builds. If you are using Next.js 16, please use `next build --webpack` instead.',\n )\n }\n\n const poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n }\n\n /**\n * @type {import('next').NextConfig}\n */\n const toReturn = {\n ...nextConfig,\n env,\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n source: '/:path*',\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n },\n ]\n },\n serverExternalPackages: [\n // serverExternalPackages = webpack.externals, but with turbopack support and an additional check\n // for whether the package is resolvable from the project root\n ...(nextConfig.serverExternalPackages || []),\n // Can be externalized, because we require users to install graphql themselves - we only rely on it as a peer dependency => resolvable from the project root.\n //\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.\n '@sentry/nextjs',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev for two reasons:\n *\n * 1. Performance: Fewer files to compile means faster compilation speeds.\n * 2. Turbopack support: Webpack's externals are not supported by Turbopack.\n *\n * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to\n * externalized packages that are not resolvable from the project root. So including a package like\n * \"drizzle-kit\" in here would do nothing - Next.js will ignore the rule and still bundle the package -\n * because it detects that the package is not resolvable from the project root (= not directly installed\n * by the user in their own package.json).\n *\n * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly\n * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).\n *\n *\n *\n * We should only do this during development, not build, because externalizing these packages can hurt\n * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the\n * same package.\n *\n * Example:\n * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)\n * - payload (not in bundle, external) -> installs qs-esm (external because of importer)\n * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.\n *\n * During development, these bundle size difference do not matter much, and development speed /\n * turbopack support are more important.\n */\n [\n 'payload',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/drizzle',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/payload-cloud',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n // see: https://github.com/vercel/next.js/discussions/76991\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\n * See the explanation in the serverExternalPackages section above.\n * We need to force Webpack to emit require() calls for these packages, even though they are not\n * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.\n *\n * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the\n * entry point packages, as explained in the serverExternalPackages section above.\n */\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n }\n },\n }\n\n if (nextConfig.basePath) {\n toReturn.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n return toReturn\n}\n\nexport default withPayload\n"]}