@payloadcms/next 4.0.0-internal.e7d4ebc → 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 (67) 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/handleServerFunctions.d.ts.map +1 -1
  6. package/dist/adapters/handleServerFunctions.js +4 -6
  7. package/dist/adapters/handleServerFunctions.js.map +1 -1
  8. package/dist/adapters/layout.d.ts +2 -2
  9. package/dist/adapters/layout.d.ts.map +1 -1
  10. package/dist/adapters/layout.js +3 -3
  11. package/dist/adapters/layout.js.map +1 -1
  12. package/dist/adapters/metadata.js.map +1 -1
  13. package/dist/adapters/router.d.ts.map +1 -1
  14. package/dist/adapters/router.js +58 -21
  15. package/dist/adapters/router.js.map +1 -1
  16. package/dist/adapters/views.d.ts +3 -2
  17. package/dist/adapters/views.d.ts.map +1 -1
  18. package/dist/adapters/views.js +27 -17
  19. package/dist/adapters/views.js.map +1 -1
  20. package/dist/auth/login.d.ts +3 -18
  21. package/dist/auth/login.d.ts.map +1 -1
  22. package/dist/auth/login.js +6 -62
  23. package/dist/auth/login.js.map +1 -1
  24. package/dist/auth/logout.d.ts +2 -5
  25. package/dist/auth/logout.d.ts.map +1 -1
  26. package/dist/auth/logout.js +6 -47
  27. package/dist/auth/logout.js.map +1 -1
  28. package/dist/auth/refresh.d.ts +2 -4
  29. package/dist/auth/refresh.d.ts.map +1 -1
  30. package/dist/auth/refresh.js +6 -51
  31. package/dist/auth/refresh.js.map +1 -1
  32. package/dist/cjs/withPayload.cjs +96 -69
  33. package/dist/cjs/withPayload.cjs.map +4 -4
  34. package/dist/prod/styles.css +1 -1
  35. package/dist/routes/graphql/handler.js +3 -3
  36. package/dist/routes/graphql/handler.js.map +1 -1
  37. package/dist/routes/graphql/playground.d.ts.map +1 -1
  38. package/dist/routes/graphql/playground.js +2 -2
  39. package/dist/routes/graphql/playground.js.map +1 -1
  40. package/dist/routes/rest/og/index.d.ts.map +1 -1
  41. package/dist/routes/rest/og/index.js.map +1 -1
  42. package/dist/utilities/initAdminContext.d.ts +8 -0
  43. package/dist/utilities/initAdminContext.d.ts.map +1 -0
  44. package/dist/utilities/initAdminContext.js +35 -0
  45. package/dist/utilities/initAdminContext.js.map +1 -0
  46. package/dist/utilities/selectiveCache.d.ts +18 -0
  47. package/dist/utilities/selectiveCache.d.ts.map +1 -0
  48. package/dist/utilities/selectiveCache.js +36 -0
  49. package/dist/utilities/selectiveCache.js.map +1 -0
  50. package/dist/withPayload/instantLoader.d.ts +16 -0
  51. package/dist/withPayload/instantLoader.d.ts.map +1 -0
  52. package/dist/withPayload/instantLoader.js +27 -0
  53. package/dist/withPayload/instantLoader.js.map +1 -0
  54. package/dist/withPayload/withPayload.d.ts.map +1 -1
  55. package/dist/withPayload/withPayload.js +51 -62
  56. package/dist/withPayload/withPayload.js.map +1 -1
  57. package/package.json +41 -42
  58. package/dist/utilities/getExistingAuthToken.d.ts +0 -7
  59. package/dist/utilities/getExistingAuthToken.d.ts.map +0 -1
  60. package/dist/utilities/getExistingAuthToken.js +0 -6
  61. package/dist/utilities/getExistingAuthToken.js.map +0 -1
  62. package/dist/utilities/setPayloadAuthCookie.d.ts +0 -9
  63. package/dist/utilities/setPayloadAuthCookie.d.ts.map +0 -1
  64. package/dist/utilities/setPayloadAuthCookie.js +0 -27
  65. package/dist/utilities/setPayloadAuthCookie.js.map +0 -1
  66. package/dist/withPayload/withPayload.spec.js +0 -56
  67. package/dist/withPayload/withPayload.spec.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"logout.js","names":["cookies","getCookies","headers","nextHeaders","createLocalReq","getPayload","logoutOperation","getExistingAuthToken","logout","allSessions","config","payload","cron","authResult","auth","user","message","success","req","collection","collections","logoutResult","existingCookie","cookiePrefix","delete","name"],"sources":["../../src/auth/logout.ts"],"sourcesContent":["'use server'\n\nimport type { MaybePromise, SanitizedConfig } from 'payload'\n\nimport { cookies as getCookies, headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, logoutOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\n\nexport async function logout({\n allSessions = false,\n config,\n}: {\n allSessions?: boolean\n config: MaybePromise<SanitizedConfig>\n}) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const authResult = await payload.auth({ headers })\n\n if (!authResult.user) {\n return { message: 'User already logged out', success: true }\n }\n\n const { user } = authResult\n const req = await createLocalReq({ user }, payload)\n const collection = payload.collections[user.collection]\n\n const logoutResult = await logoutOperation({\n allSessions,\n collection,\n req,\n })\n\n if (!logoutResult) {\n return { message: 'Logout failed', success: false }\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (existingCookie) {\n const cookies = await getCookies()\n cookies.delete(existingCookie.name)\n }\n\n return { message: 'User logged out successfully', success: true }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,UAAU,EAAEC,OAAA,IAAWC,WAAW,QAAQ;AAC9D,SAASC,cAAc,EAAEC,UAAU,EAAEC,eAAe,QAAQ;AAE5D,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,OAAO;EAC3BC,WAAA,GAAc,KAAK;EACnBC;AAAM,CAIP;EACC,MAAMC,OAAA,GAAU,MAAMN,UAAA,CAAW;IAAEK,MAAA;IAAQE,IAAA,EAAM;EAAK;EACtD,MAAMV,OAAA,GAAU,MAAMC,WAAA;EACtB,MAAMU,UAAA,GAAa,MAAMF,OAAA,CAAQG,IAAI,CAAC;IAAEZ;EAAQ;EAEhD,IAAI,CAACW,UAAA,CAAWE,IAAI,EAAE;IACpB,OAAO;MAAEC,OAAA,EAAS;MAA2BC,OAAA,EAAS;IAAK;EAC7D;EAEA,MAAM;IAAEF;EAAI,CAAE,GAAGF,UAAA;EACjB,MAAMK,GAAA,GAAM,MAAMd,cAAA,CAAe;IAAEW;EAAK,GAAGJ,OAAA;EAC3C,MAAMQ,UAAA,GAAaR,OAAA,CAAQS,WAAW,CAACL,IAAA,CAAKI,UAAU,CAAC;EAEvD,MAAME,YAAA,GAAe,MAAMf,eAAA,CAAgB;IACzCG,WAAA;IACAU,UAAA;IACAD;EACF;EAEA,IAAI,CAACG,YAAA,EAAc;IACjB,OAAO;MAAEL,OAAA,EAAS;MAAiBC,OAAA,EAAS;IAAM;EACpD;EAEA,MAAMK,cAAA,GAAiB,MAAMf,oBAAA,CAAqBI,OAAA,CAAQD,MAAM,CAACa,YAAY;EAC7E,IAAID,cAAA,EAAgB;IAClB,MAAMtB,OAAA,GAAU,MAAMC,UAAA;IACtBD,OAAA,CAAQwB,MAAM,CAACF,cAAA,CAAeG,IAAI;EACpC;EAEA,OAAO;IAAET,OAAA,EAAS;IAAgCC,OAAA,EAAS;EAAK;AAClE","ignoreList":[]}
