@payloadcms/next 3.65.0-internal.098b771 → 3.65.0-internal.ef335bd
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.
- package/dist/cjs/withPayload.cjs +89 -22
- package/dist/cjs/withPayload.cjs.map +1 -1
- package/dist/exports/utilities.d.ts +4 -3
- package/dist/exports/utilities.d.ts.map +1 -1
- package/dist/views/Document/getDocumentPermissions.d.ts +3 -0
- package/dist/views/Document/getDocumentPermissions.d.ts.map +1 -1
- package/dist/views/Document/getDocumentPermissions.js +21 -29
- package/dist/views/Document/getDocumentPermissions.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +25 -5
- package/dist/views/Document/index.js.map +1 -1
- package/dist/withPayload.d.ts.map +1 -1
- package/dist/withPayload.js +86 -21
- package/dist/withPayload.js.map +1 -1
- package/package.json +7 -7
package/dist/cjs/withPayload.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param {import('next').NextConfig} nextConfig
|
|
3
3
|
* @param {Object} [options] - Optional configuration options
|
|
4
|
-
* @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default
|
|
4
|
+
* @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false
|
|
5
5
|
*
|
|
6
6
|
* @returns {import('next').NextConfig}
|
|
7
7
|
* */ "use strict";
|
|
@@ -51,6 +51,12 @@ const withPayload = (nextConfig = {}, options = {})=>{
|
|
|
51
51
|
consoleWarn(...args);
|
|
52
52
|
};
|
|
53
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
|
+
}
|
|
54
60
|
const poweredByHeader = {
|
|
55
61
|
key: 'X-Powered-By',
|
|
56
62
|
value: 'Next.js, Payload'
|
|
@@ -109,35 +115,57 @@ const withPayload = (nextConfig = {}, options = {})=>{
|
|
|
109
115
|
];
|
|
110
116
|
},
|
|
111
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
|
|
112
120
|
...nextConfig.serverExternalPackages || [],
|
|
113
|
-
//
|
|
114
|
-
// that will error when trying to bundle them (e.g. drizzle-kit, libsql, esbuild etc.).
|
|
115
|
-
// We cannot externalize those problem-packages directly. We can only externalize packages that are manually installed
|
|
116
|
-
// by the end user. Otherwise, the require('externalPackage') calls generated by the bundler would fail during runtime,
|
|
117
|
-
// as you cannot import dependencies of dependencies in a lot of package managers like pnpm. We'd have to force users
|
|
118
|
-
// to install the dependencies directly.
|
|
119
|
-
// Thus, we externalize the "entry-point" = the package that is installed by the end user, which would be our db adapters.
|
|
120
|
-
//
|
|
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.
|
|
121
122
|
//
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
'@payloadcms/db-postgres',
|
|
126
|
-
'@payloadcms/db-sqlite',
|
|
127
|
-
'@payloadcms/db-vercel-postgres',
|
|
128
|
-
'@payloadcms/drizzle',
|
|
129
|
-
'@payloadcms/db-d1-sqlite',
|
|
130
|
-
// External because they install @aws-sdk/client-s3:
|
|
131
|
-
'@payloadcms/payload-cloud',
|
|
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',
|
|
132
126
|
// External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.
|
|
133
127
|
'@sentry/nextjs',
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
+
*/ [
|
|
137
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',
|
|
138
165
|
'@payloadcms/email-nodemailer',
|
|
139
166
|
'@payloadcms/email-resend',
|
|
140
167
|
'@payloadcms/graphql',
|
|
168
|
+
'@payloadcms/payload-cloud',
|
|
141
169
|
'@payloadcms/plugin-redirects'
|
|
142
170
|
] : []
|
|
143
171
|
],
|
|
@@ -147,8 +175,47 @@ const withPayload = (nextConfig = {}, options = {})=>{
|
|
|
147
175
|
...incomingWebpackConfig,
|
|
148
176
|
externals: [
|
|
149
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',
|
|
150
189
|
'require-in-the-middle'
|
|
151
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
|
+
},
|
|
152
219
|
plugins: [
|
|
153
220
|
...incomingWebpackConfig?.plugins || [],
|
|
154
221
|
// Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177
|
|
@@ -1 +1 @@
|
|
|
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","poweredByHeader","key","value","toReturn","turbopack","outputFileTracingExcludes","outputFileTracingIncludes","headers","headersFromConfig","source","serverExternalPackages","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","basePath","NEXT_BAS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,OAAO,KAAK,aAC1B9B,WAAW8B,OAAO,CAACC,eAAeC,kBAClCD;YAEN,OAAO;gBACL,GAAGE,qBAAqB;gBACxBC,WAAW;uBAAKD,uBAAuBC,aAAa,EAAE;oBAAG;iBAAwB;gBACjFC,SAAS;uBACHF,uBAAuBE,WAAW,EAAE;oBACxC,oFAAoF;oBACpF,IAAIH,eAAeF,OAAO,CAACM,YAAY,CAAC;wBACtCC,gBAAgB;oBAClB;iBACD;YACH;QACF;IACF;IAEA,IAAIrC,WAAWsC,QAAQ,EAAE;QACvBlB,SAASlB,GAAG,CAACqC,cAAc,GAAGvC,WAAWsC,QAAQ;IACnD;IAEA,OAAOlB;AACT;MAEA,WAAerB","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 true\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 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 ...(nextConfig.serverExternalPackages || []),\n // These packages always need to be external, both during dev and production. This is because they install dependencies\n // that will error when trying to bundle them (e.g. drizzle-kit, libsql, esbuild etc.).\n // We cannot externalize those problem-packages directly. We can only externalize packages that are manually installed\n // by the end user. Otherwise, the require('externalPackage') calls generated by the bundler would fail during runtime,\n // as you cannot import dependencies of dependencies in a lot of package managers like pnpm. We'd have to force users\n // to install the dependencies directly.\n // Thus, we externalize the \"entry-point\" = the package that is installed by the end user, which would be our db adapters.\n //\n //\n // External because it installs mongoose (part of default serverExternalPackages: https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/server-external-packages.json => would throw warning if we don't exclude the entry-point package):\n '@payloadcms/db-mongodb',\n // External because they install dependencies like drizzle, libsql, esbuild etc.:\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/drizzle',\n '@payloadcms/db-d1-sqlite',\n // External because they install @aws-sdk/client-s3:\n '@payloadcms/payload-cloud',\n // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.\n '@sentry/nextjs',\n // 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.\n // Do not bundle additional server-only packages during dev to improve compilation speed\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages === false\n ? [\n 'payload',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\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: [...(incomingWebpackConfig?.externals || []), 'require-in-the-middle'],\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"]}
|
|
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,C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AEN,OAAO;gBACL,GAAGE,qBAAqB;gBACxBC,WAAW;uBACLD,uBAAuBC,aAAa,EAAE;oBAC1C;;;;;;;WAOC,GACD;oBACA;oBACA;oBACA;oBACA;iBACD;gBACDC,SAAS;oBACP,GAAIF,uBAAuBE,WAAW,CAAC,CAAC;oBACxCC,OAAO;wBACL,GAAIH,uBAAuBE,SAASC,SAAS,CAAC,CAAC;oBACjD;oBACAC,UAAU;wBACR,GAAIJ,uBAAuBE,SAASE,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"]}
|
|
@@ -27,12 +27,13 @@ export declare const headersWithCors: ({ headers, req }: {
|
|
|
27
27
|
* import { createPayloadRequest } from 'payload'
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare const createPayloadRequest: ({ canSetHeaders, config: configPromise, params, request, }: {
|
|
30
|
+
export declare const createPayloadRequest: ({ canSetHeaders, config: configPromise, params, payloadInstanceCacheKey, request, }: {
|
|
31
31
|
canSetHeaders?: boolean;
|
|
32
32
|
config: Promise<import("payload").SanitizedConfig> | import("payload").SanitizedConfig;
|
|
33
33
|
params?: {
|
|
34
34
|
collection: string;
|
|
35
35
|
};
|
|
36
|
+
payloadInstanceCacheKey?: string;
|
|
36
37
|
request: Request;
|
|
37
38
|
}) => Promise<import("payload").PayloadRequest>;
|
|
38
39
|
/**
|
|
@@ -51,11 +52,11 @@ export declare const addDataAndFileToRequest: (req: import("payload").PayloadReq
|
|
|
51
52
|
* ```
|
|
52
53
|
*/
|
|
53
54
|
export declare const sanitizeLocales: ({ fallbackLocale, locale, localization, }: {
|
|
54
|
-
fallbackLocale:
|
|
55
|
+
fallbackLocale: import("payload").TypedFallbackLocale;
|
|
55
56
|
locale: string;
|
|
56
57
|
localization: import("payload").SanitizedConfig["localization"];
|
|
57
58
|
}) => {
|
|
58
|
-
fallbackLocale?:
|
|
59
|
+
fallbackLocale?: import("payload").TypedFallbackLocale;
|
|
59
60
|
locale?: string;
|
|
60
61
|
};
|
|
61
62
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/exports/utilities.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,OAAO,EAEL,2BAA2B,IAAI,4BAA4B,EAK5D,MAAM,SAAS,CAAA;AAEhB;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,kEAAgB,CAAA;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;;aAAmB,CAAA;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/exports/utilities.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,OAAO,EAEL,2BAA2B,IAAI,4BAA4B,EAK5D,MAAM,SAAS,CAAA;AAEhB;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,kEAAgB,CAAA;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;;aAAmB,CAAA;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;+CAAwB,CAAA;AAEzD;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,0DAA2B,CAAA;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;;;;;;CAAmB,CAAA;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,qCAA+B,CAAA"}
|
|
@@ -3,6 +3,9 @@ export declare const getDocumentPermissions: (args: {
|
|
|
3
3
|
collectionConfig?: SanitizedCollectionConfig;
|
|
4
4
|
data: Data;
|
|
5
5
|
globalConfig?: SanitizedGlobalConfig;
|
|
6
|
+
/**
|
|
7
|
+
* When called for creating a new document, id is not provided.
|
|
8
|
+
*/
|
|
6
9
|
id?: number | string;
|
|
7
10
|
req: PayloadRequest;
|
|
8
11
|
}) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDocumentPermissions.d.ts","sourceRoot":"","sources":["../../../src/views/Document/getDocumentPermissions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,cAAc,EACd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,sBAAsB,SAAgB;IACjD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,IAAI,EAAE,IAAI,CAAA;IACV,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC;IACV,cAAc,EAAE,4BAA4B,CAAA;IAC5C,oBAAoB,EAAE,OAAO,CAAA;IAC7B,iBAAiB,EAAE,OAAO,CAAA;CAC3B,
|
|
1
|
+
{"version":3,"file":"getDocumentPermissions.d.ts","sourceRoot":"","sources":["../../../src/views/Document/getDocumentPermissions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,cAAc,EACd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,sBAAsB,SAAgB;IACjD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,IAAI,EAAE,IAAI,CAAA;IACV,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC;IACV,cAAc,EAAE,4BAA4B,CAAA;IAC5C,oBAAoB,EAAE,OAAO,CAAA;IAC7B,iBAAiB,EAAE,OAAO,CAAA;CAC3B,CAiFA,CAAA"}
|
|
@@ -17,28 +17,24 @@ export const getDocumentPermissions = async args => {
|
|
|
17
17
|
collection: {
|
|
18
18
|
config: collectionConfig
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
...
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
}
|
|
20
|
+
data: {
|
|
21
|
+
...data,
|
|
22
|
+
_status: 'draft'
|
|
23
|
+
},
|
|
24
|
+
req
|
|
27
25
|
});
|
|
28
26
|
if (collectionConfig.versions?.drafts) {
|
|
29
|
-
hasPublishPermission = await docAccessOperation({
|
|
27
|
+
hasPublishPermission = (await docAccessOperation({
|
|
30
28
|
id,
|
|
31
29
|
collection: {
|
|
32
30
|
config: collectionConfig
|
|
33
31
|
},
|
|
34
|
-
|
|
35
|
-
...
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}).then(permissions => permissions.update);
|
|
32
|
+
data: {
|
|
33
|
+
...data,
|
|
34
|
+
_status: 'published'
|
|
35
|
+
},
|
|
36
|
+
req
|
|
37
|
+
})).update;
|
|
42
38
|
}
|
|
43
39
|
} catch (err) {
|
|
44
40
|
logError({
|
|
@@ -50,23 +46,19 @@ export const getDocumentPermissions = async args => {
|
|
|
50
46
|
if (globalConfig) {
|
|
51
47
|
try {
|
|
52
48
|
docPermissions = await docAccessOperationGlobal({
|
|
49
|
+
data,
|
|
53
50
|
globalConfig,
|
|
54
|
-
req
|
|
55
|
-
...req,
|
|
56
|
-
data
|
|
57
|
-
}
|
|
51
|
+
req
|
|
58
52
|
});
|
|
59
53
|
if (globalConfig.versions?.drafts) {
|
|
60
|
-
hasPublishPermission = await docAccessOperationGlobal({
|
|
54
|
+
hasPublishPermission = (await docAccessOperationGlobal({
|
|
55
|
+
data: {
|
|
56
|
+
...data,
|
|
57
|
+
_status: 'published'
|
|
58
|
+
},
|
|
61
59
|
globalConfig,
|
|
62
|
-
req
|
|
63
|
-
|
|
64
|
-
data: {
|
|
65
|
-
...data,
|
|
66
|
-
_status: 'published'
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}).then(permissions => permissions.update);
|
|
60
|
+
req
|
|
61
|
+
})).update;
|
|
70
62
|
}
|
|
71
63
|
} catch (err) {
|
|
72
64
|
logError({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDocumentPermissions.js","names":["hasSavePermission","getHasSavePermission","isEditing","getIsEditing","docAccessOperation","docAccessOperationGlobal","logError","getDocumentPermissions","args","id","collectionConfig","data","globalConfig","req","docPermissions","hasPublishPermission","collection","config","_status","versions","drafts","
|
|
1
|
+
{"version":3,"file":"getDocumentPermissions.js","names":["hasSavePermission","getHasSavePermission","isEditing","getIsEditing","docAccessOperation","docAccessOperationGlobal","logError","getDocumentPermissions","args","id","collectionConfig","data","globalConfig","req","docPermissions","hasPublishPermission","collection","config","_status","versions","drafts","update","err","payload","collectionSlug","slug","globalSlug"],"sources":["../../../src/views/Document/getDocumentPermissions.tsx"],"sourcesContent":["import type {\n Data,\n PayloadRequest,\n SanitizedCollectionConfig,\n SanitizedDocumentPermissions,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport {\n hasSavePermission as getHasSavePermission,\n isEditing as getIsEditing,\n} from '@payloadcms/ui/shared'\nimport { docAccessOperation, docAccessOperationGlobal, logError } from 'payload'\n\nexport const getDocumentPermissions = async (args: {\n collectionConfig?: SanitizedCollectionConfig\n data: Data\n globalConfig?: SanitizedGlobalConfig\n /**\n * When called for creating a new document, id is not provided.\n */\n id?: number | string\n req: PayloadRequest\n}): Promise<{\n docPermissions: SanitizedDocumentPermissions\n hasPublishPermission: boolean\n hasSavePermission: boolean\n}> => {\n const { id, collectionConfig, data = {}, globalConfig, req } = args\n\n let docPermissions: SanitizedDocumentPermissions\n let hasPublishPermission = false\n\n if (collectionConfig) {\n try {\n docPermissions = await docAccessOperation({\n id,\n collection: {\n config: collectionConfig,\n },\n data: {\n ...data,\n _status: 'draft',\n },\n req,\n })\n\n if (collectionConfig.versions?.drafts) {\n hasPublishPermission = (\n await docAccessOperation({\n id,\n collection: {\n config: collectionConfig,\n },\n data: {\n ...data,\n _status: 'published',\n },\n req,\n })\n ).update\n }\n } catch (err) {\n logError({ err, payload: req.payload })\n }\n }\n\n if (globalConfig) {\n try {\n docPermissions = await docAccessOperationGlobal({\n data,\n globalConfig,\n req,\n })\n\n if (globalConfig.versions?.drafts) {\n hasPublishPermission = (\n await docAccessOperationGlobal({\n data: {\n ...data,\n _status: 'published',\n },\n globalConfig,\n req,\n })\n ).update\n }\n } catch (err) {\n logError({ err, payload: req.payload })\n }\n }\n\n const hasSavePermission = getHasSavePermission({\n collectionSlug: collectionConfig?.slug,\n docPermissions,\n globalSlug: globalConfig?.slug,\n isEditing: getIsEditing({\n id,\n collectionSlug: collectionConfig?.slug,\n globalSlug: globalConfig?.slug,\n }),\n })\n\n return {\n docPermissions,\n hasPublishPermission,\n hasSavePermission,\n }\n}\n"],"mappings":"AAQA,SACEA,iBAAA,IAAqBC,oBAAoB,EACzCC,SAAA,IAAaC,YAAY,QACpB;AACP,SAASC,kBAAkB,EAAEC,wBAAwB,EAAEC,QAAQ,QAAQ;AAEvE,OAAO,MAAMC,sBAAA,GAAyB,MAAOC,IAAA;EAc3C,MAAM;IAAEC,EAAE;IAAEC,gBAAgB;IAAEC,IAAA,GAAO,CAAC,CAAC;IAAEC,YAAY;IAAEC;EAAG,CAAE,GAAGL,IAAA;EAE/D,IAAIM,cAAA;EACJ,IAAIC,oBAAA,GAAuB;EAE3B,IAAIL,gBAAA,EAAkB;IACpB,IAAI;MACFI,cAAA,GAAiB,MAAMV,kBAAA,CAAmB;QACxCK,EAAA;QACAO,UAAA,EAAY;UACVC,MAAA,EAAQP;QACV;QACAC,IAAA,EAAM;UACJ,GAAGA,IAAI;UACPO,OAAA,EAAS;QACX;QACAL;MACF;MAEA,IAAIH,gBAAA,CAAiBS,QAAQ,EAAEC,MAAA,EAAQ;QACrCL,oBAAA,GAAuB,CACrB,MAAMX,kBAAA,CAAmB;UACvBK,EAAA;UACAO,UAAA,EAAY;YACVC,MAAA,EAAQP;UACV;UACAC,IAAA,EAAM;YACJ,GAAGA,IAAI;YACPO,OAAA,EAAS;UACX;UACAL;QACF,EAAC,EACDQ,MAAM;MACV;IACF,EAAE,OAAOC,GAAA,EAAK;MACZhB,QAAA,CAAS;QAAEgB,GAAA;QAAKC,OAAA,EAASV,GAAA,CAAIU;MAAQ;IACvC;EACF;EAEA,IAAIX,YAAA,EAAc;IAChB,IAAI;MACFE,cAAA,GAAiB,MAAMT,wBAAA,CAAyB;QAC9CM,IAAA;QACAC,YAAA;QACAC;MACF;MAEA,IAAID,YAAA,CAAaO,QAAQ,EAAEC,MAAA,EAAQ;QACjCL,oBAAA,GAAuB,CACrB,MAAMV,wBAAA,CAAyB;UAC7BM,IAAA,EAAM;YACJ,GAAGA,IAAI;YACPO,OAAA,EAAS;UACX;UACAN,YAAA;UACAC;QACF,EAAC,EACDQ,MAAM;MACV;IACF,EAAE,OAAOC,GAAA,EAAK;MACZhB,QAAA,CAAS;QAAEgB,GAAA;QAAKC,OAAA,EAASV,GAAA,CAAIU;MAAQ;IACvC;EACF;EAEA,MAAMvB,iBAAA,GAAoBC,oBAAA,CAAqB;IAC7CuB,cAAA,EAAgBd,gBAAA,EAAkBe,IAAA;IAClCX,cAAA;IACAY,UAAA,EAAYd,YAAA,EAAca,IAAA;IAC1BvB,SAAA,EAAWC,YAAA,CAAa;MACtBM,EAAA;MACAe,cAAA,EAAgBd,gBAAA,EAAkBe,IAAA;MAClCC,UAAA,EAAYd,YAAA,EAAca;IAC5B;EACF;EAEA,OAAO;IACLX,cAAA;IACAC,oBAAA;IACAf;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Document/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,IAAI,EACJ,uBAAuB,EACvB,uBAAuB,EAEvB,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EACjC,MAAM,SAAS,CAAA;AAehB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAcrE,eAAO,MAAM,gBAAgB,EAAE,wBAAiE,CAAA;AAEhG,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,gBAAgB,CAAC,uBAAuB,CAAC,GACzC,KAA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OAAO,CAAA;IACtC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IACtC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAA;IACzC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IACvC,QAAQ,CAAC,EAAE,gCAAgC,CAAA;CAC5C,GAAG,oBAAoB,KAAG,OAAO,CAAC;IACjC,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAqXA,CAAA;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,oBAAoB,+QAe7D"}
|
|
@@ -5,7 +5,7 @@ import { handleLivePreview, handlePreview } from '@payloadcms/ui/rsc';
|
|
|
5
5
|
import { isEditing as getIsEditing } from '@payloadcms/ui/shared';
|
|
6
6
|
import { buildFormState } from '@payloadcms/ui/utilities/buildFormState';
|
|
7
7
|
import { notFound, redirect } from 'next/navigation.js';
|
|
8
|
-
import { logError } from 'payload';
|
|
8
|
+
import { isolateObjectProperty, logError } from 'payload';
|
|
9
9
|
import { formatAdminURL } from 'payload/shared';
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import { DocumentHeader } from '../../elements/DocumentHeader/index.js';
|
|
@@ -101,6 +101,26 @@ export const renderDocument = async ({
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
const isTrashedDoc = Boolean(doc && 'deletedAt' in doc && typeof doc?.deletedAt === 'string');
|
|
104
|
+
// CRITICAL FIX FOR TRANSACTION RACE CONDITION:
|
|
105
|
+
// When running parallel operations with Promise.all, if they share the same req object
|
|
106
|
+
// and one operation calls initTransaction() which MUTATES req.transactionID, that mutation
|
|
107
|
+
// is visible to all parallel operations. This causes:
|
|
108
|
+
// 1. Operation A (e.g., getDocumentPermissions → docAccessOperation) calls initTransaction()
|
|
109
|
+
// which sets req.transactionID = Promise, then resolves it to a UUID
|
|
110
|
+
// 2. Operation B (e.g., getIsLocked) running in parallel receives the SAME req with the mutated transactionID
|
|
111
|
+
// 3. Operation A (does not even know that Operation B even exists and is stil using the transactionID) commits/ends its transaction
|
|
112
|
+
// 4. Operation B tries to use the now-expired session → MongoExpiredSessionError!
|
|
113
|
+
//
|
|
114
|
+
// Solution: Use isolateObjectProperty to create a Proxy that isolates the 'transactionID' property.
|
|
115
|
+
// This allows each operation to have its own transactionID without affecting the parent req.
|
|
116
|
+
// If parent req already has a transaction, preserve it (don't isolate), since this
|
|
117
|
+
// issue only arises when one of the operations calls initTransaction() themselves -
|
|
118
|
+
// because then, that operation will also try to commit/end the transaction itself.
|
|
119
|
+
// If the transactionID is already set, the parallel operations will not try to
|
|
120
|
+
// commit/end the transaction themselves, so we don't need to isolate the
|
|
121
|
+
// transactionID property.
|
|
122
|
+
const reqForPermissions = req.transactionID ? req : isolateObjectProperty(req, 'transactionID');
|
|
123
|
+
const reqForLockCheck = req.transactionID ? req : isolateObjectProperty(req, 'transactionID');
|
|
104
124
|
const [docPreferences, {
|
|
105
125
|
docPermissions,
|
|
106
126
|
hasPublishPermission,
|
|
@@ -118,21 +138,21 @@ export const renderDocument = async ({
|
|
|
118
138
|
payload,
|
|
119
139
|
user
|
|
120
140
|
}),
|
|
121
|
-
// Get permissions
|
|
141
|
+
// Get permissions - isolated transactionID prevents cross-contamination
|
|
122
142
|
getDocumentPermissions({
|
|
123
143
|
id: idFromArgs,
|
|
124
144
|
collectionConfig,
|
|
125
145
|
data: doc,
|
|
126
146
|
globalConfig,
|
|
127
|
-
req
|
|
147
|
+
req: reqForPermissions
|
|
128
148
|
}),
|
|
129
|
-
// Fetch document lock state
|
|
149
|
+
// Fetch document lock state - isolated transactionID prevents cross-contamination
|
|
130
150
|
getIsLocked({
|
|
131
151
|
id: idFromArgs,
|
|
132
152
|
collectionConfig,
|
|
133
153
|
globalConfig,
|
|
134
154
|
isEditing,
|
|
135
|
-
req
|
|
155
|
+
req: reqForLockCheck
|
|
136
156
|
}),
|
|
137
157
|
// get entity preferences
|
|
138
158
|
getPreferences(collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`, payload, req.user.id, req.user.collection)]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","LivePreviewProvider","RenderServerComponent","handleLivePreview","handlePreview","isEditing","getIsEditing","buildFormState","notFound","redirect","logError","formatAdminURL","React","DocumentHeader","getPreferences","NotFoundView","getDocPreferences","getDocumentData","getDocumentPermissions","getDocumentView","getIsLocked","getMetaBySegment","getVersions","renderDocumentSlots","generateMetadata","args","renderDocument","disableActions","documentSubViewType","drawerSlug","importMap","initialData","initPageResult","overrideEntityVisibility","params","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","redirectAfterRestore","searchParams","versions","viewType","collectionConfig","docID","idFromArgs","globalConfig","locale","permissions","req","i18n","payload","config","routes","admin","adminRoute","api","apiRoute","serverURL","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","id","doc","redirectURL","path","encodeURIComponent","Error","isTrashedDoc","Boolean","deletedAt","docPreferences","docPermissions","hasPublishPermission","hasSavePermission","currentEditor","isLocked","lastUpdateTime","entityPreferences","Promise","all","data","collection","operation","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","state","formState","code","fallbackLocale","readOnly","renderAllFields","schemaPath","skipValidation","documentViewServerProps","routeSegments","collections","find","visibleSlug","globals","formattedParams","URLSearchParams","drafts","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","autosave","validateDraftData","validate","create","depth","draft","documentSlots","Description","clientProps","isLivePreviewEnabled","livePreviewConfig","livePreviewURL","isPreviewEnabled","previewURL","Document","_jsx","initialState","isTrashed","_jsxs","breakpoints","isLivePreviewing","value","editViewType","typeofLivePreviewURL","url","AfterHeader","serverProps","DocumentView","props","RenderedDocument","error","message","err"],"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n Data,\n DocumentViewClientProps,\n DocumentViewServerProps,\n DocumentViewServerPropsOnly,\n EditViewComponent,\n PayloadComponent,\n RenderDocumentVersionsProperties,\n} from 'payload'\n\nimport {\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n LivePreviewProvider,\n} from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { handleLivePreview, handlePreview } from '@payloadcms/ui/rsc'\nimport { isEditing as getIsEditing } from '@payloadcms/ui/shared'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { logError } from 'payload'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { NotFoundView } from '../NotFound/index.js'\nimport { getDocPreferences } from './getDocPreferences.js'\nimport { getDocumentData } from './getDocumentData.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\nimport { getDocumentView } from './getDocumentView.js'\nimport { getIsLocked } from './getIsLocked.js'\nimport { getMetaBySegment } from './getMetaBySegment.js'\nimport { getVersions } from './getVersions.js'\nimport { renderDocumentSlots } from './renderDocumentSlots.js'\n\nexport const generateMetadata: GenerateEditViewMetadata = async (args) => getMetaBySegment(args)\n\nexport type ViewToRender =\n | EditViewComponent\n | PayloadComponent<DocumentViewServerProps>\n | React.FC\n | React.FC<DocumentViewClientProps>\n\n/**\n * This function is responsible for rendering\n * an Edit Document view on the server for both:\n * - default document edit views\n * - on-demand edit views within drawers\n */\nexport const renderDocument = async ({\n disableActions,\n documentSubViewType,\n drawerSlug,\n importMap,\n initialData,\n initPageResult,\n overrideEntityVisibility,\n params,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n redirectAfterRestore,\n searchParams,\n versions,\n viewType,\n}: {\n drawerSlug?: string\n overrideEntityVisibility?: boolean\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n readonly redirectAfterRestore?: boolean\n versions?: RenderDocumentVersionsProperties\n} & AdminViewServerProps): Promise<{\n data: Data\n Document: React.ReactNode\n}> => {\n const {\n collectionConfig,\n docID: idFromArgs,\n globalConfig,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: {\n config,\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n serverURL,\n },\n },\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const segments = Array.isArray(params?.segments) ? params.segments : []\n const collectionSlug = collectionConfig?.slug || undefined\n const globalSlug = globalConfig?.slug || undefined\n let isEditing = getIsEditing({ id: idFromArgs, collectionSlug, globalSlug })\n\n // Fetch the doc required for the view\n let doc =\n !idFromArgs && !globalSlug\n ? initialData || null\n : await getDocumentData({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n locale,\n payload,\n req,\n segments,\n user,\n })\n\n if (isEditing && !doc) {\n // If it's a collection document that doesn't exist, redirect to collection list\n if (collectionSlug) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}?notFound=${encodeURIComponent(idFromArgs)}`,\n serverURL,\n })\n redirect(redirectURL)\n } else {\n // For globals or other cases, keep the 404 behavior\n throw new Error('not-found')\n }\n }\n\n const isTrashedDoc = Boolean(doc && 'deletedAt' in doc && typeof doc?.deletedAt === 'string')\n\n const [\n docPreferences,\n { docPermissions, hasPublishPermission, hasSavePermission },\n { currentEditor, isLocked, lastUpdateTime },\n entityPreferences,\n ] = await Promise.all([\n // Get document preferences\n getDocPreferences({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n payload,\n user,\n }),\n\n // Get permissions\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req,\n }),\n\n // Fetch document lock state\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req,\n }),\n\n // get entity preferences\n getPreferences<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n payload,\n req.user.id,\n req.user.collection,\n ),\n ])\n\n const operation = (collectionSlug && idFromArgs) || globalSlug ? 'update' : 'create'\n\n const [\n { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount },\n { state: formState },\n ] = await Promise.all([\n getVersions({\n id: idFromArgs,\n collectionConfig,\n doc,\n docPermissions,\n globalConfig,\n locale: locale?.code,\n payload,\n user,\n }),\n buildFormState({\n id: idFromArgs,\n collectionSlug,\n data: doc,\n docPermissions,\n docPreferences,\n fallbackLocale: false,\n globalSlug,\n locale: locale?.code,\n operation,\n readOnly: isTrashedDoc || isLocked,\n renderAllFields: true,\n req,\n schemaPath: collectionSlug || globalSlug,\n skipValidation: true,\n }),\n ])\n\n const documentViewServerProps: DocumentViewServerPropsOnly = {\n doc,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n user,\n versions,\n }\n\n if (\n !overrideEntityVisibility &&\n ((collectionSlug &&\n !visibleEntities?.collections?.find((visibleSlug) => visibleSlug === collectionSlug)) ||\n (globalSlug && !visibleEntities?.globals?.find((visibleSlug) => visibleSlug === globalSlug)))\n ) {\n throw new Error('not-found')\n }\n\n const formattedParams = new URLSearchParams()\n\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n formattedParams.append('draft', 'true')\n }\n\n if (locale?.code) {\n formattedParams.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${formattedParams.toString()}`\n\n const apiURL = collectionSlug\n ? `${serverURL}${apiRoute}/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `${serverURL}${apiRoute}/${globalSlug}${apiQueryParams}`\n : ''\n\n let View: ViewToRender = null\n\n let showHeader = true\n\n const RootViewOverride =\n collectionConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in collectionConfig.admin.components.views.edit.root\n ? collectionConfig?.admin?.components?.views?.edit?.root?.Component\n : globalConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in globalConfig.admin.components.views.edit.root\n ? globalConfig?.admin?.components?.views?.edit?.root?.Component\n : null\n\n if (RootViewOverride) {\n View = RootViewOverride\n showHeader = false\n } else {\n ;({ View } = getDocumentView({\n collectionConfig,\n config,\n docPermissions,\n globalConfig,\n routeSegments: segments,\n }))\n }\n\n if (!View) {\n View = NotFoundView\n }\n\n /**\n * Handle case where autoSave is enabled and the document is being created\n * => create document and redirect\n */\n const shouldAutosave =\n hasSavePermission &&\n ((collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave))\n\n const validateDraftData =\n collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.validate\n\n let id = idFromArgs\n\n if (shouldAutosave && !validateDraftData && !idFromArgs && collectionSlug) {\n doc = await payload.create({\n collection: collectionSlug,\n data: initialData || {},\n depth: 0,\n draft: true,\n fallbackLocale: false,\n locale: locale?.code,\n req,\n user,\n })\n\n if (doc?.id) {\n id = doc.id\n isEditing = getIsEditing({ id: doc.id, collectionSlug, globalSlug })\n\n if (!drawerSlug && redirectAfterCreate !== false) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${doc.id}`,\n serverURL,\n })\n\n redirect(redirectURL)\n }\n } else {\n throw new Error('not-found')\n }\n }\n\n const documentSlots = renderDocumentSlots({\n id,\n collectionConfig,\n globalConfig,\n hasSavePermission,\n permissions: docPermissions,\n req,\n })\n\n // Extract Description from documentSlots to pass to DocumentHeader\n const { Description } = documentSlots\n\n const clientProps: DocumentViewClientProps = {\n formState,\n ...documentSlots,\n documentSubViewType,\n viewType,\n }\n\n const { isLivePreviewEnabled, livePreviewConfig, livePreviewURL } = await handleLivePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n const { isPreviewEnabled, previewURL } = await handlePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n return {\n data: doc,\n Document: (\n <DocumentInfoProvider\n apiURL={apiURL}\n collectionSlug={collectionConfig?.slug}\n currentEditor={currentEditor}\n disableActions={disableActions ?? false}\n docPermissions={docPermissions}\n globalSlug={globalConfig?.slug}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={id}\n initialData={doc}\n initialState={formState}\n isEditing={isEditing}\n isLocked={isLocked}\n isTrashed={isTrashedDoc}\n key={locale?.code}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n redirectAfterCreate={redirectAfterCreate}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n redirectAfterRestore={redirectAfterRestore}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <LivePreviewProvider\n breakpoints={livePreviewConfig?.breakpoints}\n isLivePreviewEnabled={isLivePreviewEnabled && operation !== 'create'}\n isLivePreviewing={Boolean(\n entityPreferences?.value?.editViewType === 'live-preview' && livePreviewURL,\n )}\n isPreviewEnabled={Boolean(isPreviewEnabled)}\n previewURL={previewURL}\n typeofLivePreviewURL={typeof livePreviewConfig?.url as 'function' | 'string' | undefined}\n url={livePreviewURL}\n >\n {showHeader && !drawerSlug && (\n <DocumentHeader\n AfterHeader={Description}\n collectionConfig={collectionConfig}\n globalConfig={globalConfig}\n permissions={permissions}\n req={req}\n />\n )}\n <HydrateAuthProvider permissions={permissions} />\n <EditDepthProvider>\n {RenderServerComponent({\n clientProps,\n Component: View,\n importMap,\n serverProps: documentViewServerProps,\n })}\n </EditDepthProvider>\n </LivePreviewProvider>\n </DocumentInfoProvider>\n ),\n }\n}\n\nexport async function DocumentView(props: AdminViewServerProps) {\n try {\n const { Document: RenderedDocument } = await renderDocument(props)\n return RenderedDocument\n } catch (error) {\n if (error?.message === 'NEXT_REDIRECT') {\n throw error\n }\n\n logError({ err: error, payload: props.initPageResult.req.payload })\n\n if (error.message === 'not-found') {\n notFound()\n }\n }\n}\n"],"mappings":";AAYA,SACEA,oBAAoB,EACpBC,iBAAiB,EACjBC,mBAAmB,EACnBC,mBAAmB,QACd;AACP,SAASC,qBAAqB,QAAQ;AACtC,SAASC,iBAAiB,EAAEC,aAAa,QAAQ;AACjD,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,eAAe,QAAQ;AAChC,SAASC,WAAW,QAAQ;AAC5B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,WAAW,QAAQ;AAC5B,SAASC,mBAAmB,QAAQ;AAEpC,OAAO,MAAMC,gBAAA,GAA6C,MAAOC,IAAA,IAASJ,gBAAA,CAAiBI,IAAA;AAQ3F;;;;;;AAMA,OAAO,MAAMC,cAAA,GAAiB,MAAAA,CAAO;EACnCC,cAAc;EACdC,mBAAmB;EACnBC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,cAAc;EACdC,wBAAwB;EACxBC,MAAM;EACNC,mBAAmB;EACnBC,mBAAmB;EACnBC,sBAAsB;EACtBC,oBAAoB;EACpBC,YAAY;EACZC,QAAQ;EACRC;AAAQ,CASc;EAItB,MAAM;IACJC,gBAAgB;IAChBC,KAAA,EAAOC,UAAU;IACjBC,YAAY;IACZC,MAAM;IACNC,WAAW;IACXC,G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AChBS,iBAAA,EAAmB6D,KAAA,EAAOC,YAAA,KAAiB,kBAAkBX,cAAA;QAE/DC,gBAAA,EAAkB7D,OAAA,CAAQ6D,gBAAA;QAC1BC,UAAA,EAAYA,UAAA;QACZU,oBAAA,EAAsB,OAAOb,iBAAA,EAAmBc,GAAA;QAChDA,GAAA,EAAKb,cAAA;mBAEJnB,UAAA,IAAc,CAACtF,UAAA,iBACd6G,IAAA,CAAC7H,cAAA;UACCuI,WAAA,EAAalB,WAAA;UACbxF,gBAAA,EAAkBA,gBAAA;UAClBG,YAAA,EAAcA,YAAA;UACdE,WAAA,EAAaA,WAAA;UACbC,GAAA,EAAKA;yBAGT0F,IAAA,CAAC1I,mBAAA;UAAoB+C,WAAA,EAAaA;yBAClC2F,IAAA,CAAC3I,iBAAA;oBACEG,qBAAA,CAAsB;YACrBiI,WAAA;YACAV,SAAA,EAAWP,IAAA;YACXpF,SAAA;YACAuH,WAAA,EAAahD;UACf;;;OArCCvD,MAAA,EAAQiD,IAAA;EA0CnB;AACF;AAEA,OAAO,eAAeuD,aAAaC,KAA2B;EAC5D,IAAI;IACF,MAAM;MAAEd,QAAA,EAAUe;IAAgB,CAAE,GAAG,MAAM9H,cAAA,CAAe6H,KAAA;IAC5D,OAAOC,gBAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,EAAOC,OAAA,KAAY,iBAAiB;MACtC,MAAMD,KAAA;IACR;IAEA/I,QAAA,CAAS;MAAEiJ,GAAA,EAAKF,KAAA;MAAOvG,OAAA,EAASqG,KAAA,CAAMvH,cAAc,CAACgB,GAAG,CAACE;IAAQ;IAEjE,IAAIuG,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjClJ,QAAA;IACF;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","LivePreviewProvider","RenderServerComponent","handleLivePreview","handlePreview","isEditing","getIsEditing","buildFormState","notFound","redirect","isolateObjectProperty","logError","formatAdminURL","React","DocumentHeader","getPreferences","NotFoundView","getDocPreferences","getDocumentData","getDocumentPermissions","getDocumentView","getIsLocked","getMetaBySegment","getVersions","renderDocumentSlots","generateMetadata","args","renderDocument","disableActions","documentSubViewType","drawerSlug","importMap","initialData","initPageResult","overrideEntityVisibility","params","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","redirectAfterRestore","searchParams","versions","viewType","collectionConfig","docID","idFromArgs","globalConfig","locale","permissions","req","i18n","payload","config","routes","admin","adminRoute","api","apiRoute","serverURL","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","id","doc","redirectURL","path","encodeURIComponent","Error","isTrashedDoc","Boolean","deletedAt","reqForPermissions","transactionID","reqForLockCheck","docPreferences","docPermissions","hasPublishPermission","hasSavePermission","currentEditor","isLocked","lastUpdateTime","entityPreferences","Promise","all","data","collection","operation","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","state","formState","code","fallbackLocale","readOnly","renderAllFields","schemaPath","skipValidation","documentViewServerProps","routeSegments","collections","find","visibleSlug","globals","formattedParams","URLSearchParams","drafts","append","apiQueryParams","toString","apiURL","View","showHeader","RootViewOverride","components","views","edit","root","Component","shouldAutosave","autosave","validateDraftData","validate","create","depth","draft","documentSlots","Description","clientProps","isLivePreviewEnabled","livePreviewConfig","livePreviewURL","isPreviewEnabled","previewURL","Document","_jsx","initialState","isTrashed","_jsxs","breakpoints","isLivePreviewing","value","editViewType","typeofLivePreviewURL","url","AfterHeader","serverProps","DocumentView","props","RenderedDocument","error","message","err"],"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n CollectionPreferences,\n Data,\n DocumentViewClientProps,\n DocumentViewServerProps,\n DocumentViewServerPropsOnly,\n EditViewComponent,\n PayloadComponent,\n RenderDocumentVersionsProperties,\n} from 'payload'\n\nimport {\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n LivePreviewProvider,\n} from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { handleLivePreview, handlePreview } from '@payloadcms/ui/rsc'\nimport { isEditing as getIsEditing } from '@payloadcms/ui/shared'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { isolateObjectProperty, logError } from 'payload'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { NotFoundView } from '../NotFound/index.js'\nimport { getDocPreferences } from './getDocPreferences.js'\nimport { getDocumentData } from './getDocumentData.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\nimport { getDocumentView } from './getDocumentView.js'\nimport { getIsLocked } from './getIsLocked.js'\nimport { getMetaBySegment } from './getMetaBySegment.js'\nimport { getVersions } from './getVersions.js'\nimport { renderDocumentSlots } from './renderDocumentSlots.js'\n\nexport const generateMetadata: GenerateEditViewMetadata = async (args) => getMetaBySegment(args)\n\nexport type ViewToRender =\n | EditViewComponent\n | PayloadComponent<DocumentViewServerProps>\n | React.FC\n | React.FC<DocumentViewClientProps>\n\n/**\n * This function is responsible for rendering\n * an Edit Document view on the server for both:\n * - default document edit views\n * - on-demand edit views within drawers\n */\nexport const renderDocument = async ({\n disableActions,\n documentSubViewType,\n drawerSlug,\n importMap,\n initialData,\n initPageResult,\n overrideEntityVisibility,\n params,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n redirectAfterRestore,\n searchParams,\n versions,\n viewType,\n}: {\n drawerSlug?: string\n overrideEntityVisibility?: boolean\n readonly redirectAfterCreate?: boolean\n readonly redirectAfterDelete?: boolean\n readonly redirectAfterDuplicate?: boolean\n readonly redirectAfterRestore?: boolean\n versions?: RenderDocumentVersionsProperties\n} & AdminViewServerProps): Promise<{\n data: Data\n Document: React.ReactNode\n}> => {\n const {\n collectionConfig,\n docID: idFromArgs,\n globalConfig,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: {\n config,\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n serverURL,\n },\n },\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const segments = Array.isArray(params?.segments) ? params.segments : []\n const collectionSlug = collectionConfig?.slug || undefined\n const globalSlug = globalConfig?.slug || undefined\n let isEditing = getIsEditing({ id: idFromArgs, collectionSlug, globalSlug })\n\n // Fetch the doc required for the view\n let doc =\n !idFromArgs && !globalSlug\n ? initialData || null\n : await getDocumentData({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n locale,\n payload,\n req,\n segments,\n user,\n })\n\n if (isEditing && !doc) {\n // If it's a collection document that doesn't exist, redirect to collection list\n if (collectionSlug) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}?notFound=${encodeURIComponent(idFromArgs)}`,\n serverURL,\n })\n redirect(redirectURL)\n } else {\n // For globals or other cases, keep the 404 behavior\n throw new Error('not-found')\n }\n }\n\n const isTrashedDoc = Boolean(doc && 'deletedAt' in doc && typeof doc?.deletedAt === 'string')\n\n // CRITICAL FIX FOR TRANSACTION RACE CONDITION:\n // When running parallel operations with Promise.all, if they share the same req object\n // and one operation calls initTransaction() which MUTATES req.transactionID, that mutation\n // is visible to all parallel operations. This causes:\n // 1. Operation A (e.g., getDocumentPermissions → docAccessOperation) calls initTransaction()\n // which sets req.transactionID = Promise, then resolves it to a UUID\n // 2. Operation B (e.g., getIsLocked) running in parallel receives the SAME req with the mutated transactionID\n // 3. Operation A (does not even know that Operation B even exists and is stil using the transactionID) commits/ends its transaction\n // 4. Operation B tries to use the now-expired session → MongoExpiredSessionError!\n //\n // Solution: Use isolateObjectProperty to create a Proxy that isolates the 'transactionID' property.\n // This allows each operation to have its own transactionID without affecting the parent req.\n // If parent req already has a transaction, preserve it (don't isolate), since this\n // issue only arises when one of the operations calls initTransaction() themselves -\n // because then, that operation will also try to commit/end the transaction itself.\n\n // If the transactionID is already set, the parallel operations will not try to\n // commit/end the transaction themselves, so we don't need to isolate the\n // transactionID property.\n const reqForPermissions = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n const reqForLockCheck = req.transactionID ? req : isolateObjectProperty(req, 'transactionID')\n\n const [\n docPreferences,\n { docPermissions, hasPublishPermission, hasSavePermission },\n { currentEditor, isLocked, lastUpdateTime },\n entityPreferences,\n ] = await Promise.all([\n // Get document preferences\n getDocPreferences({\n id: idFromArgs,\n collectionSlug,\n globalSlug,\n payload,\n user,\n }),\n\n // Get permissions - isolated transactionID prevents cross-contamination\n getDocumentPermissions({\n id: idFromArgs,\n collectionConfig,\n data: doc,\n globalConfig,\n req: reqForPermissions,\n }),\n\n // Fetch document lock state - isolated transactionID prevents cross-contamination\n getIsLocked({\n id: idFromArgs,\n collectionConfig,\n globalConfig,\n isEditing,\n req: reqForLockCheck,\n }),\n\n // get entity preferences\n getPreferences<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n payload,\n req.user.id,\n req.user.collection,\n ),\n ])\n\n const operation = (collectionSlug && idFromArgs) || globalSlug ? 'update' : 'create'\n\n const [\n { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount },\n { state: formState },\n ] = await Promise.all([\n getVersions({\n id: idFromArgs,\n collectionConfig,\n doc,\n docPermissions,\n globalConfig,\n locale: locale?.code,\n payload,\n user,\n }),\n buildFormState({\n id: idFromArgs,\n collectionSlug,\n data: doc,\n docPermissions,\n docPreferences,\n fallbackLocale: false,\n globalSlug,\n locale: locale?.code,\n operation,\n readOnly: isTrashedDoc || isLocked,\n renderAllFields: true,\n req,\n schemaPath: collectionSlug || globalSlug,\n skipValidation: true,\n }),\n ])\n\n const documentViewServerProps: DocumentViewServerPropsOnly = {\n doc,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n user,\n versions,\n }\n\n if (\n !overrideEntityVisibility &&\n ((collectionSlug &&\n !visibleEntities?.collections?.find((visibleSlug) => visibleSlug === collectionSlug)) ||\n (globalSlug && !visibleEntities?.globals?.find((visibleSlug) => visibleSlug === globalSlug)))\n ) {\n throw new Error('not-found')\n }\n\n const formattedParams = new URLSearchParams()\n\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n formattedParams.append('draft', 'true')\n }\n\n if (locale?.code) {\n formattedParams.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${formattedParams.toString()}`\n\n const apiURL = collectionSlug\n ? `${serverURL}${apiRoute}/${collectionSlug}/${idFromArgs}${apiQueryParams}`\n : globalSlug\n ? `${serverURL}${apiRoute}/${globalSlug}${apiQueryParams}`\n : ''\n\n let View: ViewToRender = null\n\n let showHeader = true\n\n const RootViewOverride =\n collectionConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in collectionConfig.admin.components.views.edit.root\n ? collectionConfig?.admin?.components?.views?.edit?.root?.Component\n : globalConfig?.admin?.components?.views?.edit?.root &&\n 'Component' in globalConfig.admin.components.views.edit.root\n ? globalConfig?.admin?.components?.views?.edit?.root?.Component\n : null\n\n if (RootViewOverride) {\n View = RootViewOverride\n showHeader = false\n } else {\n ;({ View } = getDocumentView({\n collectionConfig,\n config,\n docPermissions,\n globalConfig,\n routeSegments: segments,\n }))\n }\n\n if (!View) {\n View = NotFoundView\n }\n\n /**\n * Handle case where autoSave is enabled and the document is being created\n * => create document and redirect\n */\n const shouldAutosave =\n hasSavePermission &&\n ((collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave))\n\n const validateDraftData =\n collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.validate\n\n let id = idFromArgs\n\n if (shouldAutosave && !validateDraftData && !idFromArgs && collectionSlug) {\n doc = await payload.create({\n collection: collectionSlug,\n data: initialData || {},\n depth: 0,\n draft: true,\n fallbackLocale: false,\n locale: locale?.code,\n req,\n user,\n })\n\n if (doc?.id) {\n id = doc.id\n isEditing = getIsEditing({ id: doc.id, collectionSlug, globalSlug })\n\n if (!drawerSlug && redirectAfterCreate !== false) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${doc.id}`,\n serverURL,\n })\n\n redirect(redirectURL)\n }\n } else {\n throw new Error('not-found')\n }\n }\n\n const documentSlots = renderDocumentSlots({\n id,\n collectionConfig,\n globalConfig,\n hasSavePermission,\n permissions: docPermissions,\n req,\n })\n\n // Extract Description from documentSlots to pass to DocumentHeader\n const { Description } = documentSlots\n\n const clientProps: DocumentViewClientProps = {\n formState,\n ...documentSlots,\n documentSubViewType,\n viewType,\n }\n\n const { isLivePreviewEnabled, livePreviewConfig, livePreviewURL } = await handleLivePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n const { isPreviewEnabled, previewURL } = await handlePreview({\n collectionSlug,\n config,\n data: doc,\n globalSlug,\n operation,\n req,\n })\n\n return {\n data: doc,\n Document: (\n <DocumentInfoProvider\n apiURL={apiURL}\n collectionSlug={collectionConfig?.slug}\n currentEditor={currentEditor}\n disableActions={disableActions ?? false}\n docPermissions={docPermissions}\n globalSlug={globalConfig?.slug}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={id}\n initialData={doc}\n initialState={formState}\n isEditing={isEditing}\n isLocked={isLocked}\n isTrashed={isTrashedDoc}\n key={locale?.code}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n redirectAfterCreate={redirectAfterCreate}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n redirectAfterRestore={redirectAfterRestore}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <LivePreviewProvider\n breakpoints={livePreviewConfig?.breakpoints}\n isLivePreviewEnabled={isLivePreviewEnabled && operation !== 'create'}\n isLivePreviewing={Boolean(\n entityPreferences?.value?.editViewType === 'live-preview' && livePreviewURL,\n )}\n isPreviewEnabled={Boolean(isPreviewEnabled)}\n previewURL={previewURL}\n typeofLivePreviewURL={typeof livePreviewConfig?.url as 'function' | 'string' | undefined}\n url={livePreviewURL}\n >\n {showHeader && !drawerSlug && (\n <DocumentHeader\n AfterHeader={Description}\n collectionConfig={collectionConfig}\n globalConfig={globalConfig}\n permissions={permissions}\n req={req}\n />\n )}\n <HydrateAuthProvider permissions={permissions} />\n <EditDepthProvider>\n {RenderServerComponent({\n clientProps,\n Component: View,\n importMap,\n serverProps: documentViewServerProps,\n })}\n </EditDepthProvider>\n </LivePreviewProvider>\n </DocumentInfoProvider>\n ),\n }\n}\n\nexport async function DocumentView(props: AdminViewServerProps) {\n try {\n const { Document: RenderedDocument } = await renderDocument(props)\n return RenderedDocument\n } catch (error) {\n if (error?.message === 'NEXT_REDIRECT') {\n throw error\n }\n\n logError({ err: error, payload: props.initPageResult.req.payload })\n\n if (error.message === 'not-found') {\n notFound()\n }\n }\n}\n"],"mappings":";AAYA,SACEA,oBAAoB,EACpBC,iBAAiB,EACjBC,mBAAmB,EACnBC,mBAAmB,QACd;AACP,SAASC,qBAAqB,QAAQ;AACtC,SAASC,iBAAiB,EAAEC,aAAa,QAAQ;AACjD,SAASC,SAAA,IAAaC,YAAY,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,qBAAqB,EAAEC,QAAQ,QAAQ;AAChD,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,sB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AkBA,gBAAA;UAClBG,YAAA,EAAcA,YAAA;UACdE,WAAA,EAAaA,WAAA;UACbC,GAAA,EAAKA;yBAGT6F,IAAA,CAAC9I,mBAAA;UAAoBgD,WAAA,EAAaA;yBAClC8F,IAAA,CAAC/I,iBAAA;oBACEG,qBAAA,CAAsB;YACrBqI,WAAA;YACAV,SAAA,EAAWP,IAAA;YACXvF,SAAA;YACA0H,WAAA,EAAahD;UACf;;;OArCC1D,MAAA,EAAQoD,IAAA;EA0CnB;AACF;AAEA,OAAO,eAAeuD,aAAaC,KAA2B;EAC5D,IAAI;IACF,MAAM;MAAEd,QAAA,EAAUe;IAAgB,CAAE,GAAG,MAAMjI,cAAA,CAAegI,KAAA;IAC5D,OAAOC,gBAAA;EACT,EAAE,OAAOC,KAAA,EAAO;IACd,IAAIA,KAAA,EAAOC,OAAA,KAAY,iBAAiB;MACtC,MAAMD,KAAA;IACR;IAEAlJ,QAAA,CAAS;MAAEoJ,GAAA,EAAKF,KAAA;MAAO1G,OAAA,EAASwG,KAAA,CAAM1H,cAAc,CAACgB,GAAG,CAACE;IAAQ;IAEjE,IAAI0G,KAAA,CAAMC,OAAO,KAAK,aAAa;MACjCtJ,QAAA;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -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,
|
|
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"}
|
package/dist/withPayload.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param {import('next').NextConfig} nextConfig
|
|
3
3
|
* @param {Object} [options] - Optional configuration options
|
|
4
|
-
* @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default
|
|
4
|
+
* @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false
|
|
5
5
|
*
|
|
6
6
|
* @returns {import('next').NextConfig}
|
|
7
7
|
* */export const withPayload = (nextConfig = {}, options = {}) => {
|
|
@@ -33,6 +33,12 @@
|
|
|
33
33
|
consoleWarn(...args);
|
|
34
34
|
};
|
|
35
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
|
+
}
|
|
36
42
|
const poweredByHeader = {
|
|
37
43
|
key: 'X-Powered-By',
|
|
38
44
|
value: 'Next.js, Payload'
|
|
@@ -74,32 +80,91 @@
|
|
|
74
80
|
}, ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : [])]
|
|
75
81
|
}];
|
|
76
82
|
},
|
|
77
|
-
serverExternalPackages: [
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
//
|
|
82
|
-
// as you cannot import dependencies of dependencies in a lot of package managers like pnpm. We'd have to force users
|
|
83
|
-
// to install the dependencies directly.
|
|
84
|
-
// Thus, we externalize the "entry-point" = the package that is installed by the end user, which would be our db adapters.
|
|
85
|
-
//
|
|
83
|
+
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.
|
|
86
88
|
//
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'@payloadcms/db-postgres', '@payloadcms/db-sqlite', '@payloadcms/db-vercel-postgres', '@payloadcms/drizzle', '@payloadcms/db-d1-sqlite',
|
|
91
|
-
// External because they install @aws-sdk/client-s3:
|
|
92
|
-
'@payloadcms/payload-cloud',
|
|
89
|
+
// WHY: without externalizing graphql, a graphql version error will be thrown
|
|
90
|
+
// during runtime ("Ensure that there is only one instance of \"graphql\" in the node_modules\ndirectory.")
|
|
91
|
+
'graphql',
|
|
93
92
|
// External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.
|
|
94
|
-
'@sentry/nextjs',
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
'@sentry/nextjs', ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true ?
|
|
94
|
+
/**
|
|
95
|
+
* Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we
|
|
96
|
+
* do not bundle server-only packages during dev for two reasons:
|
|
97
|
+
*
|
|
98
|
+
* 1. Performance: Fewer files to compile means faster compilation speeds.
|
|
99
|
+
* 2. Turbopack support: Webpack's externals are not supported by Turbopack.
|
|
100
|
+
*
|
|
101
|
+
* Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to
|
|
102
|
+
* externalized packages that are not resolvable from the project root. So including a package like
|
|
103
|
+
* "drizzle-kit" in here would do nothing - Next.js will ignore the rule and still bundle the package -
|
|
104
|
+
* because it detects that the package is not resolvable from the project root (= not directly installed
|
|
105
|
+
* by the user in their own package.json).
|
|
106
|
+
*
|
|
107
|
+
* Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly
|
|
108
|
+
* by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).
|
|
109
|
+
*
|
|
110
|
+
*
|
|
111
|
+
*
|
|
112
|
+
* We should only do this during development, not build, because externalizing these packages can hurt
|
|
113
|
+
* the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the
|
|
114
|
+
* same package.
|
|
115
|
+
*
|
|
116
|
+
* Example:
|
|
117
|
+
* - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)
|
|
118
|
+
* - payload (not in bundle, external) -> installs qs-esm (external because of importer)
|
|
119
|
+
* Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.
|
|
120
|
+
*
|
|
121
|
+
* During development, these bundle size difference do not matter much, and development speed /
|
|
122
|
+
* turbopack support are more important.
|
|
123
|
+
*/
|
|
124
|
+
['payload', '@payloadcms/db-mongodb', '@payloadcms/db-postgres', '@payloadcms/db-sqlite', '@payloadcms/db-vercel-postgres', '@payloadcms/db-d1-sqlite', '@payloadcms/drizzle', '@payloadcms/email-nodemailer', '@payloadcms/email-resend', '@payloadcms/graphql', '@payloadcms/payload-cloud', '@payloadcms/plugin-redirects'] : [])],
|
|
98
125
|
webpack: (webpackConfig, webpackOptions) => {
|
|
99
126
|
const incomingWebpackConfig = typeof nextConfig.webpack === 'function' ? nextConfig.webpack(webpackConfig, webpackOptions) : webpackConfig;
|
|
100
127
|
return {
|
|
101
128
|
...incomingWebpackConfig,
|
|
102
|
-
externals: [...(incomingWebpackConfig?.externals || []),
|
|
129
|
+
externals: [...(incomingWebpackConfig?.externals || []),
|
|
130
|
+
/**
|
|
131
|
+
* See the explanation in the serverExternalPackages section above.
|
|
132
|
+
* We need to force Webpack to emit require() calls for these packages, even though they are not
|
|
133
|
+
* 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.
|
|
134
|
+
*
|
|
135
|
+
* This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the
|
|
136
|
+
* entry point packages, as explained in the serverExternalPackages section above.
|
|
137
|
+
*/
|
|
138
|
+
'drizzle-kit', 'drizzle-kit/api', 'sharp', 'libsql', 'require-in-the-middle'],
|
|
139
|
+
resolve: {
|
|
140
|
+
...(incomingWebpackConfig?.resolve || {}),
|
|
141
|
+
alias: {
|
|
142
|
+
...(incomingWebpackConfig?.resolve?.alias || {})
|
|
143
|
+
},
|
|
144
|
+
fallback: {
|
|
145
|
+
...(incomingWebpackConfig?.resolve?.fallback || {}),
|
|
146
|
+
/*
|
|
147
|
+
* This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):
|
|
148
|
+
*
|
|
149
|
+
* ⚠ Compiled with warnings in 8.7s
|
|
150
|
+
*
|
|
151
|
+
* ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js
|
|
152
|
+
* Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'
|
|
153
|
+
*
|
|
154
|
+
* Import trace for requested module:
|
|
155
|
+
* ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js
|
|
156
|
+
* ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js
|
|
157
|
+
* ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js
|
|
158
|
+
* ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js
|
|
159
|
+
* ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js
|
|
160
|
+
* ./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
|
|
161
|
+
* ./src/payload.config.ts
|
|
162
|
+
* ./src/app/my-route/route.ts
|
|
163
|
+
*
|
|
164
|
+
**/
|
|
165
|
+
aws4: false
|
|
166
|
+
}
|
|
167
|
+
},
|
|
103
168
|
plugins: [...(incomingWebpackConfig?.plugins || []),
|
|
104
169
|
// Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177
|
|
105
170
|
new webpackOptions.webpack.IgnorePlugin({
|
package/dist/withPayload.js.map
CHANGED
|
@@ -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","poweredByHeader","key","value","toReturn","turbopack","outputFileTracingExcludes","outputFileTracingIncludes","headers","headersFromConfig","source","serverExternalPackages","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","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 true\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 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 ...(nextConfig.serverExternalPackages || []),\n // These packages always need to be external, both during dev and production. This is because they install dependencies\n // that will error when trying to bundle them (e.g. drizzle-kit, libsql, esbuild etc.).\n // We cannot externalize those problem-packages directly. We can only externalize packages that are manually installed\n // by the end user. Otherwise, the require('externalPackage') calls generated by the bundler would fail during runtime,\n // as you cannot import dependencies of dependencies in a lot of package managers like pnpm. We'd have to force users\n // to install the dependencies directly.\n // Thus, we externalize the \"entry-point\" = the package that is installed by the end user, which would be our db adapters.\n //\n //\n // External because it installs mongoose (part of default serverExternalPackages: https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/server-external-packages.json => would throw warning if we don't exclude the entry-point package):\n '@payloadcms/db-mongodb',\n // External because they install dependencies like drizzle, libsql, esbuild etc.:\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/drizzle',\n '@payloadcms/db-d1-sqlite',\n // External because they install @aws-sdk/client-s3:\n '@payloadcms/payload-cloud',\n // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.\n '@sentry/nextjs',\n // 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.\n // Do not bundle additional server-only packages during dev to improve compilation speed\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages === false\n ? [\n 'payload',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\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: [...(incomingWebpackConfig?.externals || []), 'require-in-the-middle'],\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;;;;;;KAOA,OAAO,MAAMA,WAAA,GAAcA,CAACC,UAAA,GAAa,CAAC,CAAC,EAAEC,OAAA,GAAU,CAAC,CAAC;EACvD,MAAMC,GAAA,GAAMF,UAAA,CAAWE,GAAG,IAAI,CAAC;EAE/B,IAAIF,UAAA,CAAWG,YAAY,EAAEC,UAAA,EAAYC,OAAA,EAAS;IAChDC,OAAA,CAAQC,IAAI,CACV;IAEFL,GAAA,CAAIM,uCAAuC,GAAG;EAChD;EAEA,IAAIC,OAAA,CAAQP,GAAG,CAACQ,gCAAgC,KAAK,SAAS;IAC5D;IACA;IACA,MAAMC,oBAAA,GACJ;IAEF;IACA,MAAMC,0BAAA,GAA6B;IAEnC,MAAMC,WAAA,GAAcP,OAAA,CAAQC,IAAI;IAChCD,OAAA,CAAQC,IAAI,GAAG,CAAC,GAAGO,IAAA;MACjB;MACA,IACE,OAAQA,IAAI,CAAC,EAAE,KAAK,YAAYA,IAAI,CAAC,EAAE,CAACC,QAAQ,CAACJ,oBAAA,KAChD,OAAOG,IAAI,CAAC,EAAE,KAAK,YAAYA,IAAI,CAA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,EAAK;UACLC,KAAA,EAAO;QACT,GACA;UACED,GAAA,EAAK;UACLC,KAAA,EAAO;QACT,GACA;UACED,GAAA,EAAK;UACLC,KAAA,EAAO;QACT,G,IACInB,UAAA,CAAWiB,eAAe,KAAK,QAAQ,CAACA,eAAA,CAAgB,GAAG,EAAE;MAErE,EACD;IACH;IACAU,sBAAA,EAAwB,C,IAClB3B,UAAA,CAAW2B,sBAAsB,IAAI,EAAE;IAC3C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,2BACA,yBACA,kCACA,uBACA;IACA;IACA;IACA;IACA;IACA;IACA;QACIlB,OAAA,CAAQP,GAAG,CAAC0B,QAAQ,KAAK,iBAAiB3B,OAAA,CAAQ4B,uBAAuB,KAAK,QAC9E,CACE,WACA,gCACA,4BACA,uBACA,+BAWD,GACD,EAAE,EACP;IACDC,OAAA,EAASA,CAACC,aAAA,EAAeC,cAAA;MACvB,MAAMC,qBAAA,GACJ,OAAOjC,UAAA,CAAW8B,OAAO,KAAK,aAC1B9B,UAAA,CAAW8B,OAAO,CAACC,aAAA,EAAeC,cAAA,IAClCD,aAAA;MAEN,OAAO;QACL,GAAGE,qBAAqB;QACxBC,SAAA,EAAW,C,IAAKD,qBAAA,EAAuBC,SAAA,IAAa,EAAE,GAAG,wBAAwB;QACjFC,OAAA,EAAS,C,IACHF,qBAAA,EAAuBE,OAAA,IAAW,EAAE;QACxC;QACA,IAAIH,cAAA,CAAeF,OAAO,CAACM,YAAY,CAAC;UACtCC,cAAA,EAAgB;QAClB;MAEJ;IACF;EACF;EAEA,IAAIrC,UAAA,CAAWsC,QAAQ,EAAE;IACvBlB,QAAA,CAASlB,GAAG,CAACqC,cAAc,GAAGvC,UAAA,CAAWsC,QAAQ;EACnD;EAEA,OAAOlB,QAAA;AACT;AAEA,eAAerB,WAAA","ignoreList":[]}
|
|
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;;;;;;KAOA,OAAO,MAAMA,WAAA,GAAcA,CAACC,UAAA,GAAa,CAAC,CAAC,EAAEC,OAAA,GAAU,CAAC,CAAC;EACvD,MAAMC,GAAA,GAAMF,UAAA,CAAWE,GAAG,IAAI,CAAC;EAE/B,IAAIF,UAAA,CAAWG,YAAY,EAAEC,UAAA,EAAYC,OAAA,EAAS;IAChDC,OAAA,CAAQC,IAAI,CACV;IAEFL,GAAA,CAAIM,uCAAuC,GAA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EAAE,EACP;IACDC,OAAA,EAASA,CAACC,aAAA,EAAeC,cAAA;MACvB,MAAMC,qBAAA,GACJ,OAAOtC,UAAA,CAAWmC,OAAO,KAAK,aAC1BnC,UAAA,CAAWmC,OAAO,CAACC,aAAA,EAAeC,cAAA,IAClCD,aAAA;MAEN,OAAO;QACL,GAAGE,qBAAqB;QACxBC,SAAA,EAAW,C,IACLD,qBAAA,EAAuBC,SAAA,IAAa,EAAE;QAC1C;;;;;;;;QAQA,eACA,mBACA,SACA,UACA,wBACD;QACDC,OAAA,EAAS;UACP,IAAIF,qBAAA,EAAuBE,OAAA,IAAW,CAAC,CAAC;UACxCC,KAAA,EAAO;YACL,IAAIH,qBAAA,EAAuBE,OAAA,EAASC,KAAA,IAAS,CAAC,CAAC;UACjD;UACAC,QAAA,EAAU;YACR,IAAIJ,qBAAA,EAAuBE,OAAA,EAASE,QAAA,IAAY,CAAC,CAAC;YAClD;;;;;;;;;;;;;;;;;;;YAmBAC,IAAA,EAAM;UACR;QACF;QACAC,OAAA,EAAS,C,IACHN,qBAAA,EAAuBM,OAAA,IAAW,EAAE;QACxC;QACA,IAAIP,cAAA,CAAeF,OAAO,CAACU,YAAY,CAAC;UACtCC,cAAA,EAAgB;QAClB;MAEJ;IACF;EACF;EAEA,IAAI9C,UAAA,CAAW+C,QAAQ,EAAE;IACvBrB,QAAA,CAASxB,GAAG,CAAC8C,cAAc,GAAGhD,UAAA,CAAW+C,QAAQ;EACnD;EAEA,OAAOrB,QAAA;AACT;AAEA,eAAe3B,WAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.65.0-internal.
|
|
3
|
+
"version": "3.65.0-internal.ef335bd",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -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/
|
|
101
|
-
"@payloadcms/
|
|
102
|
-
"@payloadcms/
|
|
100
|
+
"@payloadcms/graphql": "3.65.0-internal.ef335bd",
|
|
101
|
+
"@payloadcms/translations": "3.65.0-internal.ef335bd",
|
|
102
|
+
"@payloadcms/ui": "3.65.0-internal.ef335bd"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@babel/cli": "7.27.2",
|
|
@@ -116,13 +116,13 @@
|
|
|
116
116
|
"esbuild": "0.25.5",
|
|
117
117
|
"esbuild-sass-plugin": "3.3.1",
|
|
118
118
|
"swc-plugin-transform-remove-imports": "4.0.4",
|
|
119
|
-
"
|
|
120
|
-
"
|
|
119
|
+
"payload": "3.65.0-internal.ef335bd",
|
|
120
|
+
"@payloadcms/eslint-config": "3.28.0"
|
|
121
121
|
},
|
|
122
122
|
"peerDependencies": {
|
|
123
123
|
"graphql": "^16.8.1",
|
|
124
124
|
"next": "^15.2.3",
|
|
125
|
-
"payload": "3.65.0-internal.
|
|
125
|
+
"payload": "3.65.0-internal.ef335bd"
|
|
126
126
|
},
|
|
127
127
|
"engines": {
|
|
128
128
|
"node": "^18.20.2 || >=20.9.0"
|