@payloadcms/next 4.0.0-internal.ea6e8f8 → 4.0.0-internal.ee5d8bd

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.
Files changed (32) hide show
  1. package/dist/adapters/UnmountWhenHidden/index.d.ts +18 -0
  2. package/dist/adapters/UnmountWhenHidden/index.d.ts.map +1 -0
  3. package/dist/adapters/UnmountWhenHidden/index.js +64 -0
  4. package/dist/adapters/UnmountWhenHidden/index.js.map +1 -0
  5. package/dist/adapters/metadata.js.map +1 -1
  6. package/dist/adapters/router.d.ts.map +1 -1
  7. package/dist/adapters/router.js +58 -21
  8. package/dist/adapters/router.js.map +1 -1
  9. package/dist/adapters/views.d.ts +3 -2
  10. package/dist/adapters/views.d.ts.map +1 -1
  11. package/dist/adapters/views.js +26 -11
  12. package/dist/adapters/views.js.map +1 -1
  13. package/dist/auth/login.js.map +1 -1
  14. package/dist/cjs/withPayload.cjs +86 -49
  15. package/dist/cjs/withPayload.cjs.map +4 -4
  16. package/dist/prod/styles.css +1 -1
  17. package/dist/routes/graphql/handler.d.ts.map +1 -1
  18. package/dist/routes/graphql/handler.js +1 -17
  19. package/dist/routes/graphql/handler.js.map +1 -1
  20. package/dist/routes/rest/og/index.d.ts.map +1 -1
  21. package/dist/routes/rest/og/index.js.map +1 -1
  22. package/dist/utilities/initAdminContext.d.ts.map +1 -1
  23. package/dist/utilities/initAdminContext.js +14 -5
  24. package/dist/utilities/initAdminContext.js.map +1 -1
  25. package/dist/withPayload/instantLoader.d.ts +16 -0
  26. package/dist/withPayload/instantLoader.d.ts.map +1 -0
  27. package/dist/withPayload/instantLoader.js +27 -0
  28. package/dist/withPayload/instantLoader.js.map +1 -0
  29. package/dist/withPayload/withPayload.d.ts.map +1 -1
  30. package/dist/withPayload/withPayload.js +41 -42
  31. package/dist/withPayload/withPayload.js.map +1 -1
  32. package/package.json +37 -36
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,SAAS,CAAA;AAsEjF,eAAO,MAAM,UAAU,WAAkB,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,iBAyBlF,CAAA;AAED,eAAO,MAAM,IAAI,WACN,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,eAAqB,OAAO,sBAyE9E,CAAA"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,SAAS,CAAA;AAqEjF,eAAO,MAAM,UAAU,WAAkB,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,iBAyBlF,CAAA;AAED,eAAO,MAAM,IAAI,WACN,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,eAAqB,OAAO,sBA6D9E,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { configToSchema } from '@payloadcms/graphql';
2
2
  import { createHandler } from 'graphql-http/lib/use/fetch';
3
- import { addDataAndFileToRequest, addLocalesToRequestFromData, assertBranchReadable, createPayloadRequestFromWebRequest, headersWithCors, logError, mergeHeaders } from 'payload';
3
+ import { addDataAndFileToRequest, addLocalesToRequestFromData, createPayloadRequestFromWebRequest, headersWithCors, logError, mergeHeaders } from 'payload';
4
4
  import { httpStatus } from 'payload/internal';
5
5
  const handleError = async ({
6
6
  err,
@@ -90,22 +90,6 @@ export const POST = config => async request => {
90
90
  status: 404
91
91
  });
92
92
  }
93
- // GraphQL takes its branch the same way REST does — a query param on the request —
94
- // so it needs the same gate (§12.5). Answered as a bare 403 rather than a GraphQL
95
- // error body: the request is refused before any operation is parsed.
96
- try {
97
- await assertBranchReadable({
98
- req
99
- });
100
- } catch (_err) {
101
- return new Response(null, {
102
- headers: headersWithCors({
103
- headers: new Headers(),
104
- req
105
- }),
106
- status: 403
107
- });
108
- }
109
93
  await addDataAndFileToRequest(req);
