@payloadcms/next 4.0.0-internal.d21c039 → 4.0.0-internal.d3909a9
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/adapters/UnmountWhenHidden/index.d.ts +18 -0
- package/dist/adapters/UnmountWhenHidden/index.d.ts.map +1 -0
- package/dist/adapters/UnmountWhenHidden/index.js +64 -0
- package/dist/adapters/UnmountWhenHidden/index.js.map +1 -0
- package/dist/adapters/handleServerFunctions.d.ts.map +1 -1
- package/dist/adapters/handleServerFunctions.js +4 -6
- package/dist/adapters/handleServerFunctions.js.map +1 -1
- package/dist/adapters/layout.d.ts +1 -1
- package/dist/adapters/layout.d.ts.map +1 -1
- package/dist/adapters/layout.js +3 -3
- package/dist/adapters/layout.js.map +1 -1
- package/dist/adapters/metadata.js.map +1 -1
- package/dist/adapters/router.d.ts.map +1 -1
- package/dist/adapters/router.js +1 -1
- package/dist/adapters/router.js.map +1 -1
- package/dist/adapters/views.d.ts +3 -2
- package/dist/adapters/views.d.ts.map +1 -1
- package/dist/adapters/views.js +27 -17
- package/dist/adapters/views.js.map +1 -1
- package/dist/auth/login.js.map +1 -1
- package/dist/cjs/withPayload.cjs +74 -23
- package/dist/cjs/withPayload.cjs.map +3 -3
- package/dist/prod/styles.css +1 -1
- package/dist/routes/graphql/handler.js +3 -3
- package/dist/routes/graphql/handler.js.map +1 -1
- package/dist/routes/graphql/playground.d.ts.map +1 -1
- package/dist/routes/graphql/playground.js +2 -2
- package/dist/routes/graphql/playground.js.map +1 -1
- package/dist/routes/rest/og/index.d.ts.map +1 -1
- package/dist/routes/rest/og/index.js.map +1 -1
- package/dist/utilities/initAdminContext.d.ts +8 -0
- package/dist/utilities/initAdminContext.d.ts.map +1 -0
- package/dist/utilities/initAdminContext.js +35 -0
- package/dist/utilities/initAdminContext.js.map +1 -0
- package/dist/utilities/selectiveCache.d.ts +18 -0
- package/dist/utilities/selectiveCache.d.ts.map +1 -0
- package/dist/utilities/selectiveCache.js +36 -0
- package/dist/utilities/selectiveCache.js.map +1 -0
- package/dist/withPayload/instantLoader.d.ts +16 -0
- package/dist/withPayload/instantLoader.d.ts.map +1 -0
- package/dist/withPayload/instantLoader.js +27 -0
- package/dist/withPayload/instantLoader.js.map +1 -0
- package/dist/withPayload/withPayload.d.ts.map +1 -1
- package/dist/withPayload/withPayload.js +49 -24
- package/dist/withPayload/withPayload.js.map +1 -1
- package/package.json +36 -36
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { configToSchema } from '@payloadcms/graphql';
|
|
2
2
|
import { createHandler } from 'graphql-http/lib/use/fetch';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { addDataAndFileToRequest, addLocalesToRequestFromData, createPayloadRequestFromWebRequest, headersWithCors, logError, mergeHeaders } from 'payload';
|
|
4
|
+
import { httpStatus } from 'payload/internal';
|
|
5
5
|
const handleError = async ({
|
|
6
6
|
err,
|
|
7
7
|
payload,
|
|
@@ -77,7 +77,7 @@ export const getGraphql = async config => {
|
|
|
77
77
|
};
|
|
78
78
|
export const POST = config => async request => {
|
|
79
79
|
const originalRequest = request.clone();
|
|
80
|
-
const req = await
|
|
80
|
+
const req = await createPayloadRequestFromWebRequest({
|
|
81
81
|
canSetHeaders: true,
|
|
82
82
|
config,
|
|
83
83
|
request
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","names":["configToSchema","createHandler","
|
|
1
|
+
{"version":3,"file":"handler.js","names":["configToSchema","createHandler","addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequestFromWebRequest","headersWithCors","logError","mergeHeaders","httpStatus","handleError","err","payload","req","status","originalError","INTERNAL_SERVER_ERROR","errorMessage","message","config","debug","response","extensions","name","undefined","data","stack","statusCode","locations","path","hooks","afterError","reduce","promise","hook","result","context","error","graphqlResult","Promise","resolve","cached","global","_payload_graphql","graphql","getGraphql","process","env","NODE_ENV","resolvedConfig","schema","e","POST","request","originalRequest","clone","canSetHeaders","graphQL","disable","Response","validationRules","headers","apiResponse","onOperation","args","errors","all","map","_","defaultRules","concat","resHeaders","Headers","key","append","body","responseHeaders"],"sources":["../../../src/routes/graphql/handler.ts"],"sourcesContent":["import type { GraphQLError, GraphQLFormattedError } from 'graphql'\nimport type { APIError, Payload, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { configToSchema } from '@payloadcms/graphql'\nimport { createHandler } from 'graphql-http/lib/use/fetch'\nimport {\n addDataAndFileToRequest,\n addLocalesToRequestFromData,\n createPayloadRequestFromWebRequest,\n headersWithCors,\n logError,\n mergeHeaders,\n} from 'payload'\nimport { httpStatus } from 'payload/internal'\n\nconst handleError = async ({\n err,\n payload,\n req,\n}: {\n err: GraphQLError\n payload: Payload\n req: PayloadRequest\n}): Promise<GraphQLFormattedError> => {\n const status = (err.originalError as APIError).status || httpStatus.INTERNAL_SERVER_ERROR\n let errorMessage = err.message\n logError({ err, payload })\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!payload.config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: GraphQLFormattedError = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && (err.originalError as APIError).data) || undefined,\n stack: payload.config.debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n await payload.config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n context: req.context,\n error: err,\n graphqlResult: response,\n req,\n })\n\n if (result) {\n response = result.graphqlResult || response\n }\n }, Promise.resolve())\n\n return response\n}\n\nlet cached = global._payload_graphql\n\nif (!cached) {\n cached = global._payload_graphql = { graphql: null, promise: null }\n}\n\nexport const getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = global._payload_graphql = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n const resolvedConfig = await config\n cached.promise = new Promise((resolve) => {\n const schema = configToSchema(resolvedConfig)\n resolve(cached.graphql || schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\nexport const POST =\n (config: Promise<SanitizedConfig> | SanitizedConfig) => async (request: Request) => {\n const originalRequest = request.clone()\n const req = await createPayloadRequestFromWebRequest({\n canSetHeaders: true,\n config,\n request,\n })\n\n const { payload } = req\n\n if (payload.config.graphQL?.disable) {\n return new Response(null, {\n status: 404,\n })\n }\n\n await addDataAndFileToRequest(req)\n addLocalesToRequestFromData(req)\n\n const { schema, validationRules } = await getGraphql(config)\n\n const headers = {}\n const apiResponse = await createHandler({\n context: { headers, req },\n onOperation: async (request, args, result) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: request,\n result,\n })\n : result\n if (response.errors) {\n const errors = (await Promise.all(\n result.errors.map((error) => {\n return handleError({ err: error, payload, req })\n }),\n )) as GraphQLError[]\n // errors type should be FormattedGraphQLError[] but onOperation has a return type of ExecutionResult instead of FormattedExecutionResult\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (_, args, defaultRules) => defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req,\n })\n\n for (const key in headers) {\n resHeaders.append(key, headers[key])\n }\n\n return new Response(apiResponse.body, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, resHeaders) : resHeaders,\n status: apiResponse.status,\n })\n }\n"],"mappings":"AAGA,SAASA,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAC9B,SACEC,uBAAuB,EACvBC,2BAA2B,EAC3BC,kCAAkC,EAClCC,eAAe,EACfC,QAAQ,EACRC,YAAY,QACP;AACP,SAASC,UAAU,QAAQ;AAE3B,MAAMC,WAAA,GAAc,MA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KZ,OAAO,CAACY,GAAA,CAAI;EACrC;EAEA,OAAO,IAAId,QAAA,CAASG,WAAA,CAAYa,IAAI,EAAE;IACpCd,OAAA,EAAShD,GAAA,CAAI+D,eAAe,GAAGpE,YAAA,CAAaK,GAAA,CAAI+D,eAAe,EAAEL,UAAA,IAAcA,UAAA;IAC/EzD,MAAA,EAAQgD,WAAA,CAAYhD;EACtB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/playground.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/playground.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAGlF,eAAO,MAAM,GAAG,WAAY,OAAO,CAAC,eAAe,CAAC,eAAqB,OAAO,sBAiC/E,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { renderPlaygroundPage } from 'graphql-playground-html';
|
|
2
|
-
import {
|
|
2
|
+
import { createPayloadRequestFromWebRequest } from 'payload';
|
|
3
3
|
import { formatAdminURL } from 'payload/shared';
|
|
4
4
|
export const GET = config => async request => {
|
|
5
|
-
const req = await
|
|
5
|
+
const req = await createPayloadRequestFromWebRequest({
|
|
6
6
|
config,
|
|
7
7
|
request
|
|
8
8
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.js","names":["renderPlaygroundPage","
|
|
1
|
+
{"version":3,"file":"playground.js","names":["renderPlaygroundPage","createPayloadRequestFromWebRequest","formatAdminURL","GET","config","request","req","payload","graphQL","disable","disablePlaygroundInProduction","process","env","NODE_ENV","endpoint","apiRoute","routes","api","path","Response","settings","headers","status"],"sources":["../../../src/routes/graphql/playground.ts"],"sourcesContent":["import { renderPlaygroundPage } from 'graphql-playground-html'\nimport { createPayloadRequestFromWebRequest, type SanitizedConfig } from 'payload'\nimport { formatAdminURL } from 'payload/shared'\n\nexport const GET = (config: Promise<SanitizedConfig>) => async (request: Request) => {\n const req = await createPayloadRequestFromWebRequest({\n config,\n request,\n })\n\n if (\n (!req.payload.config.graphQL.disable &&\n !req.payload.config.graphQL.disablePlaygroundInProduction &&\n process.env.NODE_ENV === 'production') ||\n process.env.NODE_ENV !== 'production'\n ) {\n const endpoint = formatAdminURL({\n apiRoute: req.payload.config.routes.api,\n path: req.payload.config.routes.graphQL as `/${string}`,\n })\n return new Response(\n renderPlaygroundPage({\n endpoint,\n settings: {\n 'request.credentials': 'include',\n },\n }),\n {\n headers: {\n 'Content-Type': 'text/html',\n },\n status: 200,\n },\n )\n } else {\n return new Response('Route Not Found', { status: 404 })\n }\n}\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,kCAAkC,QAA8B;AACzE,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,GAAA,GAAOC,MAAA,IAAqC,MAAOC,OAAA;EAC9D,MAAMC,GAAA,GAAM,MAAML,kCAAA,CAAmC;IACnDG,MAAA;IACAC;EACF;EAEA,IACE,CAAEC,GAAA,CAAIC,OAAO,CAACH,MAAM,CAACI,OAAO,CAACC,OAAO,IAClC,CAACH,GAAA,CAAIC,OAAO,CAACH,MAAM,CAACI,OAAO,CAACE,6BAA6B,IACzDC,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,gBAC3BF,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,cACzB;IACA,MAAMC,QAAA,GAAWZ,cAAA,CAAe;MAC9Ba,QAAA,EAAUT,GAAA,CAAIC,OAAO,CAACH,MAAM,CAACY,MAAM,CAACC,GAAG;MACvCC,IAAA,EAAMZ,GAAA,CAAIC,OAAO,CAACH,MAAM,CAACY,MAAM,CAACR;IAClC;IACA,OAAO,IAAIW,QAAA,CACTnB,oBAAA,CAAqB;MACnBc,QAAA;MACAM,QAAA,EAAU;QACR,uBAAuB;MACzB;IACF,IACA;MACEC,OAAA,EAAS;QACP,gBAAgB;MAClB;MACAC,MAAA,EAAQ;IACV;EAEJ,OAAO;IACL,OAAO,IAAIH,QAAA,CAAS,mBAAmB;MAAEG,MAAA,EAAQ;IAAI;EACvD;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/og/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAc7C,eAAO,MAAM,OAAO,WAAW,CAAA;AAE/B,eAAO,MAAM,WAAW,cAAc,CAAA;AAEtC,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/og/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAc7C,eAAO,MAAM,OAAO,WAAW,CAAA;AAE/B,eAAO,MAAM,WAAW,cAAc,CAAA;AAEtC,eAAO,MAAM,eAAe,EAAE,cA4D7B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["PayloadIcon","fs","ImageResponse","path","React","fileURLToPath","OGImage","filename","import","meta","url","dirname","runtime","contentType","generateOGImage","req","config","payload","admin","defaultOGImageType","Response","json","error","status","searchParams","URL","hasTitle","has","title","get","slice","hasLeader","leader","replace","description","fontData","readFile","join","e","logger","message","fontFamily","_jsx","Fallback","Icon","components","graphics","importMap","fonts","name","data","style","weight","height","width"],"sources":["../../../../src/routes/rest/og/index.tsx"],"sourcesContent":["import type { PayloadHandler } from 'payload'\n\nimport { PayloadIcon } from '@payloadcms/ui/shared'\nimport fs from 'fs/promises'\nimport { ImageResponse } from 'next/og.js'\nimport path from 'path'\nimport React from 'react'\nimport { fileURLToPath } from 'url'\n\nimport { OGImage } from './image.js'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nexport const runtime = 'nodejs'\n\nexport const contentType = 'image/png'\n\nexport const generateOGImage: PayloadHandler = async (req) => {\n const config = req.payload.config\n\n if (config.admin.meta.defaultOGImageType === 'off') {\n return Response.json({ error: `Open Graph images are disabled` }, { status: 400 })\n }\n\n try {\n const { searchParams } = new URL(req.url)\n\n const hasTitle = searchParams.has('title')\n const title = hasTitle ? searchParams.get('title')?.slice(0, 100) : ''\n const hasLeader = searchParams.has('leader')\n const leader = hasLeader ? searchParams.get('leader')?.slice(0, 100).replace('-', ' ') : ''\n const description = searchParams.has('description') ? searchParams.get('description') : ''\n\n let fontData\n\n try {\n // TODO: replace with `.woff2` file when supported\n // See https://github.com/vercel/next.js/issues/63935\n // Or better yet, use a CDN like Google Fonts if ever supported\n fontData = fs.readFile(path.join(dirname, 'roboto-regular.woff'))\n } catch (e) {\n req.payload.logger.error(`Error reading font file or not readable: ${e.message}`)\n }\n\n const fontFamily = 'Roboto, sans-serif'\n\n return new ImageResponse(\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["PayloadIcon","fs","ImageResponse","path","React","fileURLToPath","OGImage","filename","import","meta","url","dirname","runtime","contentType","generateOGImage","req","config","payload","admin","defaultOGImageType","Response","json","error","status","searchParams","URL","hasTitle","has","title","get","slice","hasLeader","leader","replace","description","fontData","readFile","join","e","logger","message","fontFamily","_jsx","Fallback","Icon","components","graphics","importMap","fonts","name","data","style","weight","height","width"],"sources":["../../../../src/routes/rest/og/index.tsx"],"sourcesContent":["import type { PayloadHandler } from 'payload'\n\nimport { PayloadIcon } from '@payloadcms/ui/shared'\nimport fs from 'fs/promises'\nimport { ImageResponse } from 'next/og.js'\nimport path from 'path'\nimport React from 'react'\nimport { fileURLToPath } from 'url'\n\nimport { OGImage } from './image.js'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nexport const runtime = 'nodejs'\n\nexport const contentType = 'image/png'\n\nexport const generateOGImage: PayloadHandler = async (req) => {\n const config = req.payload.config\n\n if (config.admin.meta.defaultOGImageType === 'off') {\n return Response.json({ error: `Open Graph images are disabled` }, { status: 400 })\n }\n\n try {\n const { searchParams } = new URL(req.url)\n\n const hasTitle = searchParams.has('title')\n const title = hasTitle ? searchParams.get('title')?.slice(0, 100) : ''\n const hasLeader = searchParams.has('leader')\n const leader = hasLeader ? searchParams.get('leader')?.slice(0, 100).replace('-', ' ') : ''\n const description = searchParams.has('description') ? searchParams.get('description') : ''\n\n let fontData\n\n try {\n // TODO: replace with `.woff2` file when supported\n // See https://github.com/vercel/next.js/issues/63935\n // Or better yet, use a CDN like Google Fonts if ever supported\n fontData = fs.readFile(path.join(dirname, 'roboto-regular.woff'))\n } catch (e) {\n req.payload.logger.error(`Error reading font file or not readable: ${e.message}`)\n }\n\n const fontFamily = 'Roboto, sans-serif'\n\n return new ImageResponse(\n <OGImage\n description={description}\n Fallback={PayloadIcon}\n fontFamily={fontFamily}\n Icon={config.admin?.components?.graphics?.Icon}\n importMap={req.payload.importMap}\n leader={leader}\n title={title}\n />,\n {\n ...(fontData\n ? {\n fonts: [\n {\n name: 'Roboto',\n data: await fontData,\n style: 'normal',\n weight: 400,\n },\n ],\n }\n : {}),\n height: 630,\n width: 1200,\n },\n )\n } catch (e: any) {\n req.payload.logger.error(`Error generating Open Graph image: ${e.message}`)\n return Response.json({ error: `Internal Server Error: ${e.message}` }, { status: 500 })\n }\n}\n"],"mappings":";AAEA,SAASA,WAAW,QAAQ;AAC5B,OAAOC,EAAA,MAAQ;AACf,SAASC,aAAa,QAAQ;AAC9B,OAAOC,IAAA,MAAU;AACjB,OAAOC,KAAA,MAAW;AAClB,SAASC,aAAa,QAAQ;AAE9B,SAASC,OAAO,QAAQ;AAExB,MAAMC,QAAA,GAAWF,aAAA,CAAcG,MAAA,CAAAC,IAAA,CAAYC,GAAG;AAC9C,MAAMC,OAAA,GAAUR,IAAA,CAAKQ,OAAO,CAACJ,QAAA;AAE7B,OAAO,MAAMK,OAAA,GAAU;A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EAAYA,UAAA;MACZG,IAAA,EAAM5B,MAAA,CAAOE,KAAK,EAAE2B,UAAA,EAAYC,QAAA,EAAUF,IAAA;MAC1CG,SAAA,EAAWhC,GAAA,CAAIE,OAAO,CAAC8B,SAAS;MAChCf,MAAA,EAAQA,MAAA;MACRJ,KAAA,EAAOA;QAET;MACE,IAAIO,QAAA,GACA;QACEa,KAAA,EAAO,CACL;UACEC,IAAA,EAAM;UACNC,IAAA,EAAM,MAAMf,QAAA;UACZgB,KAAA,EAAO;UACPC,MAAA,EAAQ;QACV;MAEJ,IACA,CAAC,CAAC;MACNC,MAAA,EAAQ;MACRC,KAAA,EAAO;IACT;EAEJ,EAAE,OAAOhB,CAAA,EAAQ;IACfvB,GAAA,CAAIE,OAAO,CAACsB,MAAM,CAACjB,KAAK,CAAC,sCAAsCgB,CAAA,CAAEE,OAAO,EAAE;IAC1E,OAAOpB,QAAA,CAASC,IAAI,CAAC;MAAEC,KAAA,EAAO,0BAA0BgB,CAAA,CAAEE,OAAO;IAAG,GAAG;MAAEjB,MAAA,EAAQ;IAAI;EACvF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AdminContext } from 'payload';
|
|
2
|
+
import type { InitAdminContextArgs } from 'payload/internal';
|
|
3
|
+
type NextInitAdminContextArgs = {
|
|
4
|
+
key: string;
|
|
5
|
+
} & Omit<InitAdminContextArgs, 'cache' | 'key' | 'serverAdapter'>;
|
|
6
|
+
export declare const initAdminContext: (args: NextInitAdminContextArgs) => Promise<AdminContext>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=initAdminContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initAdminContext.d.ts","sourceRoot":"","sources":["../../src/utilities/initAdminContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,KAAK,EAAqB,oBAAoB,EAAuB,MAAM,kBAAkB,CAAA;AAuBpG,KAAK,wBAAwB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,KAAK,GAAG,eAAe,CAAC,CAAA;AAEjE,eAAO,MAAM,gBAAgB,SAAgB,wBAAwB,0BAapE,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { connection } from 'next/server.js';
|
|
2
|
+
import { initAdminContext as initPayloadAdminContext } from 'payload/internal';
|
|
3
|
+
import { nextServerAdapter } from '../adapters/server.js';
|
|
4
|
+
import { selectiveCache } from './selectiveCache.js';
|
|
5
|
+
const partialContextCache = selectiveCache('partialContext');
|
|
6
|
+
const localeCache = selectiveCache('locale');
|
|
7
|
+
const adminContextCache = selectiveCache('adminContext');
|
|
8
|
+
const cache = {
|
|
9
|
+
getLocale: (resolveLocale, ...key) => localeCache.get({
|
|
10
|
+
create: resolveLocale,
|
|
11
|
+
key
|
|
12
|
+
}),
|
|
13
|
+
getPartial: createPartialContext => partialContextCache.get({
|
|
14
|
+
create: createPartialContext,
|
|
15
|
+
key: ['global']
|
|
16
|
+
}),
|
|
17
|
+
getRequest: (createContext, key, ...cacheArgs) => adminContextCache.get({
|
|
18
|
+
create: createContext,
|
|
19
|
+
key: [key, ...cacheArgs]
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
export const initAdminContext = async args => {
|
|
23
|
+
// Without this, enabling `cacheComponents` throws as soon as the admin panel calls `new Date()`
|
|
24
|
+
// (e.g. inside the database adapter): "Next.js encountered the unstable value `new Date()` while
|
|
25
|
+
// prerendering". `connection()` tells Next.js to wait for the incoming request, so everything
|
|
26
|
+
// after it renders per request and can use `new Date()`, `Math.random()`, etc.
|
|
27
|
+
// https://nextjs.org/docs/app/api-reference/functions/connection
|
|
28
|
+
await connection();
|
|
29
|
+
return initPayloadAdminContext({
|
|
30
|
+
...args,
|
|
31
|
+
cache,
|
|
32
|
+
serverAdapter: nextServerAdapter
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=initAdminContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initAdminContext.js","names":["connection","initAdminContext","initPayloadAdminContext","nextServerAdapter","selectiveCache","partialContextCache","localeCache","adminContextCache","cache","getLocale","resolveLocale","key","get","create","getPartial","createPartialContext","getRequest","createContext","cacheArgs","args","serverAdapter"],"sources":["../../src/utilities/initAdminContext.ts"],"sourcesContent":["import type { AdminContext } from 'payload'\nimport type { AdminContextCache, InitAdminContextArgs, PartialAdminContext } from 'payload/internal'\n\nimport { connection } from 'next/server.js'\nimport { initAdminContext as initPayloadAdminContext } from 'payload/internal'\n\nimport { nextServerAdapter } from '../adapters/server.js'\nimport { selectiveCache } from './selectiveCache.js'\n\nconst partialContextCache = selectiveCache<PartialAdminContext>('partialContext')\nconst localeCache = selectiveCache<Pick<AdminContext, 'locale'>>('locale')\nconst adminContextCache = selectiveCache<AdminContext>('adminContext')\n\nconst cache: AdminContextCache = {\n getLocale: (resolveLocale, ...key) => localeCache.get({ create: resolveLocale, key }),\n getPartial: (createPartialContext) =>\n partialContextCache.get({ create: createPartialContext, key: ['global'] }),\n getRequest: (createContext, key, ...cacheArgs) =>\n adminContextCache.get({\n create: createContext,\n key: [key, ...cacheArgs],\n }),\n}\n\ntype NextInitAdminContextArgs = {\n key: string\n} & Omit<InitAdminContextArgs, 'cache' | 'key' | 'serverAdapter'>\n\nexport const initAdminContext = async (args: NextInitAdminContextArgs) => {\n // Without this, enabling `cacheComponents` throws as soon as the admin panel calls `new Date()`\n // (e.g. inside the database adapter): \"Next.js encountered the unstable value `new Date()` while\n // prerendering\". `connection()` tells Next.js to wait for the incoming request, so everything\n // after it renders per request and can use `new Date()`, `Math.random()`, etc.\n // https://nextjs.org/docs/app/api-reference/functions/connection\n await connection()\n\n return initPayloadAdminContext({\n ...args,\n cache,\n serverAdapter: nextServerAdapter,\n })\n}\n"],"mappings":"AAGA,SAASA,UAAU,QAAQ;AAC3B,SAASC,gBAAA,IAAoBC,uBAAuB,QAAQ;AAE5D,SAASC,iBAAiB,QAAQ;AAClC,SAASC,cAAc,QAAQ;AAE/B,MAAMC,mBAAA,GAAsBD,cAAA,CAAoC;AAChE,MAAME,WAAA,GAAcF,cAAA,CAA6C;AACjE,MAAMG,iBAAA,GAAoBH,cAAA,CAA6B;AAEvD,MAAMI,KAAA,GAA2B;EAC/BC,SAAA,EAAWA,CAACC,aAAA,EAAe,GAAGC,GAAA,KAAQL,WAAA,CAAYM,GAAG,CAAC;IAAEC,MAAA,EAAQH,aAAA;IAAeC;EAAI;EACnFG,UAAA,EAAaC,oBAAA,IACXV,mBAAA,CAAoBO,GAAG,CAAC;IAAEC,MAAA,EAAQE,oBAAA;IAAsBJ,GAAA,EAAK,CAAC;EAAU;EAC1EK,UAAA,EAAYA,CAACC,aAAA,EAAeN,GAAA,EAAK,GAAGO,SAAA,KAClCX,iBAAA,CAAkBK,GAAG,CAAC;IACpBC,MAAA,EAAQI,aAAA;IACRN,GAAA,EAAK,CAACA,GAAA,E,GAAQO,SAAA;EAChB;AACJ;AAMA,OAAO,MAAMjB,gBAAA,GAAmB,MAAOkB,IAAA;EACrC;EACA;EACA;EACA;EACA;EACA,MAAMnB,UAAA;EAEN,OAAOE,uBAAA,CAAwB;IAC7B,GAAGiB,IAAI;IACPX,KAAA;IACAY,aAAA,EAAejB;EACjB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type CachedValue = object;
|
|
2
|
+
type GetCachedArgs<TValue extends object> = {
|
|
3
|
+
/** Creates the value when it is not cached. */
|
|
4
|
+
create: () => Promise<TValue>;
|
|
5
|
+
/** Values that identify the cached value. */
|
|
6
|
+
key: unknown[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Creates a selective cache function that provides more control over React's request-level caching behavior.
|
|
10
|
+
*
|
|
11
|
+
* @param namespace - A namespace to group related cached values
|
|
12
|
+
* @returns A function that manages cached values within the specified namespace
|
|
13
|
+
*/
|
|
14
|
+
export declare function selectiveCache<TValue extends object = CachedValue>(namespace: string): {
|
|
15
|
+
get: ({ create, key }: GetCachedArgs<TValue>) => Promise<TValue>;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=selectiveCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectiveCache.d.ts","sourceRoot":"","sources":["../../src/utilities/selectiveCache.ts"],"names":[],"mappings":"AAEA,KAAK,WAAW,GAAG,MAAM,CAAA;AAEzB,KAAK,aAAa,CAAC,MAAM,SAAS,MAAM,IAAI;IAC1C,+CAA+C;IAC/C,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7B,6CAA6C;IAC7C,GAAG,EAAE,OAAO,EAAE,CAAA;CACf,CAAA;AAaD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,SAAS,MAAM,GAAG,WAAW,EAAE,SAAS,EAAE,MAAM;IA4BjF,GAAG,oBAlBqC,aAAa,CAAC,MAAM,CAAC,KAAG,OAAO,CAAC,MAAM,CAAC;EAoBlF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { cache } from 'react';
|
|
2
|
+
// Module-scoped cache container that holds all cached, stable containers
|
|
3
|
+
// - these may hold the stable value, or a promise to the stable value
|
|
4
|
+
const globalCacheContainer = {};
|
|
5
|
+
/**
|
|
6
|
+
* Creates a selective cache function that provides more control over React's request-level caching behavior.
|
|
7
|
+
*
|
|
8
|
+
* @param namespace - A namespace to group related cached values
|
|
9
|
+
* @returns A function that manages cached values within the specified namespace
|
|
10
|
+
*/
|
|
11
|
+
export function selectiveCache(namespace) {
|
|
12
|
+
if (!globalCacheContainer[namespace]) {
|
|
13
|
+
globalCacheContainer[namespace] = cache((..._args) => ({
|
|
14
|
+
value: null
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Gets or creates a cached value for a specific key within the namespace
|
|
19
|
+
*/
|
|
20
|
+
const getCached = async ({
|
|
21
|
+
create,
|
|
22
|
+
key
|
|
23
|
+
}) => {
|
|
24
|
+
const stableObjectFn = globalCacheContainer[namespace];
|
|
25
|
+
const stableObject = stableObjectFn(...key);
|
|
26
|
+
if (stableObject?.value && 'then' in stableObject.value && typeof stableObject.value?.then === 'function') {
|
|
27
|
+
return await stableObject.value;
|
|
28
|
+
}
|
|
29
|
+
stableObject.value = create();
|
|
30
|
+
return await stableObject.value;
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
get: getCached
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=selectiveCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectiveCache.js","names":["cache","globalCacheContainer","selectiveCache","namespace","_args","value","getCached","create","key","stableObjectFn","stableObject","then","get"],"sources":["../../src/utilities/selectiveCache.ts"],"sourcesContent":["import { cache } from 'react'\n\ntype CachedValue = object\n\ntype GetCachedArgs<TValue extends object> = {\n /** Creates the value when it is not cached. */\n create: () => Promise<TValue>\n /** Values that identify the cached value. */\n key: unknown[]\n}\n\n// Module-scoped cache container that holds all cached, stable containers\n// - these may hold the stable value, or a promise to the stable value\nconst globalCacheContainer: Record<\n string,\n <TValue extends object = CachedValue>(\n ...args: unknown[]\n ) => {\n value: null | Promise<TValue> | TValue\n }\n> = {}\n\n/**\n * Creates a selective cache function that provides more control over React's request-level caching behavior.\n *\n * @param namespace - A namespace to group related cached values\n * @returns A function that manages cached values within the specified namespace\n */\nexport function selectiveCache<TValue extends object = CachedValue>(namespace: string) {\n if (!globalCacheContainer[namespace]) {\n globalCacheContainer[namespace] = cache((..._args) => ({\n value: null,\n }))\n }\n\n /**\n * Gets or creates a cached value for a specific key within the namespace\n */\n const getCached = async ({ create, key }: GetCachedArgs<TValue>): Promise<TValue> => {\n const stableObjectFn = globalCacheContainer[namespace]\n const stableObject = stableObjectFn<TValue>(...key)\n\n if (\n stableObject?.value &&\n 'then' in stableObject.value &&\n typeof stableObject.value?.then === 'function'\n ) {\n return await stableObject.value\n }\n\n stableObject.value = create()\n\n return await stableObject.value\n }\n\n return {\n get: getCached,\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ;AAWtB;AACA;AACA,MAAMC,oBAAA,GAOF,CAAC;AAEL;;;;;;AAMA,OAAO,SAASC,eAAoDC,SAAiB;EACnF,IAAI,CAACF,oBAAoB,CAACE,SAAA,CAAU,EAAE;IACpCF,oBAAoB,CAACE,SAAA,CAAU,GAAGH,KAAA,CAAM,CAAC,GAAGI,KAAA,MAAW;MACrDC,KAAA,EAAO;IACT;EACF;EAEA;;;EAGA,MAAMC,SAAA,GAAY,MAAAA,CAAO;IAAEC,MAAM;IAAEC;EAAG,CAAyB;IAC7D,MAAMC,cAAA,GAAiBR,oBAAoB,CAACE,SAAA,CAAU;IACtD,MAAMO,YAAA,GAAeD,cAAA,IAA0BD,GAAA;IAE/C,IACEE,YAAA,EAAcL,KAAA,IACd,UAAUK,YAAA,CAAaL,KAAK,IAC5B,OAAOK,YAAA,CAAaL,KAAK,EAAEM,IAAA,KAAS,YACpC;MACA,OAAO,MAAMD,YAAA,CAAaL,KAAK;IACjC;IAEAK,YAAA,CAAaL,KAAK,GAAGE,MAAA;IAErB,OAAO,MAAMG,YAAA,CAAaL,KAAK;EACjC;EAEA,OAAO;IACLO,GAAA,EAAKN;EACP;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webpack / Turbopack loader that appends `export const instant = false` to the route modules
|
|
3
|
+
* rendering the Payload admin panel (`RootLayout` and `RootPage`).
|
|
4
|
+
*
|
|
5
|
+
* With Next.js `cacheComponents`, every route must either produce a static shell or opt out with
|
|
6
|
+
* `instant = false`. The admin panel reads cookies, headers and the database above any Suspense
|
|
7
|
+
* boundary, so it has to opt out. Next.js reads `instant` from the route module itself and rejects
|
|
8
|
+
* it when `cacheComponents` is disabled, which is why it cannot live in the generated admin files.
|
|
9
|
+
* Instead, `withPayload` registers this loader only when `cacheComponents` is enabled.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} source
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
export default function instantLoader(source: string): string;
|
|
16
|
+
//# sourceMappingURL=instantLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instantLoader.d.ts","sourceRoot":"","sources":["../../src/withPayload/instantLoader.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,MAAM,EAHjC,MAGiC,GAF/B,MAAM,CAQlB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webpack / Turbopack loader that appends `export const instant = false` to the route modules
|
|
3
|
+
* rendering the Payload admin panel (`RootLayout` and `RootPage`).
|
|
4
|
+
*
|
|
5
|
+
* With Next.js `cacheComponents`, every route must either produce a static shell or opt out with
|
|
6
|
+
* `instant = false`. The admin panel reads cookies, headers and the database above any Suspense
|
|
7
|
+
* boundary, so it has to opt out. Next.js reads `instant` from the route module itself and rejects
|
|
8
|
+
* it when `cacheComponents` is disabled, which is why it cannot live in the generated admin files.
|
|
9
|
+
* Instead, `withPayload` registers this loader only when `cacheComponents` is enabled.
|
|
10
|
+
*/ // Matches e.g. `import { RootLayout } from '@payloadcms/next/layouts'`, including aliased and
|
|
11
|
+
// multi-line imports. Matching the import instead of the JSX/call site avoids touching files that
|
|
12
|
+
// define their own `RootLayout` component.
|
|
13
|
+
const importsPayloadRootComponentRegex = /\bimport\s*\{[^}]*\bRoot(?:Layout|Page)\b[^}]*\}\s*from\s*['"]@payloadcms\/next\/(?:layouts|views)['"]/;
|
|
14
|
+
// Skip files that already declare `instant` (exported or not), so a user's own value wins and we
|
|
15
|
+
// never produce a duplicate declaration.
|
|
16
|
+
const declaresInstantRegex = /\b(?:const|let|var|function|class)\s+instant\b|\bexport\s*\{[^}]*\binstant\b[^}]*\}/;
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} source
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
export default function instantLoader(source) {
|
|
22
|
+
if (!importsPayloadRootComponentRegex.test(source) || declaresInstantRegex.test(source)) {
|
|
23
|
+
return source;
|
|
24
|
+
}
|
|
25
|
+
return `${source}\nexport const instant = false\n`;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=instantLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instantLoader.js","names":["importsPayloadRootComponentRegex","declaresInstantRegex","instantLoader","source","test"],"sources":["../../src/withPayload/instantLoader.js"],"sourcesContent":["/**\n * Webpack / Turbopack loader that appends `export const instant = false` to the route modules\n * rendering the Payload admin panel (`RootLayout` and `RootPage`).\n *\n * With Next.js `cacheComponents`, every route must either produce a static shell or opt out with\n * `instant = false`. The admin panel reads cookies, headers and the database above any Suspense\n * boundary, so it has to opt out. Next.js reads `instant` from the route module itself and rejects\n * it when `cacheComponents` is disabled, which is why it cannot live in the generated admin files.\n * Instead, `withPayload` registers this loader only when `cacheComponents` is enabled.\n */\n\n// Matches e.g. `import { RootLayout } from '@payloadcms/next/layouts'`, including aliased and\n// multi-line imports. Matching the import instead of the JSX/call site avoids touching files that\n// define their own `RootLayout` component.\nconst importsPayloadRootComponentRegex =\n /\\bimport\\s*\\{[^}]*\\bRoot(?:Layout|Page)\\b[^}]*\\}\\s*from\\s*['\"]@payloadcms\\/next\\/(?:layouts|views)['\"]/\n\n// Skip files that already declare `instant` (exported or not), so a user's own value wins and we\n// never produce a duplicate declaration.\nconst declaresInstantRegex =\n /\\b(?:const|let|var|function|class)\\s+instant\\b|\\bexport\\s*\\{[^}]*\\binstant\\b[^}]*\\}/\n\n/**\n * @param {string} source\n * @returns {string}\n */\nexport default function instantLoader(source) {\n if (!importsPayloadRootComponentRegex.test(source) || declaresInstantRegex.test(source)) {\n return source\n }\n\n return `${source}\\nexport const instant = false\\n`\n}\n"],"mappings":"AAAA;;;;;;;;;GAAA,CAWA;AACA;AACA;AACA,MAAMA,gCAAA,GACJ;AAEF;AACA;AACA,MAAMC,oBAAA,GACJ;AAEF;;;;AAIA,eAAe,SAASC,cAAcC,MAAM;EAC1C,IAAI,CAACH,gCAAA,CAAiCI,IAAI,CAACD,MAAA,KAAWF,oBAAA,CAAqBG,IAAI,CAACD,MAAA,GAAS;IACvF,OAAOA,MAAA;EACT;EAEA,OAAO,GAAGA,MAAA,kCAAwC;AACpD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withPayload.d.ts","sourceRoot":"","sources":["../../src/withPayload/withPayload.js"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"withPayload.d.ts","sourceRoot":"","sources":["../../src/withPayload/withPayload.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;;;KAIK;AACL,eAAO,MAAM,WAAW,gBAJb,OAAO,MAAM,EAAE,UAAU,YAEjC;IAA0B,uBAAuB,AAAjD,CAA4G,EAApG,OAAO,CAA6F;CAAA,8BA8R9G,CAAA;eAEc,WAAW"}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* imported directly in next.config.mjs files. Since next.config files run before the build process,
|
|
4
4
|
* TypeScript compilation is not available. This ensures compatibility with all templates and
|
|
5
5
|
* user projects regardless of their TypeScript setup.
|
|
6
|
-
*/
|
|
6
|
+
*/import { fileURLToPath } from 'node:url';
|
|
7
|
+
const poweredByHeader = {
|
|
7
8
|
key: 'X-Powered-By',
|
|
8
9
|
value: 'Next.js, Payload'
|
|
9
10
|
};
|
|
@@ -13,7 +14,13 @@
|
|
|
13
14
|
* @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false
|
|
14
15
|
* */
|
|
15
16
|
export const withPayload = (nextConfig = {}, options = {}) => {
|
|
16
|
-
const env =
|
|
17
|
+
const env = {
|
|
18
|
+
...nextConfig.env
|
|
19
|
+
};
|
|
20
|
+
// Adds `export const instant = false` to the admin layout and page. See `instantLoader.js` for
|
|
21
|
+
// why this cannot live in the generated admin files.
|
|
22
|
+
const instantLoader = nextConfig.cacheComponents ? typeof import.meta?.resolve === 'function' ? fileURLToPath(new URL('./instantLoader.js', import.meta.url)) : require.resolve('@payloadcms/next/withPayload/instantLoader') : undefined;
|
|
23
|
+
const instantLoaderRule = '**/{layout,page}.{js,jsx,ts,tsx,mjs,mts,cjs,cts}';
|
|
17
24
|
if (nextConfig.experimental?.staleTimes?.dynamic) {
|
|
18
25
|
console.warn('Payload: detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.');
|
|
19
26
|
env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true';
|
|
@@ -36,9 +43,7 @@ export const withPayload = (nextConfig = {}, options = {}) => {
|
|
|
36
43
|
/** @type {import('next').NextConfig} */
|
|
37
44
|
const baseConfig = {
|
|
38
45
|
...nextConfig,
|
|
39
|
-
devIndicators: nextConfig.devIndicators !== undefined ? nextConfig.devIndicators :
|
|
40
|
-
position: 'bottom-left'
|
|
41
|
-
},
|
|
46
|
+
devIndicators: nextConfig.devIndicators !== undefined ? nextConfig.devIndicators : false,
|
|
42
47
|
env,
|
|
43
48
|
experimental: {
|
|
44
49
|
...(nextConfig.experimental || {})
|
|
@@ -64,7 +69,24 @@ export const withPayload = (nextConfig = {}, options = {}) => {
|
|
|
64
69
|
'**/*': [...(nextConfig.outputFileTracingExcludes?.['**/*'] || []), 'drizzle-kit', 'drizzle-kit/api']
|
|
65
70
|
},
|
|
66
71
|
turbopack: {
|
|
67
|
-
...(nextConfig.turbopack || {})
|
|
72
|
+
...(nextConfig.turbopack || {}),
|
|
73
|
+
...(instantLoader ? {
|
|
74
|
+
rules: {
|
|
75
|
+
...nextConfig.turbopack?.rules,
|
|
76
|
+
[instantLoaderRule]: [...[].concat(nextConfig.turbopack?.rules?.[instantLoaderRule] ?? []), {
|
|
77
|
+
// Only send files that import the admin root components to the loader, so
|
|
78
|
+
// Turbopack does not run a JavaScript loader for every other layout and page.
|
|
79
|
+
condition: {
|
|
80
|
+
all: [{
|
|
81
|
+
not: 'foreign'
|
|
82
|
+
}, {
|
|
83
|
+
content: /['"]@payloadcms\/next\/(?:layouts|views)['"]/
|
|
84
|
+
}]
|
|
85
|
+
},
|
|
86
|
+
loaders: [instantLoader]
|
|
87
|
+
}]
|
|
88
|
+
}
|
|
89
|
+
} : {})
|
|
68
90
|
},
|
|
69
91
|
// We disable the poweredByHeader here because we add it manually in the headers function below
|
|
70
92
|
...(nextConfig.poweredByHeader !== false ? {
|
|
@@ -97,21 +119,12 @@ export const withPayload = (nextConfig = {}, options = {}) => {
|
|
|
97
119
|
'file-type', ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true ?
|
|
98
120
|
/**
|
|
99
121
|
* Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we
|
|
100
|
-
* do not bundle server-only packages during dev
|
|
101
|
-
*
|
|
102
|
-
* 1. Performance: Fewer files to compile means faster compilation speeds.
|
|
103
|
-
* 2. Turbopack support: Webpack's externals are not supported by Turbopack.
|
|
104
|
-
*
|
|
105
|
-
* Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to
|
|
106
|
-
* externalized packages that are not resolvable from the project root. So including a package like
|
|
107
|
-
* "drizzle-kit" in here would do nothing - Next.js will ignore the rule and still bundle the package -
|
|
108
|
-
* because it detects that the package is not resolvable from the project root (= not directly installed
|
|
109
|
-
* by the user in their own package.json).
|
|
110
|
-
*
|
|
111
|
-
* Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly
|
|
112
|
-
* by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).
|
|
113
|
-
*
|
|
122
|
+
* do not bundle server-only packages during dev. Node.js loads them directly instead, so there are fewer
|
|
123
|
+
* files to compile, which means faster compilation speeds.
|
|
114
124
|
*
|
|
125
|
+
* A package can only be listed here if the import map never loads a client component from it. Node.js
|
|
126
|
+
* loads external packages as they are, so a `'use client'` file inside one would not become a client
|
|
127
|
+
* component. That is why packages with client components are not listed (see the TODO below).
|
|
115
128
|
*
|
|
116
129
|
* We should only do this during development, not build, because externalizing these packages can hurt
|
|
117
130
|
* the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the
|
|
@@ -122,17 +135,29 @@ export const withPayload = (nextConfig = {}, options = {}) => {
|
|
|
122
135
|
* - payload (not in bundle, external) -> installs qs-esm (external because of importer)
|
|
123
136
|
* Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.
|
|
124
137
|
*
|
|
125
|
-
* During development, these bundle size
|
|
126
|
-
*
|
|
138
|
+
* During development, these bundle size differences do not matter much, and development speed is more
|
|
139
|
+
* important.
|
|
127
140
|
*/
|
|
128
|
-
['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/
|
|
141
|
+
['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/kv-redis', '@payloadcms/payload-cloud',
|
|
142
|
+
// Its `/client` entry has no exports, so the import map never loads anything from it
|
|
143
|
+
'@payloadcms/plugin-mcp', '@payloadcms/plugin-nested-docs', '@payloadcms/plugin-redirects', '@payloadcms/transformer-sharp', '@payloadcms/translations'] : [])],
|
|
129
144
|
webpack: (webpackConfig, webpackOptions) => {
|
|
130
145
|
const incomingWebpackConfig = typeof nextConfig.webpack === 'function' ? nextConfig.webpack(webpackConfig, webpackOptions) : webpackConfig;
|
|
131
146
|
return {
|
|
132
147
|
...incomingWebpackConfig,
|
|
148
|
+
...(instantLoader ? {
|
|
149
|
+
module: {
|
|
150
|
+
...incomingWebpackConfig.module,
|
|
151
|
+
rules: [...(incomingWebpackConfig.module?.rules || []), {
|
|
152
|
+
enforce: 'pre',
|
|
153
|
+
exclude: /node_modules/,
|
|
154
|
+
test: /[/\\](layout|page)\.(?:[cm]?[jt]s|[jt]sx)$/,
|
|
155
|
+
use: [instantLoader]
|
|
156
|
+
}]
|
|
157
|
+
}
|
|
158
|
+
} : {}),
|
|
133
159
|
externals: [...(incomingWebpackConfig?.externals || []),
|
|
134
160
|
/**
|
|
135
|
-
* See the explanation in the serverExternalPackages section above.
|
|
136
161
|
* We need to force Webpack to emit require() calls for these packages, even though they are not
|
|
137
162
|
* 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.
|
|
138
163
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withPayload.js","names":["poweredByHeader","key","value","withPayload","nextConfig","options","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","cacheComponents","PAYLOAD_CACHE_COMPONENTS_ENABLED","consoleWarn","sassWarningTexts","args","some","text","includes","baseConfig","devIndicators","undefined","position","sassOptions","silenceDeprecations","outputFileTracingExcludes","turbopack","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","resolve","alias","fallback","aws4","basePath","NEXT_BASE_PATH","trailingSlash","NEXT_TRAILING_SLASH"],"sources":["../../src/withPayload/withPayload.js"],"sourcesContent":["/**\n * These files must remain as plain JavaScript (.js) rather than TypeScript (.ts) because they are\n * imported directly in next.config.mjs files. Since next.config files run before the build process,\n * TypeScript compilation is not available. This ensures compatibility with all templates and\n * user projects regardless of their TypeScript setup.\n */\n\nconst poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n}\n\n/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n * */\nexport const withPayload = (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 (nextConfig.cacheComponents) {\n env.PAYLOAD_CACHE_COMPONENTS_ENABLED = 'true'\n }\n\n const consoleWarn = console.warn\n\n const sassWarningTexts = [\n // This warning is a lie - without silencing import deprecation warnings, sass will spam the console with deprecation warnings\n 'Future import deprecation is not yet active, so silencing it is unnecessary',\n // Sometimes happens despite silenceDeprecations\n 'The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0',\n ]\n console.warn = (...args) => {\n if (\n (typeof args[1] === 'string' && sassWarningTexts.some((text) => args[1].includes(text))) ||\n (typeof args[0] === 'string' && sassWarningTexts.some((text) => args[0].includes(text)))\n ) {\n return\n }\n\n consoleWarn(...args)\n }\n\n /** @type {import('next').NextConfig} */\n const baseConfig = {\n ...nextConfig,\n devIndicators:\n nextConfig.devIndicators !== undefined\n ? nextConfig.devIndicators\n : { position: 'bottom-left' },\n env,\n experimental: {\n ...(nextConfig.experimental || {}),\n },\n sassOptions: {\n ...(nextConfig.sassOptions || {}),\n /**\n * This prevents scss warning spam during pnpm dev that looks like this:\n * ⚠ ./path/to/some/index.scss\n * Issue while running loader\n * SassWarning: Deprecation Warning: Sass @import rules are deprecated and\n * will be removed in Dart Sass 3.0.0.\n *\n * More info and automated migrator: https://sass-lang.com/d/import\n *\n * This can be triggered by any `.scss` file in a consumer's project that\n * still uses `@import`.\n */\n silenceDeprecations: [...(nextConfig.sassOptions?.silenceDeprecations || []), 'import'],\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n // Prevents turbopack build errors by the thread-stream package which is installed by pino\n 'pino',\n // file-type v22 uses `import(specifier)` with a non-literal specifier, which Turbopack rejects\n // with \"Cannot find module as expression is too dynamic\"\n 'file-type',\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-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 'json-schema-to-typescript',\n ],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n }\n },\n }\n\n if (nextConfig.basePath) {\n process.env.NEXT_BASE_PATH = nextConfig.basePath\n baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n const trailingSlash = nextConfig.trailingSlash === true ? 'true' : 'false'\n process.env.NEXT_TRAILING_SLASH = trailingSlash\n baseConfig.env.NEXT_TRAILING_SLASH = trailingSlash\n\n return baseConfig\n}\n\nexport default withPayload\n"],"mappings":"AAAA;;;;;GAOA,MAAMA,eAAA,GAAkB;EACtBC,GAAA,EAAK;EACLC,KAAA,EAAO;AACT;AAEA;;;;;AAKA,OAAO,MAAMC,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,IAAIR,UAAA,CAAWS,eAAe,EAAE;IAC9BP,GAAA,CAAIQ,gCAAgC,GAAG;EACzC;EAEA,MAAMC,WAAA,GAAcL,OAAA,CAAQC,IAAI;EAEhC,MAAMK,gBAAA,GAAmB;EACvB;EACA;EACA;EACA,yEACD;EACDN,OAAA,CAAQC,IAAI,GAAG,CAAC,GAAGM,IAAA;IACjB,IACE,OAAQA,IAAI,CAAC,EAAE,KAAK,YAAYD,gBAAA,CAAiBE,IAAI,CAAEC,IAAA,IAASF,IAAI,CAAC,EAAE,CAACG,QAAQ,CAACD,IAAA,MAChF,OAAOF,IAAI,CAAC,EAAE,KAAK,YAAYD,gBAAA,CAAiBE,IAAI,CAAEC,IAAA,IAASF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AAI3C,UAAA,CAAW4C,QAAQ,EAAE;IACvBf,OAAA,CAAQ3B,GAAG,CAAC2C,cAAc,GAAG7C,UAAA,CAAW4C,QAAQ;IAChD3B,UAAA,CAAWf,GAAG,CAAC2C,cAAc,GAAG7C,UAAA,CAAW4C,QAAQ;EACrD;EAEA,MAAME,aAAA,GAAgB9C,UAAA,CAAW8C,aAAa,KAAK,OAAO,SAAS;EACnEjB,OAAA,CAAQ3B,GAAG,CAAC6C,mBAAmB,GAAGD,aAAA;EAClC7B,UAAA,CAAWf,GAAG,CAAC6C,mBAAmB,GAAGD,aAAA;EAErC,OAAO7B,UAAA;AACT;AAEA,eAAelB,WAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"withPayload.js","names":["fileURLToPath","poweredByHeader","key","value","withPayload","nextConfig","options","env","instantLoader","cacheComponents","import","meta","resolve","URL","url","require","undefined","instantLoaderRule","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","PAYLOAD_CACHE_COMPONENTS_ENABLED","consoleWarn","sassWarningTexts","args","some","text","includes","baseConfig","devIndicators","sassOptions","silenceDeprecations","outputFileTracingExcludes","turbopack","rules","concat","condition","all","not","content","loaders","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","module","enforce","exclude","test","use","externals","plugins","IgnorePlugin","resourceRegExp","alias","fallback","aws4","basePath","NEXT_BASE_PATH","trailingSlash","NEXT_TRAILING_SLASH"],"sources":["../../src/withPayload/withPayload.js"],"sourcesContent":["/**\n * These files must remain as plain JavaScript (.js) rather than TypeScript (.ts) because they are\n * imported directly in next.config.mjs files. Since next.config files run before the build process,\n * TypeScript compilation is not available. This ensures compatibility with all templates and\n * user projects regardless of their TypeScript setup.\n */\n\nimport { fileURLToPath } from 'node:url'\n\nconst poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n}\n\n/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const env = { ...nextConfig.env }\n // Adds `export const instant = false` to the admin layout and page. See `instantLoader.js` for\n // why this cannot live in the generated admin files.\n const instantLoader = nextConfig.cacheComponents\n ? typeof import.meta?.resolve === 'function'\n ? fileURLToPath(new URL('./instantLoader.js', import.meta.url))\n : require.resolve('@payloadcms/next/withPayload/instantLoader')\n : undefined\n const instantLoaderRule = '**/{layout,page}.{js,jsx,ts,tsx,mjs,mts,cjs,cts}'\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 (nextConfig.cacheComponents) {\n env.PAYLOAD_CACHE_COMPONENTS_ENABLED = 'true'\n }\n\n const consoleWarn = console.warn\n\n const sassWarningTexts = [\n // This warning is a lie - without silencing import deprecation warnings, sass will spam the console with deprecation warnings\n 'Future import deprecation is not yet active, so silencing it is unnecessary',\n // Sometimes happens despite silenceDeprecations\n 'The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0',\n ]\n console.warn = (...args) => {\n if (\n (typeof args[1] === 'string' && sassWarningTexts.some((text) => args[1].includes(text))) ||\n (typeof args[0] === 'string' && sassWarningTexts.some((text) => args[0].includes(text)))\n ) {\n return\n }\n\n consoleWarn(...args)\n }\n\n /** @type {import('next').NextConfig} */\n const baseConfig = {\n ...nextConfig,\n devIndicators: nextConfig.devIndicators !== undefined ? nextConfig.devIndicators : false,\n env,\n experimental: {\n ...(nextConfig.experimental || {}),\n },\n sassOptions: {\n ...(nextConfig.sassOptions || {}),\n /**\n * This prevents scss warning spam during pnpm dev that looks like this:\n * ⚠ ./path/to/some/index.scss\n * Issue while running loader\n * SassWarning: Deprecation Warning: Sass @import rules are deprecated and\n * will be removed in Dart Sass 3.0.0.\n *\n * More info and automated migrator: https://sass-lang.com/d/import\n *\n * This can be triggered by any `.scss` file in a consumer's project that\n * still uses `@import`.\n */\n silenceDeprecations: [...(nextConfig.sassOptions?.silenceDeprecations || []), 'import'],\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n ...(instantLoader\n ? {\n rules: {\n ...nextConfig.turbopack?.rules,\n [instantLoaderRule]: [\n ...[].concat(nextConfig.turbopack?.rules?.[instantLoaderRule] ?? []),\n {\n // Only send files that import the admin root components to the loader, so\n // Turbopack does not run a JavaScript loader for every other layout and page.\n condition: {\n all: [\n { not: 'foreign' },\n { content: /['\"]@payloadcms\\/next\\/(?:layouts|views)['\"]/ },\n ],\n },\n loaders: [instantLoader],\n },\n ],\n },\n }\n : {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n // Prevents turbopack build errors by the thread-stream package which is installed by pino\n 'pino',\n // file-type v22 uses `import(specifier)` with a non-literal specifier, which Turbopack rejects\n // with \"Cannot find module as expression is too dynamic\"\n 'file-type',\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. Node.js loads them directly instead, so there are fewer\n * files to compile, which means faster compilation speeds.\n *\n * A package can only be listed here if the import map never loads a client component from it. Node.js\n * loads external packages as they are, so a `'use client'` file inside one would not become a client\n * component. That is why packages with client components are not listed (see the TODO below).\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 differences do not matter much, and development speed is more\n * 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/kv-redis',\n '@payloadcms/payload-cloud',\n // Its `/client` entry has no exports, so the import map never loads anything from it\n '@payloadcms/plugin-mcp',\n '@payloadcms/plugin-nested-docs',\n '@payloadcms/plugin-redirects',\n '@payloadcms/transformer-sharp',\n '@payloadcms/translations',\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-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 ...(instantLoader\n ? {\n module: {\n ...incomingWebpackConfig.module,\n rules: [\n ...(incomingWebpackConfig.module?.rules || []),\n {\n enforce: 'pre',\n exclude: /node_modules/,\n test: /[/\\\\](layout|page)\\.(?:[cm]?[jt]s|[jt]sx)$/,\n use: [instantLoader],\n },\n ],\n },\n }\n : {}),\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\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 'json-schema-to-typescript',\n ],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n }\n },\n }\n\n if (nextConfig.basePath) {\n process.env.NEXT_BASE_PATH = nextConfig.basePath\n baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n const trailingSlash = nextConfig.trailingSlash === true ? 'true' : 'false'\n process.env.NEXT_TRAILING_SLASH = trailingSlash\n baseConfig.env.NEXT_TRAILING_SLASH = trailingSlash\n\n return baseConfig\n}\n\nexport default withPayload\n"],"mappings":"AAAA;;;;;GAOA,SAASA,aAAa,QAAQ;AAE9B,MAAMC,eAAA,GAAkB;EACtBC,GAAA,EAAK;EACLC,KAAA,EAAO;AACT;AAEA;;;;;AAKA,OAAO,MAAMC,WAAA,GAAcA,CAACC,UAAA,GAAa,CAAC,CAAC,EAAEC,OAAA,GAAU,CAAC,CAAC;EACvD,MAAMC,GAAA,GAAM;IAAE,GAAGF,UAAA,CAAWE;EAAI;EAChC;EACA;EACA,MAAMC,aAAA,GAAgBH,UAAA,CAAWI,eAAe,GAC5C,OAAOC,MAAA,CAAAC,IAAA,EAAaC,OAAA,KAAY,aAC9B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