1
+ {"version":3,"file":"logout.js","names":["logout","logoutFn","nextServerAdapter","args","serverAdapter"],"sources":["../../src/auth/logout.ts"],"sourcesContent":["'use server'\n\nimport type { LogoutArgs } from 'payload/auth'\n\nimport { logout as logoutFn } from 'payload/auth'\n\nimport { nextServerAdapter } from '../adapters/server.js'\n\nexport async function logout(\n args: Omit<LogoutArgs, 'serverAdapter'>,\n): Promise<{ message: string; success: boolean }> {\n return logoutFn({ ...args, serverAdapter: nextServerAdapter })\n}\n"],"mappings":"AAAA;;AAIA,SAASA,MAAA,IAAUC,QAAQ,QAAQ;AAEnC,SAASC,iBAAiB,QAAQ;AAElC,OAAO,eAAeF,OACpBG,IAAuC;EAEvC,OAAOF,QAAA,CAAS;IAAE,GAAGE,IAAI;IAAEC,aAAA,EAAeF;EAAkB;AAC9D","ignoreList":[]}
@@ -1,7 +1,5 @@
1
- import type { MaybePromise, SanitizedConfig } from 'payload';
2
- export declare function refresh({ config }: {
3
- config: MaybePromise<SanitizedConfig>;
4
- }): Promise<{
1
+ import type { RefreshArgs } from 'payload/auth';
2
+ export declare function refresh(args: Omit<RefreshArgs, 'serverAdapter'>): Promise<{
5
3
  message: string;
6
4
  success: boolean;
7
5
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/auth/refresh.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAQ5E,wBAAsB,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;CAAE;;;GAuClF"}
1
+ {"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/auth/refresh.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAM/C,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,GACvC,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAEhD"}
@@ -1,56 +1,11 @@
1
1
  'use server';
2
2
 
3
- import { headers as nextHeaders } from 'next/headers.js';
4
- import { createLocalReq, getPayload, refreshOperation } from 'payload';
5
- import { getExistingAuthToken } from '../utilities/getExistingAuthToken.js';
6
- import { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js';
7
- export async function refresh({
8
- config
9
- }) {
10
- const payload = await getPayload({
11
- config,
12
- cron: true
3
+ import { refresh as refreshFn } from 'payload/auth';
4
+ import { nextServerAdapter } from '../adapters/server.js';
5
+ export async function refresh(args) {
6
+ return refreshFn({
7
+ ...args,
8
+ serverAdapter: nextServerAdapter
13
9
  });
14
- const headers = await nextHeaders();
15
- const result = await payload.auth({
16
- headers
17
- });
18
- if (!result.user) {
19
- throw new Error('Cannot refresh token: user not authenticated');
20
- }
21
- const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix);
22
- if (!existingCookie) {
23
- return {
24
- message: 'No valid token found to refresh',
25
- success: false
26
- };
27
- }
28
- const collection = result.user.collection;
29
- const collectionConfig = payload.collections[collection];
30
- if (!collectionConfig?.config.auth) {
31
- throw new Error(`No auth config found for collection: ${collection}`);
32
- }
33
- const req = await createLocalReq({
34
- user: result.user
35
- }, payload);
36
- const refreshResult = await refreshOperation({
37
- collection: collectionConfig,
38
- req
39
- });
40
- if (!refreshResult) {
41
- return {
42
- message: 'Token refresh failed',
43
- success: false
44
- };
45
- }
46
- await setPayloadAuthCookie({
47
- authConfig: collectionConfig.config.auth,
48
- cookiePrefix: payload.config.cookiePrefix,
49
- token: refreshResult.refreshedToken
50
- });
51
- return {
52
- message: 'Token refreshed successfully',
53
- success: true
54
- };
55
10
  }
56
11
  //# sourceMappingURL=refresh.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"refresh.js","names":["headers","nextHeaders","createLocalReq","getPayload","refreshOperation","getExistingAuthToken","setPayloadAuthCookie","refresh","config","payload","cron","result","auth","user","Error","existingCookie","cookiePrefix","message","success","collection","collectionConfig","collections","req","refreshResult","authConfig","token","refreshedToken"],"sources":["../../src/auth/refresh.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug, MaybePromise, SanitizedConfig } from 'payload'\n\nimport { headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, refreshOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\nexport async function refresh({ config }: { config: MaybePromise<SanitizedConfig> }) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const result = await payload.auth({ headers })\n\n if (!result.user) {\n throw new Error('Cannot refresh token: user not authenticated')\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (!existingCookie) {\n return { message: 'No valid token found to refresh', success: false }\n }\n\n const collection: CollectionSlug | undefined = result.user.collection\n const collectionConfig = payload.collections[collection]\n\n if (!collectionConfig?.config.auth) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const req = await createLocalReq({ user: result.user }, payload)\n\n const refreshResult = await refreshOperation({\n collection: collectionConfig,\n req,\n })\n\n if (!refreshResult) {\n return { message: 'Token refresh failed', success: false }\n }\n\n await setPayloadAuthCookie({\n authConfig: collectionConfig.config.auth,\n cookiePrefix: payload.config.cookiePrefix,\n token: refreshResult.refreshedToken,\n })\n\n return { message: 'Token refreshed successfully', success: true }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,WAAW,QAAQ;AACvC,SAASC,cAAc,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ;AAE7D,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,QAAQ;EAAEC;AAAM,CAA6C;EACjF,MAAMC,OAAA,GAAU,MAAMN,UAAA,CAAW;IAAEK,MAAA;IAAQE,IAAA,EAAM;EAAK;EACtD,MAAMV,OAAA,GAAU,MAAMC,WAAA;EACtB,MAAMU,MAAA,GAAS,MAAMF,OAAA,CAAQG,IAAI,CAAC;IAAEZ;EAAQ;EAE5C,IAAI,CAACW,MAAA,CAAOE,IAAI,EAAE;IAChB,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAMC,cAAA,GAAiB,MAAMV,oBAAA,CAAqBI,OAAA,CAAQD,MAAM,CAACQ,YAAY;EAC7E,IAAI,CAACD,cAAA,EAAgB;IACnB,OAAO;MAAEE,OAAA,EAAS;MAAmCC,OAAA,EAAS;IAAM;EACtE;EAEA,MAAMC,UAAA,GAAyCR,MAAA,CAAOE,IAAI,CAACM,UAAU;EACrE,MAAMC,gBAAA,GAAmBX,OAAA,CAAQY,WAAW,CAACF,UAAA,CAAW;EAExD,IAAI,CAACC,gBAAA,EAAkBZ,MAAA,CAAOI,IAAA,EAAM;IAClC,MAAM,IAAIE,KAAA,CAAM,wCAAwCK,UAAA,EAAY;EACtE;EAEA,MAAMG,GAAA,GAAM,MAAMpB,cAAA,CAAe;IAAEW,IAAA,EAAMF,MAAA,CAAOE;EAAK,GAAGJ,OAAA;EAExD,MAAMc,aAAA,GAAgB,MAAMnB,gBAAA,CAAiB;IAC3Ce,UAAA,EAAYC,gBAAA;IACZE;EACF;EAEA,IAAI,CAACC,aAAA,EAAe;IAClB,OAAO;MAAEN,OAAA,EAAS;MAAwBC,OAAA,EAAS;IAAM;EAC3D;EAEA,MAAMZ,oBAAA,CAAqB;IACzBkB,UAAA,EAAYJ,gBAAA,CAAiBZ,MAAM,CAACI,IAAI;IACxCI,YAAA,EAAcP,OAAA,CAAQD,MAAM,CAACQ,YAAY;IACzCS,KAAA,EAAOF,aAAA,CAAcG;EACvB;EAEA,OAAO;IAAET,OAAA,EAAS;IAAgCC,OAAA,EAAS;EAAK;AAClE","ignoreList":[]}
1
+ {"version":3,"file":"refresh.js","names":["refresh","refreshFn","nextServerAdapter","args","serverAdapter"],"sources":["../../src/auth/refresh.ts"],"sourcesContent":["'use server'\n\nimport type { RefreshArgs } from 'payload/auth'\n\nimport { refresh as refreshFn } from 'payload/auth'\n\nimport { nextServerAdapter } from '../adapters/server.js'\n\nexport async function refresh(\n args: Omit<RefreshArgs, 'serverAdapter'>,\n): Promise<{ message: string; success: boolean }> {\n return refreshFn({ ...args, serverAdapter: nextServerAdapter })\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,SAAS,QAAQ;AAErC,SAASC,iBAAiB,QAAQ;AAElC,OAAO,eAAeF,QACpBG,IAAwC;EAExC,OAAOF,SAAA,CAAU;IAAE,GAAGE,IAAI;IAAEC,aAAA,EAAeF;EAAkB;AAC/D","ignoreList":[]}
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // dist/withPayload/withPayload.js
@@ -23,12 +33,54 @@ __export(withPayload_exports, {
23
33
  withPayload: () => withPayload
24
34
  });
25
35
  module.exports = __toCommonJS(withPayload_exports);
36
+ var import_node_url = require("node:url");
37
+
38
+ // ../payload/src/exports/build-config.js
39
+ var devServerExternalPackages = [
40
+ "payload",
41
+ "@payloadcms/db-mongodb",
42
+ "@payloadcms/db-postgres",
43
+ "@payloadcms/db-sqlite",
44
+ "@payloadcms/db-vercel-postgres",
45
+ "@payloadcms/db-d1-sqlite",
46
+ "@payloadcms/drizzle",
47
+ "@payloadcms/email-nodemailer",
48
+ "@payloadcms/email-resend",
49
+ "@payloadcms/graphql",
50
+ "@payloadcms/kv-redis",
51
+ "@payloadcms/payload-cloud",
52
+ // Its `/client` entry has no exports, so the import map never loads anything from it.
53
+ "@payloadcms/plugin-mcp",
54
+ "@payloadcms/plugin-nested-docs",
55
+ "@payloadcms/plugin-redirects",
56
+ "@payloadcms/transformer-sharp",
57
+ "@payloadcms/translations"
58
+ ];
59
+ var serverExternalPackages = [
60
+ // GraphQL requires a single runtime instance across bundled and external packages.
61
+ "graphql",
62
+ "drizzle-kit",
63
+ "drizzle-kit/api",
64
+ "sharp",
65
+ "libsql",
66
+ "require-in-the-middle",
67
+ "json-schema-to-typescript",
68
+ // Bundling pino's thread-stream dependency causes Turbopack build errors.
69
+ "pino"
70
+ ];
71
+
72
+ // dist/withPayload/withPayload.js
73
+ var import_meta = {};
26
74
  var poweredByHeader = {
27
75
  key: "X-Powered-By",
28
76
  value: "Next.js, Payload"
29
77
  };
30
78
  var withPayload = (nextConfig = {}, options = {}) => {
31
- const env = nextConfig.env || {};
79
+ const env = {
80
+ ...nextConfig.env
81
+ };
82
+ const instantLoader = nextConfig.cacheComponents ? typeof import_meta?.resolve === "function" ? (0, import_node_url.fileURLToPath)(new URL("./instantLoader.js", import_meta.url)) : require.resolve("@payloadcms/next/withPayload/instantLoader") : void 0;
83
+ const instantLoaderRule = "**/{layout,page}.{js,jsx,ts,tsx,mjs,mts,cjs,cts}";
32
84
  if (nextConfig.experimental?.staleTimes?.dynamic) {
33
85
  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.");
34
86
  env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = "true";
@@ -51,33 +103,24 @@ var withPayload = (nextConfig = {}, options = {}) => {
51
103
  };
52
104
  const baseConfig = {
53
105
  ...nextConfig,
54
- devIndicators: nextConfig.devIndicators !== void 0 ? nextConfig.devIndicators : {
55
- position: "bottom-right"
56
- },
106
+ devIndicators: nextConfig.devIndicators !== void 0 ? nextConfig.devIndicators : false,
57
107
  env,
58
108
  experimental: {
59
- ...nextConfig.experimental || {},
60
- // Server fast refresh breaks HMR
61
- turbopackServerFastRefresh: false
109
+ ...nextConfig.experimental || {}
62
110
  },
63
111
  sassOptions: {
64
112
  ...nextConfig.sassOptions || {},
65
113
  /**
66
114
  * This prevents scss warning spam during pnpm dev that looks like this:
67
- * ⚠ ./test/admin/components/views/CustomMinimal/index.scss
115
+ * ⚠ ./path/to/some/index.scss
68
116
  * Issue while running loader
69
- * SassWarning: Deprecation Warning on line 8, column 8 of file:///Users/alessio/Documents/GitHub/ payload/packages/ui/src/scss/styles.scss:8:8:
70
- * Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
117
+ * SassWarning: Deprecation Warning: Sass @import rules are deprecated and
118
+ * will be removed in Dart Sass 3.0.0.
71
119
  *
72
120
  * More info and automated migrator: https://sass-lang.com/d/import
73
121
  *
74
- * 8 | @import 'queries';
75
- *
76
- *
77
- * packages/ui/src/scss/styles.scss 9:9 @import
78
- * test/admin/components/views/CustomMinimal/index.scss 1:9 root stylesheet
79
- *
80
- * @todo: update all outdated scss imports to use @use instead of @import. Then, we can remove this.
122
+ * This can be triggered by any `.scss` file in a consumer's project that
123
+ * still uses `@import`.
81
124
  */
82
125
  silenceDeprecations: [...nextConfig.sassOptions?.silenceDeprecations || [], "import"]
83
126
  },
@@ -85,12 +128,25 @@ var withPayload = (nextConfig = {}, options = {}) => {
85
128
  ...nextConfig.outputFileTracingExcludes || {},
86
129
  "**/*": [...nextConfig.outputFileTracingExcludes?.["**/*"] || [], "drizzle-kit", "drizzle-kit/api"]
87
130
  },
88
- outputFileTracingIncludes: {
89
- ...nextConfig.outputFileTracingIncludes || {},
90
- "**/*": [...nextConfig.outputFileTracingIncludes?.["**/*"] || [], "@libsql/client"]
91
- },
92
131
  turbopack: {
93
- ...nextConfig.turbopack || {}
132
+ ...nextConfig.turbopack || {},
133
+ ...instantLoader ? {
134
+ rules: {
135
+ ...nextConfig.turbopack?.rules,
136
+ [instantLoaderRule]: [...[].concat(nextConfig.turbopack?.rules?.[instantLoaderRule] ?? []), {
137
+ // Only send files that import the admin root components to the loader, so
138
+ // Turbopack does not run a JavaScript loader for every other layout and page.
139
+ condition: {
140
+ all: [{
141
+ not: "foreign"
142
+ }, {
143
+ content: /['"]@payloadcms\/next\/(?:layouts|views)['"]/
144
+ }]
145
+ },
146
+ loaders: [instantLoader]
147
+ }]
148
+ }
149
+ } : {}
94
150
  },
95
151
  // We disable the poweredByHeader here because we add it manually in the headers function below
96
152
  ...nextConfig.poweredByHeader !== false ? {
@@ -112,64 +168,32 @@ var withPayload = (nextConfig = {}, options = {}) => {
112
168
  source: "/:path*"
113
169
  }];
114
170
  },
115
- serverExternalPackages: [
171
+ serverExternalPackages: [.../* @__PURE__ */ new Set([
116
172
  ...nextConfig.serverExternalPackages || [],
117
- // WHY: without externalizing graphql, a graphql version error will be thrown
118
- // during runtime ("Ensure that there is only one instance of \"graphql\" in the node_modules\ndirectory.")
119
- "graphql",
120
- "drizzle-kit",
121
- "drizzle-kit/api",
122
- "sharp",
123
- "libsql",
124
- "require-in-the-middle",
125
- "json-schema-to-typescript",
126
- // Prevents turbopack build errors by the thread-stream package which is installed by pino
127
- "pino",
173
+ ...serverExternalPackages,
128
174
  // file-type v22 uses `import(specifier)` with a non-literal specifier, which Turbopack rejects
129
175
  // with "Cannot find module as expression is too dynamic"
130
176
  "file-type",
131
- ...process.env.NODE_ENV === "development" && options.devBundleServerPackages !== true ? (
132
- /**
133
- * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we
134
- * do not bundle server-only packages during dev for two reasons:
135
- *
136
- * 1. Performance: Fewer files to compile means faster compilation speeds.
137
- * 2. Turbopack support: Webpack's externals are not supported by Turbopack.
138
- *
139
- * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to
140
- * externalized packages that are not resolvable from the project root. So including a package like
141
- * "drizzle-kit" in here would do nothing - Next.js will ignore the rule and still bundle the package -
142
- * because it detects that the package is not resolvable from the project root (= not directly installed
143
- * by the user in their own package.json).
144
- *
145
- * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly
146
- * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).
147
- *
148
- *
149
- *
150
- * We should only do this during development, not build, because externalizing these packages can hurt
151
- * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the
152
- * same package.
153
- *
154
- * Example:
155
- * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)
156
- * - payload (not in bundle, external) -> installs qs-esm (external because of importer)
157
- * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.
158
- *
159
- * During development, these bundle size difference do not matter much, and development speed /
160
- * turbopack support are more important.
161
- */
162
- ["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"]
163
- ) : []
164
- ],
177
+ ...process.env.NODE_ENV === "development" && options.devBundleServerPackages !== true ? devServerExternalPackages : []
178
+ ])],
165
179
  webpack: (webpackConfig, webpackOptions) => {
166
180
  const incomingWebpackConfig = typeof nextConfig.webpack === "function" ? nextConfig.webpack(webpackConfig, webpackOptions) : webpackConfig;
167
181
  return {
168
182
  ...incomingWebpackConfig,
183
+ ...instantLoader ? {
184
+ module: {
185
+ ...incomingWebpackConfig.module,
186
+ rules: [...incomingWebpackConfig.module?.rules || [], {
187
+ enforce: "pre",
188
+ exclude: /node_modules/,
189
+ test: /[/\\](layout|page)\.(?:[cm]?[jt]s|[jt]sx)$/,
190
+ use: [instantLoader]
191
+ }]
192
+ }
193
+ } : {},
169
194
  externals: [
170
195
  ...incomingWebpackConfig?.externals || [],
171
196
  /**
172
- * See the explanation in the serverExternalPackages section above.
173
197
  * We need to force Webpack to emit require() calls for these packages, even though they are not
174
198
  * 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.
175
199
  *
@@ -226,6 +250,9 @@ var withPayload = (nextConfig = {}, options = {}) => {
226
250
  process.env.NEXT_BASE_PATH = nextConfig.basePath;
227
251
  baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath;
228
252
  }
253
+ const trailingSlash = nextConfig.trailingSlash === true ? "true" : "false";
254
+ process.env.NEXT_TRAILING_SLASH = trailingSlash;
255
+ baseConfig.env.NEXT_TRAILING_SLASH = trailingSlash;
229
256
  return baseConfig;
230
257
  };
231
258
  var withPayload_default = withPayload;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/withPayload/withPayload.js"],
4
- "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-right' },\n env,\n experimental: {\n ...(nextConfig.experimental || {}),\n // Server fast refresh breaks HMR\n turbopackServerFastRefresh: false,\n },\n sassOptions: {\n ...(nextConfig.sassOptions || {}),\n /**\n * This prevents scss warning spam during pnpm dev that looks like this:\n * ⚠ ./test/admin/components/views/CustomMinimal/index.scss\n * Issue while running loader\n * SassWarning: Deprecation Warning on line 8, column 8 of file:///Users/alessio/Documents/GitHub/ payload/packages/ui/src/scss/styles.scss:8:8:\n * Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.\n *\n * More info and automated migrator: https://sass-lang.com/d/import\n *\n * 8 | @import 'queries';\n *\n *\n * packages/ui/src/scss/styles.scss 9:9 @import\n * test/admin/components/views/CustomMinimal/index.scss 1:9 root stylesheet\n *\n * @todo: update all outdated scss imports to use @use instead of @import. Then, we can remove this.\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 outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n ...(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 return baseConfig\n}\n\nexport default withPayload\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAOA,IAAMA,kBAAkB;EACtBC,KAAK;EACLC,OAAO;AACT;AAOO,IAAMC,cAAcA,CAACC,aAAa,CAAC,GAAGC,UAAU,CAAC,MAAC;AACvD,QAAMC,MAAMF,WAAWE,OAAO,CAAC;AAE/B,MAAIF,WAAWG,cAAcC,YAAYC,SAAS;AAChDC,YAAQC,KACN,gXAAA;AAEFL,QAAIM,0CAA0C;EAChD;A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eAAWf,IAAI6C,iBAAiB/C,WAAW8C;EAC7C;AAEA,SAAO7B;AACT;AAEA,IAAA,sBAAelB;",
6
- "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", "turbopackServerFastRefresh", "sassOptions", "silenceDeprecations", "outputFileTracingExcludes", "outputFileTracingIncludes", "turbopack", "headers", "headersFromConfig", "source", "serverExternalPackages", "process", "NODE_ENV", "devBundleServerPackages", "webpack", "webpackConfig", "webpackOptions", "incomingWebpackConfig", "externals", "plugins", "IgnorePlugin", "resourceRegExp", "resolve", "alias", "fallback", "aws4", "basePath", "NEXT_BASE_PATH"]
3
+ "sources": ["../../src/withPayload/withPayload.js", "../../../payload/src/exports/build-config.js"],
4
+ "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.NEXT_TRAILING_SLASH = trailingSlash\n baseConfig.env.NEXT_TRAILING_SLASH = trailingSlash\n\n return baseConfig\n}\n\nexport default withPayload\n", "/**\n * Server-only Payload packages that can skip development transforms.\n * Packages with client components loaded by the import map must remain bundled.\n * Production bundling preserves tree-shaking and avoids duplicate dependencies.\n */\nexport const devServerExternalPackages = [\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]\n\n/** Third-party packages that both framework adapters externalize in development and production. */\nexport const serverExternalPackages = [\n // GraphQL requires a single runtime instance across bundled and external packages.\n 'graphql',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n // Bundling pino's thread-stream dependency causes Turbopack build errors.\n 'pino',\n]\n"],
5
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AAO,SAAS;AACnEtB,UAAQ3C,IAAIkE,sBAAsBD;AAClCzC,aAAWxB,IAAIkE,sBAAsBD;AAErC,SAAOzC;AACT;AAEA,IAAA,sBAAe3B;",
6
+ "names": ["poweredByHeader", "key", "value", "withPayload", "nextConfig", "options", "env", "instantLoader", "cacheComponents", "import", "resolve", "fileURLToPath", "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", "Set", "serverExternalPayloadPackages", "process", "NODE_ENV", "devBundleServerPackages", "devServerExternalPayloadPackages", "webpack", "webpackConfig", "webpackOptions", "incomingWebpackConfig", "module", "enforce", "exclude", "test", "use", "externals", "plugins", "IgnorePlugin", "resourceRegExp", "alias", "fallback", "aws4", "basePath", "NEXT_BASE_PATH", "trailingSlash", "NEXT_TRAILING_SLASH"]
7
7
  }