110
94
  addLocalesToRequestFromData(req);
111
95
  const {
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","names":["configToSchema","createHandler","addDataAndFileToRequest","addLocalesToRequestFromData","assertBranchReadable","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","_err","headers","Headers","validationRules","apiResponse","onOperation","args","errors","all","map","_","defaultRules","concat","resHeaders","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 assertBranchReadable,\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 // GraphQL takes its branch the same way REST does — a query param on the request —\n // so it needs the same gate (§12.5). Answered as a bare 403 rather than a GraphQL\n // error body: the request is refused before any operation is parsed.\n try {\n await assertBranchReadable({ req })\n } catch (_err) {\n return new Response(null, {\n headers: headersWithCors({ headers: new Headers(), req }),\n status: 403,\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,oBAAoB,EACpBC,kCAAkC,EAClCC,eAAe,EACfC,QAAQ,EACRC,YAAY,QACP;AACP,SAASC,UAAU,QAAQ;AAE3B,MAAMC,WAAA,GAAc,MAAAA,CAAO;EACzBC,GAAG;EACHC,OAAO;EACPC;AAAG,CAKJ;EACC,MAAMC,MAAA,GAASH,GAAC,CAAII,aAAa,CAAcD,MAAM,IAAIL,UAAA,CAAWO,qBAAqB;EACzF,IAAIC,YAAA,GAAeN,GAAA,CAAIO,OAAO;EAC9BX,QAAA,CAAS;IAAEI,GAAA;IAAKC;EAAQ;EAExB;EACA;EACA,IAAI,CAACA,OAAA,CAAQO,MAAM,CAACC,KAAK,IAAIN,MAAA,KAAWL,UAAA,CAAWO,qBAAqB,EAAE;IACxEC,YAAA,GAAe;EACjB;EAEA,IAAII,QAAA,GAAkC;IACpCC,UAAA,EAAY;MACVC,IAAA,EAAMZ,GAAA,EAAKI,aAAA,EAAeQ,IAAA,IAAQC,SAAA;MAClCC,IAAA,EAAMd,GAAC,IAAOA,GAAA,CAAII,aAAa,IAAIJ,GAAC,CAAII,aAAa,CAAcU,IAAI,IAAKD,SAAA;MAC5EE,KAAA,EAAOd,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A,CAAOZ,OAAA,EAASa,IAAA,EAAM/B,MAAA;MACjC,MAAMd,QAAA,GACJ,OAAOT,OAAA,CAAQU,UAAU,KAAK,aAC1B,MAAMV,OAAA,CAAQU,UAAU,CAAC;QACvB4C,IAAA;QACArD,GAAA,EAAKwC,OAAA;QACLlB;MACF,KACAA,MAAA;MACN,IAAId,QAAA,CAAS8C,MAAM,EAAE;QACnB,MAAMA,MAAA,GAAU,MAAM5B,OAAA,CAAQ6B,GAAG,CAC/BjC,MAAA,CAAOgC,MAAM,CAACE,GAAG,CAAEhC,KAAA;UACjB,OAAO3B,WAAA,CAAY;YAAEC,GAAA,EAAK0B,KAAA;YAAOzB,OAAA;YAASC;UAAI;QAChD;QAEF;QACA,OAAO;UAAE,GAAGQ,QAAQ;UAAE8C;QAAO;MAC/B;MACA,OAAO9C,QAAA;IACT;IACA6B,MAAA;IACAa,eAAA,EAAiBA,CAACO,CAAA,EAAGJ,IAAA,EAAMK,YAAA,KAAiBA,YAAA,CAAaC,MAAM,CAACT,eAAA,CAAgBG,IAAA;EAClF,GAAGZ,eAAA;EAEH,MAAMmB,UAAA,GAAanE,eAAA,CAAgB;IACjCuD,OAAA,EAAS,IAAIC,OAAA,CAAQE,WAAA,CAAYH,OAAO;IACxChD;EACF;EAEA,KAAK,MAAM6D,GAAA,IAAOb,OAAA,EAAS;IACzBY,UAAA,CAAWE,MAAM,CAACD,GAAA,EAAKb,OAAO,CAACa,GAAA,CAAI;EACrC;EAEA,OAAO,IAAIf,QAAA,CAASK,WAAA,CAAYY,IAAI,EAAE;IACpCf,OAAA,EAAShD,GAAA,CAAIgE,eAAe,GAAGrE,YAAA,CAAaK,GAAA,CAAIgE,eAAe,EAAEJ,UAAA,IAAcA,UAAA;IAC/E3D,MAAA,EAAQkD,WAAA,CAAYlD;EACtB;AACF","ignoreList":[]}
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,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CAAgBI,IAAA;EAClF,GAAGV,eAAA;EAEH,MAAMiB,UAAA,GAAajE,eAAA,CAAgB;IACjCuD,OAAA,EAAS,IAAIW,OAAA,CAAQV,WAAA,CAAYD,OAAO;IACxChD;EACF;EAEA,KAAK,MAAM4D,GAAA,IAAOZ,OAAA,EAAS;IACzBU,UAAA,CAAWG,MAAM,CAACD,GAAA,EAAKZ,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":"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,cA8D7B,CAAA"}
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 (\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 {\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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,QAAA;IAEJ,IAAI;MACF;MACA;MACA;MACAA,QAAA,GAAWlC,EAAA,CAAGmC,QAAQ,CAACjC,IAAA,CAAKkC,IAAI,CAAC1B,OAAA,EAAS;IAC5C,EAAE,OAAO2B,CAAA,EAAG;MACVvB,GAAA,CAAIE,OAAO,CAACsB,MAAM,CAACjB,KAAK,CAAC,4CAA4CgB,CAAA,CAAEE,OAAO,EAAE;IAClF;IAEA,MAAMC,UAAA,GAAa;IAEnB,OAAO,IAAIvC,aAAA,cAEPwC,IAAA,CAACpC,OAAA;MACC4B,WAAA,EAAaA,WAAA;MACbS,QAAA,EAAU3C,WAAA;MACVyC,UAAA,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;QAGX;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":[]}
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;AAEvB,OAAO,MAAMC,WAAA,GAAc;AAE3B,OAAO,MAAMC,eAAA,GAAkC,MAAOC,GAAA;EACpD,MAAMC,MAAA,GAASD,GAAA,CAAIE,OAAO,CAACD,MAAM;EAEjC,IAAIA,MAAA,CAAOE,KAAK,CAACT,IAAI,CAACU,kBAAkB,KAAK,OAAO;IAClD,OAAOC,QAAA,CAASC,IAAI,CAAC;MAAEC,KAAA,EAAO;IAAiC,GAAG;MAAEC,MAAA,EAAQ;IAAI;EAClF;EAEA,IAAI;IACF,MAAM;MAAEC;IAAY,CAAE,GAAG,IAAIC,GAAA,CAAIV,GAAA,CAAIL,GAAG;IAExC,MAAMgB,QAAA,GAAWF,YAAA,CAAaG,GAAG,CAAC;IAClC,MAAMC,KAAA,GAAQF,QAAA,GAAWF,YAAA,CAAaK,GAAG,CAAC,UAAUC,KAAA,CAAM,GAAG,OAAO;IACpE,MAAMC,SAAA,GAAYP,YAAA,CAAaG,GAAG,CAAC;IACnC,MAAMK,MAAA,GAASD,SAAA,GAAYP,YAAA,CAAaK,GAAG,CAAC,WAAWC,KAAA,CAAM,GAAG,KAAKG,OAAA,CAAQ,KAAK,OAAO;IACzF,MAAMC,WAAA,GAAcV,YAAA,CAAaG,GAAG,CAAC,iB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":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,KAAK,EAAqB,oBAAoB,EAAuB,MAAM,kBAAkB,CAAA;AAsBpG,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,SAAU,wBAAwB,0BAK3D,CAAA"}
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"}
@@ -1,3 +1,4 @@
1
+ import { connection } from 'next/server.js';
1
2
  import { initAdminContext as initPayloadAdminContext } from 'payload/internal';
2
3
  import { nextServerAdapter } from '../adapters/server.js';
3
4
  import { selectiveCache } from './selectiveCache.js';
@@ -18,9 +19,17 @@ const cache = {
18
19
  key: [key, ...cacheArgs]
19
20
  })
20
21
  };
