@payloadcms/next 3.65.0-internal.098b771 → 3.65.0-internal.19683e7
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/prod/styles.css +1 -1
- package/dist/utilities/initReq.d.ts.map +1 -1
- package/dist/utilities/initReq.js +16 -1
- package/dist/utilities/initReq.js.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 +6 -6
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_BASE_PATH"],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;;;QA6KH;eAAA;;QA5KaA;eAAAA;;;AAAN,MAAMA,cAAc,CAACC,aAAa,CAAC,CAAC,EAAEC,UAAU,CAAC,CAAC;IACvD,MAAMC,MAAMF,WAAWE,GAAG,IAAI,CAAC;IAE/B,IAAIF,WAAWG,YAAY,EAAEC,YAAYC,SAAS;QAChDC,QAAQC,IAAI,CACV;QAEFL,IAAIM,uCAAuC,GAAG;IAChD;IAEA,IAAIC,QAAQP,GAAG,CAACQ,gCAAgC,KAAK,SAAS;QAC5D,4IAA4I;QAC5I,iGAAiG;QACjG,MAAMC,uBACJ;QAEF,gEAAgE;QAChE,MAAMC,6BAA6B;QAEnC,MAAMC,cAAcP,QAAQC,IAAI;QAChCD,QAAQC,IAAI,GAAG,CAAC,GAAGO;YACjB,mGAAmG;YACnG,IACE,AAAC,OAAOA,IAAI,CAAC,EAAE,KAAK,YAAYA,IAAI,CAAC,EAAE,CAACC,QAAQ,CAACJ,yBAChD,OAAOG,IAAI,CAAC,EAAE,KAAK,YAAYA,IAAI,CAAC,EAAE,CAACC,QAAQ,CAACJ,uBACjD;gBACA;YACF;YAEA,0FAA0F;YAC1F,gEAAgE;YAChE,MAAMK,4BACJ,AAAC,OAAOF,IAAI,CAAC,EAAE,KAAK,YAAYA,IAAI,CAAC,EAAE,CAACC,QAAQ,CAACH,+BAChD,OAAOE,IAAI,CAAC,EAAE,KAAK,YAAYA,IAAI,CAAC,EAAE,CAACC,QAAQ,CAACH;YAEnD,IAAII,2BAA2B;gBAC7BH,eAAeC;gBACfD,YACE;gBAEF;YACF;YAEAA,eAAeC;QACjB;IACF;IAEA,MAAMG,kBAAkB;QACtBC,KAAK;QACLC,OAAO;IACT;IAEA;;GAEC,GACD,MAAMC,WAAW;QACf,GAAGpB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BACA;gBACA;gBACA;gBACA;aAWD,GACD,EAAE;SACP;QACDC,SAAS,CAACC,eAAeC;YACvB,MAAMC,wBACJ,OAAOjC,WAAW8B,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,MAA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C,eAAeC;YACvB,MAAMC,wBACJ,OAAOtC,WAAWmC,OAAO,KAAK,aAC1BnC,WAAWmC,OAAO,CAACC,eAAeC,kBAClCD;YAEN,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"}
|