21
- export const initAdminContext = args => initPayloadAdminContext({
22
- ...args,
23
- cache,
24
- serverAdapter: nextServerAdapter
25
- });
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
+ };
26
35
  //# sourceMappingURL=initAdminContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"initAdminContext.js","names":["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 { 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 = (args: NextInitAdminContextArgs) =>\n initPayloadAdminContext({\n ...args,\n cache,\n serverAdapter: nextServerAdapter,\n })\n"],"mappings":"AAGA,SAASA,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,GAAoBkB,IAAA,IAC/BjB,uBAAA,CAAwB;EACtB,GAAGiB,IAAI;EACPX,KAAA;EACAY,aAAA,EAAejB;AACjB","ignoreList":[]}
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,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;AAOH;;;;KAIK;AACL,eAAO,MAAM,WAAW,gBAJb,OAAO,MAAM,EAAE,UAAU,YAEjC;IAA0B,uBAAuB,AAAjD,CAA4G,EAApG,OAAO,CAA6F;CAAA,8BAqP9G,CAAA;eAEc,WAAW"}
1
+ {"version":3,"file":"withPayload.d.ts","sourceRoot":"","sources":["../../src/withPayload/withPayload.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH;;;;KAIK;AACL,eAAO,MAAM,WAAW,gBAJb,OAAO,MAAM,EAAE,UAAU,YAEjC;IAA0B,uBAAuB,AAAjD,CAA4G,EAApG,OAAO,CAA6F;CAAA,8BAoO9G,CAAA;eAEc,WAAW"}
@@ -3,7 +3,9 @@
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
- */const poweredByHeader = {
6
+ */import { fileURLToPath } from 'node:url';
7
+ import { devServerExternalPackages as devServerExternalPayloadPackages, serverExternalPackages as serverExternalPayloadPackages } from 'payload/build-config';
8
+ const poweredByHeader = {
7
9
  key: 'X-Powered-By',
8
10
  value: 'Next.js, Payload'
9
11
  };
@@ -13,7 +15,13 @@
13
15
  * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false
14
16
  * */
15
17
  export const withPayload = (nextConfig = {}, options = {}) => {
16
- const env = nextConfig.env || {};
18
+ const env = {
19
+ ...nextConfig.env
20
+ };
21
+ // Adds `export const instant = false` to the admin layout and page. See `instantLoader.js` for
22
+ // why this cannot live in the generated admin files.
23
+ const instantLoader = nextConfig.cacheComponents ? typeof import.meta?.resolve === 'function' ? fileURLToPath(new URL('./instantLoader.js', import.meta.url)) : require.resolve('@payloadcms/next/withPayload/instantLoader') : undefined;
24
+ const instantLoaderRule = '**/{layout,page}.{js,jsx,ts,tsx,mjs,mts,cjs,cts}';
17
25
  if (nextConfig.experimental?.staleTimes?.dynamic) {
18
26
  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
27
  env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true';
@@ -62,7 +70,24 @@ export const withPayload = (nextConfig = {}, options = {}) => {
62
70
  '**/*': [...(nextConfig.outputFileTracingExcludes?.['**/*'] || []), 'drizzle-kit', 'drizzle-kit/api']
63
71
  },
64
72
  turbopack: {
65
- ...(nextConfig.turbopack || {})
73
+ ...(nextConfig.turbopack || {}),
74
+ ...(instantLoader ? {
75
+ rules: {
76
+ ...nextConfig.turbopack?.rules,
77
+ [instantLoaderRule]: [...[].concat(nextConfig.turbopack?.rules?.[instantLoaderRule] ?? []), {
78
+ // Only send files that import the admin root components to the loader, so
79
+ // Turbopack does not run a JavaScript loader for every other layout and page.
80
+ condition: {
81
+ all: [{
82
+ not: 'foreign'
83
+ }, {
84
+ content: /['"]@payloadcms\/next\/(?:layouts|views)['"]/
85
+ }]
86
+ },
87
+ loaders: [instantLoader]
88
+ }]
89
+ }
90
+ } : {})
66
91
  },
67
92
  // We disable the poweredByHeader here because we add it manually in the headers function below
68
93
  ...(nextConfig.poweredByHeader !== false ? {
@@ -84,53 +109,27 @@ export const withPayload = (nextConfig = {}, options = {}) => {
84
109
  source: '/:path*'
85
110
  }];
86
111
  },
87
- serverExternalPackages: [...(nextConfig.serverExternalPackages || []),
88
- // WHY: without externalizing graphql, a graphql version error will be thrown
89
- // during runtime ("Ensure that there is only one instance of \"graphql\" in the node_modules\ndirectory.")
90
- 'graphql', 'drizzle-kit', 'drizzle-kit/api', 'sharp', 'libsql', 'require-in-the-middle', 'json-schema-to-typescript',
91
- // Prevents turbopack build errors by the thread-stream package which is installed by pino
92
- 'pino',
112
+ serverExternalPackages: [...new Set([...(nextConfig.serverExternalPackages || []), ...serverExternalPayloadPackages,
93
113
  // file-type v22 uses `import(specifier)` with a non-literal specifier, which Turbopack rejects
94
114
  // with "Cannot find module as expression is too dynamic"
95
- 'file-type', ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true ?
96
- /**
97
- * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we
98
- * do not bundle server-only packages during dev for two reasons:
99
- *
100
- * 1. Performance: Fewer files to compile means faster compilation speeds.
101
- * 2. Turbopack support: Webpack's externals are not supported by Turbopack.
102
- *
103
- * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to
104
- * externalized packages that are not resolvable from the project root. So including a package like
105
- * "drizzle-kit" in here would do nothing - Next.js will ignore the rule and still bundle the package -
106
- * because it detects that the package is not resolvable from the project root (= not directly installed
107
- * by the user in their own package.json).
108
- *
109
- * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly
110
- * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).
111
- *
112
- *
113
- *
114
- * We should only do this during development, not build, because externalizing these packages can hurt
115
- * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the
116
- * same package.
117
- *
118
- * Example:
119
- * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)
120
- * - payload (not in bundle, external) -> installs qs-esm (external because of importer)
121
- * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.
122
- *
123
- * During development, these bundle size difference do not matter much, and development speed /
124
- * turbopack support are more important.
125
- */
126
- ['payload', '@payloadcms/db-mongodb', '@payloadcms/db-postgres', '@payloadcms/db-sqlite', '@payloadcms/db-vercel-postgres', '@payloadcms/db-d1-sqlite', '@payloadcms/drizzle', '@payloadcms/email-nodemailer', '@payloadcms/email-resend', '@payloadcms/graphql', '@payloadcms/payload-cloud', '@payloadcms/plugin-redirects'] : [])],
115
+ 'file-type', ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true ? devServerExternalPayloadPackages : [])])],
127
116
  webpack: (webpackConfig, webpackOptions) => {
128
117
  const incomingWebpackConfig = typeof nextConfig.webpack === 'function' ? nextConfig.webpack(webpackConfig, webpackOptions) : webpackConfig;
129
118
  return {
130
119
  ...incomingWebpackConfig,
120
+ ...(instantLoader ? {
121
+ module: {
122
+ ...incomingWebpackConfig.module,
123
+ rules: [...(incomingWebpackConfig.module?.rules || []), {
124
+ enforce: 'pre',
125
+ exclude: /node_modules/,
126
+ test: /[/\\](layout|page)\.(?:[cm]?[jt]s|[jt]sx)$/,
127
+ use: [instantLoader]
128
+ }]
129
+ }
130
+ } : {}),
131
131
  externals: [...(incomingWebpackConfig?.externals || []),
132
132
  /**
133
- * See the explanation in the serverExternalPackages section above.
134
133
  * We need to force Webpack to emit require() calls for these packages, even though they are not
135
134
  * 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.
136
135
  *
@@ -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","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: 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 },\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;EACh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BE,OAAA,IAAW,EAAE;QACxC;QACA,IAAIH,cAAA,CAAeF,OAAO,CAACM,YAAY,CAAC;UACtCC,cAAA,EAAgB;QAClB,GACD;QACDC,OAAA,EAAS;UACP,IAAIL,qBAAA,EAAuBK,OAAA,IAAW,CAAC,CAAC;UACxCC,KAAA,EAAO;YACL,IAAIN,qBAAA,EAAuBK,OAAA,EAASC,KAAA,IAAS,CAAC,CAAC;UACjD;UACAC,QAAA,EAAU;YACR,IAAIP,qBAAA,EAAuBK,OAAA,EAASE,QAAA,IAAY,CAAC,CAAC;YAClD;;;;;;;;;;;;;;;;;;;YAmBAC,IAAA,EAAM;UACR;QACF;MACF;IACF;EACF;EAEA,IAAI1C,UAAA,CAAW2C,QAAQ,EAAE;IACvBf,OAAA,CAAQ1B,GAAG,CAAC0C,cAAc,GAAG5C,UAAA,CAAW2C,QAAQ;IAChD1B,UAAA,CAAWf,GAAG,CAAC0C,cAAc,GAAG5C,UAAA,CAAW2C,QAAQ;EACrD;EAEA,MAAME,aAAA,GAAgB7C,UAAA,CAAW6C,aAAa,KAAK,OAAO,SAAS;EACnEjB,OAAA,CAAQ1B,GAAG,CAAC4C,mBAAmB,GAAGD,aAAA;EAClC5B,UAAA,CAAWf,GAAG,CAAC4C,mBAAmB,GAAGD,aAAA;EAErC,OAAO5B,UAAA;AACT;AAEA,eAAelB,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"withPayload.js","names":["fileURLToPath","devServerExternalPackages","devServerExternalPayloadPackages","serverExternalPackages","serverExternalPayloadPackages","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","Set","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'\nimport {\n devServerExternalPackages as devServerExternalPayloadPackages,\n serverExternalPackages as serverExternalPayloadPackages,\n} from 'payload/build-config'\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 ...new Set([\n ...(nextConfig.serverExternalPackages || []),\n ...serverExternalPayloadPackages,\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 ? devServerExternalPayloadPackages\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.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AAA,EAAK,CAACnD,aAAA;YACR;UAEJ;QACF,IACA,CAAC,CAAC;QACNoD,SAAA,EAAW,C,IACLN,qBAAA,EAAuBM,SAAA,IAAa,EAAE;QAC1C;;;;;;;QAOA,eACA,mBACA,SACA,UACA,yBACA,4BACD;QACDC,OAAA,EAAS,C,IACHP,qBAAA,EAAuBO,OAAA,IAAW,EAAE;QACxC;QACA,IAAIR,cAAA,CAAeF,OAAO,CAACW,YAAY,CAAC;UACtCC,cAAA,EAAgB;QAClB,GACD;QACDnD,OAAA,EAAS;UACP,IAAI0C,qBAAA,EAAuB1C,OAAA,IAAW,CAAC,CAAC;UACxCoD,KAAA,EAAO;YACL,IAAIV,qBAAA,EAAuB1C,OAAA,EAASoD,KAAA,IAAS,CAAC,CAAC;UACjD;UACAC,QAAA,EAAU;YACR,IAAIX,qBAAA,EAAuB1C,OAAA,EAASqD,QAAA,IAAY,CAAC,CAAC;YAClD;;;;;;;;;;;;;;;;;;;YAmBAC,IAAA,EAAM;UACR;QACF;MACF;IACF;EACF;EAEA,IAAI7D,UAAA,CAAW8D,QAAQ,EAAE;IACvBnB,OAAA,CAAQzC,GAAG,CAAC6D,cAAc,GAAG/D,UAAA,CAAW8D,QAAQ;IAChDpC,UAAA,CAAWxB,GAAG,CAAC6D,cAAc,GAAG/D,UAAA,CAAW8D,QAAQ;EACrD;EAEA,MAAME,aAAA,GAAgBhE,UAAA,CAAWgE,aAAa,KAAK,OAAO,SAAS;EACnErB,OAAA,CAAQzC,GAAG,CAAC+D,mBAAmB,GAAGD,aAAA;EAClCtC,UAAA,CAAWxB,GAAG,CAAC+D,mBAAmB,GAAGD,aAAA;EAErC,OAAOtC,UAAA;AACT;AAEA,eAAe3B,WAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,12 +1,7 @@
1
1
  {
2
2
  "name": "@payloadcms/next",
3
- "version": "4.0.0-internal.ea6e8f8",
3
+ "version": "4.0.0-internal.ee5d8bd",
4
4
  "homepage": "https://payloadcms.com",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/payloadcms/payload.git",
8
- "directory": "packages/next"
9
- },
10
5
  "license": "MIT",
11
6
  "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
12
7
  "maintainers": [
@@ -16,10 +11,20 @@
16
11
  "url": "https://payloadcms.com"
17
12
  }
18
13
  ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/payloadcms/payload.git",
17
+ "directory": "packages/next"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "type": "module",
19
23
  "sideEffects": [
20
24
  "*.css"
21
25
  ],
22
- "type": "module",
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.js",
23
28
  "exports": {
24
29
  "./css": {
25
30
  "types": "./dist/exports/css.d.ts",
@@ -55,25 +60,22 @@
55
60
  "import": "./dist/exports/views.js",
56
61
  "types": "./dist/exports/views.d.ts",
57
62
  "default": "./dist/exports/views.js"
63
+ },
64
+ "./withPayload/instantLoader": {
65
+ "import": "./dist/withPayload/instantLoader.js",
66
+ "default": "./dist/withPayload/instantLoader.js"
58
67
  }
59
68
  },
60
- "main": "./dist/index.js",
61
- "types": "./dist/index.js",
62
- "files": [
63
- "dist"
64
- ],
65
- "lint-staged": {
66
- "**/package.json": "sort-package-json",
67
- "*.{md,mdx,yml,json}": "prettier --write",
68
- "*.{js,jsx,ts,tsx}": [
69
- "eslint --flag v10_config_lookup_from_file --cache --fix",
70
- "prettier --write"
71
- ]
69
+ "publishConfig": {
70
+ "registry": "https://registry.npmjs.org/"
72
71
  },
73
72
  "dependencies": {
74
73
  "@dnd-kit/core": "6.3.1",
75
74
  "@dnd-kit/modifiers": "9.0.0",
76
75
  "@dnd-kit/sortable": "10.0.0",
76
+ "@payloadcms/graphql": "4.0.0-internal.ee5d8bd",
77
+ "@payloadcms/translations": "4.0.0-internal.ee5d8bd",
78
+ "@payloadcms/ui": "4.0.0-internal.ee5d8bd",
77
79
  "busboy": "^1.6.0",
78
80
  "dequal": "2.0.3",
79
81
  "file-type": "22.0.1",
@@ -82,10 +84,7 @@
82
84
  "path-to-regexp": "6.3.0",
83
85
  "qs-esm": "8.0.1",
84
86
  "sass": "1.77.4",
85
- "uuid": "14.0.0",
86
- "@payloadcms/graphql": "4.0.0-internal.ea6e8f8",
87
- "@payloadcms/ui": "4.0.0-internal.ea6e8f8",
88
- "@payloadcms/translations": "4.0.0-internal.ea6e8f8"
87
+ "uuid": "14.0.0"
89
88
  },
90
89
  "devDependencies": {
91
90
  "@babel/cli": "7.27.2",
@@ -93,27 +92,31 @@
93
92
  "@babel/preset-env": "7.27.2",
94
93
  "@babel/preset-react": "7.27.1",
95
94
  "@babel/preset-typescript": "7.27.1",
96
- "@next/eslint-plugin-next": "16.4.0",
95
+ "@next/eslint-plugin-next": "16.4.2",
97
96
  "@types/busboy": "1.5.4",
98
97
  "@types/react": "19.3.0",
99
98
  "@types/react-dom": "19.3.0",
100
- "babel-plugin-react-compiler": "19.1.0-rc.3",
99
+ "babel-plugin-react-compiler": "1.0.0",
101
100
  "esbuild": "0.27.1",
102
101
  "esbuild-sass-plugin": "3.3.1",
103
- "swc-plugin-transform-remove-imports": "8.3.0",
104
- "payload": "4.0.0-internal.ea6e8f8",
105
- "@payloadcms/eslint-config": "3.28.0"
102
+ "payload": "4.0.0-internal.ee5d8bd",
103
+ "swc-plugin-transform-remove-imports": "8.3.0"
106
104
  },
107
105
  "peerDependencies": {
108
106
  "graphql": "^16.8.1",
109
107
  "next": ">=16.4.0 <17.0.0",
110
- "payload": "4.0.0-internal.ea6e8f8"
108
+ "payload": "4.0.0-internal.ee5d8bd"
111
109
  },
112
- "engines": {
113
- "node": ">=24.15.0"
110
+ "lint-staged": {
111
+ "*.{cjs,css,cts,graphql,html,json,jsonc,md,mdx,mjs,mts,scss,toml,yaml,yml}": "oxfmt --no-error-on-unmatched-pattern",
112
+ ".swcrc": "oxfmt --no-error-on-unmatched-pattern",
113
+ "*.{js,jsx,ts,tsx}": [
114
+ "oxlint -c ../../oxlint.config.ts --fix --no-error-on-unmatched-pattern",
115
+ "oxfmt --no-error-on-unmatched-pattern"
116
+ ]
114
117
  },
115
- "publishConfig": {
116
- "registry": "https://registry.npmjs.org/"
118
+ "engines": {
119
+ "node": ">=24.22.1"
117
120
  },
118
121
  "scripts": {
119
122
  "build": "pnpm build:reactcompiler",
@@ -129,8 +132,6 @@
129
132
  "build:without_reactcompiler": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm copyfiles && pnpm build:types && pnpm build:swc && pnpm build:cjs && pnpm build:esbuild",
130
133
  "clean": "rimraf -g {dist,*.tsbuildinfo,esbuild}",
131
134
  "copyfiles": "copyfiles -u 1 -e \"**/*.spec.*\" \"src/**/*.{html,css,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
132
- "copyfiles:debug": "copyfiles -u 1 -e \"**/*.spec.*\" \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
133
- "lint": "eslint .",
134
- "lint:fix": "eslint . --fix"
135
+ "copyfiles:debug": "copyfiles -u 1 -e \"**/*.spec.*\" \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/"
135
136
  }
136
137
  }