@payloadcms/next 4.0.0-internal.f15737c → 4.0.0-internal.f2a04f7

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.
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ /**
3
+ * With `cacheComponents`, Next.js does not unmount pages you navigate away from. It keeps the last
4
+ * few inside a hidden React `<Activity>` boundary so going back can restore them. In the admin
5
+ * panel, that leaves hidden copies of previous views in the DOM (duplicate element IDs, old client
6
+ * state) and breaks selectors that expect a single match.
7
+ *
8
+ * React runs effect cleanups when an `<Activity>` boundary is hidden. This component uses that to
9
+ * render nothing while hidden, so the view is mounted fresh when it becomes visible again, like it
10
+ * is without `cacheComponents`. Only rendered when `cacheComponents` is enabled.
11
+ *
12
+ * @see https://github.com/vercel/next.js/issues/86577
13
+ * @see https://react.dev/reference/react/Activity
14
+ */
15
+ export declare const UnmountWhenHidden: React.FC<{
16
+ readonly children: React.ReactNode;
17
+ }>;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/UnmountWhenHidden/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAExD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAU9E,CAAA"}
@@ -0,0 +1,64 @@
1
+ 'use client';
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { useRouter } from 'next/navigation.js';
6
+ import React, { useLayoutEffect, useState } from 'react';
7
+ /**
8
+ * With `cacheComponents`, Next.js does not unmount pages you navigate away from. It keeps the last
9
+ * few inside a hidden React `<Activity>` boundary so going back can restore them. In the admin
10
+ * panel, that leaves hidden copies of previous views in the DOM (duplicate element IDs, old client
11
+ * state) and breaks selectors that expect a single match.
12
+ *
13
+ * React runs effect cleanups when an `<Activity>` boundary is hidden. This component uses that to
14
+ * render nothing while hidden, so the view is mounted fresh when it becomes visible again, like it
15
+ * is without `cacheComponents`. Only rendered when `cacheComponents` is enabled.
16
+ *
17
+ * @see https://github.com/vercel/next.js/issues/86577
18
+ * @see https://react.dev/reference/react/Activity
19
+ */
20
+ export const UnmountWhenHidden = t0 => {
21
+ const $ = _c(3);
22
+ const {
23
+ children
24
+ } = t0;
25
+ const {
26
+ bfcacheId
27
+ } = useRouter();
28
+ let t1;
29
+ if ($[0] !== bfcacheId || $[1] !== children) {
30
+ t1 = _jsx(RenderNothingWhileHidden, {
31
+ children
32
+ }, bfcacheId);
33
+ $[0] = bfcacheId;
34
+ $[1] = children;
35
+ $[2] = t1;
36
+ } else {
37
+ t1 = $[2];
38
+ }
39
+ return t1;
40
+ };
41
+ const RenderNothingWhileHidden = t0 => {
42
+ const $ = _c(2);
43
+ const {
44
+ children
45
+ } = t0;
46
+ const [isVisible, setIsVisible] = useState(true);
47
+ let t1;
48
+ let t2;
49
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
50
+ t1 = () => {
51
+ setIsVisible(true);
52
+ return () => setIsVisible(false);
53
+ };
54
+ t2 = [];
55
+ $[0] = t1;
56
+ $[1] = t2;
57
+ } else {
58
+ t1 = $[0];
59
+ t2 = $[1];
60
+ }
61
+ useLayoutEffect(t1, t2);
62
+ return isVisible ? children : null;
63
+ };
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["c","_c","useRouter","React","useLayoutEffect","useState","UnmountWhenHidden","t0","$","children","bfcacheId","t1","_jsx","RenderNothingWhileHidden","isVisible","setIsVisible","t2","Symbol","for"],"sources":["../../../src/adapters/UnmountWhenHidden/index.tsx"],"sourcesContent":["'use client'\nimport { useRouter } from 'next/navigation.js'\nimport React, { useLayoutEffect, useState } from 'react'\n\n/**\n * With `cacheComponents`, Next.js does not unmount pages you navigate away from. It keeps the last\n * few inside a hidden React `<Activity>` boundary so going back can restore them. In the admin\n * panel, that leaves hidden copies of previous views in the DOM (duplicate element IDs, old client\n * state) and breaks selectors that expect a single match.\n *\n * React runs effect cleanups when an `<Activity>` boundary is hidden. This component uses that to\n * render nothing while hidden, so the view is mounted fresh when it becomes visible again, like it\n * is without `cacheComponents`. Only rendered when `cacheComponents` is enabled.\n *\n * @see https://github.com/vercel/next.js/issues/86577\n * @see https://react.dev/reference/react/Activity\n */\nexport const UnmountWhenHidden: React.FC<{ readonly children: React.ReactNode }> = ({\n children,\n}) => {\n // Next.js shows the hidden copy again when you navigate to a view you visited recently. That copy\n // is empty, so it would show a blank page until the view rendered again. `bfcacheId` changes on\n // those navigations, so the new key mounts the view as part of the navigation instead.\n // https://nextjs.org/docs/app/api-reference/functions/use-router#bfcacheid\n const { bfcacheId } = useRouter()\n\n return <RenderNothingWhileHidden key={bfcacheId}>{children}</RenderNothingWhileHidden>\n}\n\nconst RenderNothingWhileHidden: React.FC<{ readonly children: React.ReactNode }> = ({\n children,\n}) => {\n const [isVisible, setIsVisible] = useState(true)\n\n useLayoutEffect(() => {\n setIsVisible(true)\n\n return () => setIsVisible(false)\n }, [])\n\n return isVisible ? children : null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,SAAS,QAAQ;AAC1B,OAAOC,KAAA,IAASC,eAAe,EAAEC,QAAQ,QAAQ;AAEjD;;;;;;;;;;;;;AAaA,OAAO,MAAMC,iBAAA,GAAsEC,EAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAAC;IAAAQ;EAAA,IAAAF,EAEnF;EAKC;IAAAG;EAAA,IAAsBR,SAAA;EAAA,IAAAS,EAAA;EAAA,IAAAH,CAAA,QAAAE,SAAA,IAAAF,CAAA,QAAAC,QAAA;IAEfE,EAAA,GAAAC,IAAA,CAAAC,wBAAA;MAAAJ;IAAA,GAA+BC,SAAA;IAAAF,CAAA,MAAAE,SAAA;IAAAF,CAAA,MAAAC,QAAA;IAAAD,CAAA,MAAAG,EAAA;EAAA;IAAAA,EAAA,GAAAH,CAAA;EAAA;EAAA,OAA/BG,EAA+B;AAAA,CACxC;AAEA,MAAME,wBAAA,GAA6EN,EAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAAC;IAAAQ;EAAA,IAAAF,EAEnF;EACC,OAAAO,SAAA,EAAAC,YAAA,IAAkCV,QAAA,KAAS;EAAA,IAAAM,EAAA;EAAA,IAAAK,EAAA;EAAA,IAAAR,CAAA,QAAAS,MAAA,CAAAC,GAAA;IAE3BP,EAAA,GAAAA,CAAA;MACdI,YAAA,KAAa;MAAA,aAEAA,YAAA,MAAa;IAAA;IACzBC,EAAA;IAAER,CAAA,MAAAG,EAAA;IAAAH,CAAA,MAAAQ,EAAA;EAAA;IAAAL,EAAA,GAAAH,CAAA;IAAAQ,EAAA,GAAAR,CAAA;EAAA;EAJLJ,eAAA,CAAgBO,EAIhB,EAAGK,EAAE;EAAA,OAEEF,SAAA,GAAYL,QAAA,OAAW;AAAA,CAChC","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  import type { AdminViewAdapter, AdminViewServerProps, ImportMap, MetaConfig, SanitizedConfig } from 'payload';
2
+ import React from 'react';
2
3
  export declare const adminViews: AdminViewAdapter<AdminViewServerProps, MetaConfig>;
3
4
  type PageProps = {
4
5
  readonly config: Promise<SanitizedConfig>;
@@ -10,7 +11,7 @@ type PageProps = {
10
11
  [key: string]: string | string[];
11
12
  }>;
12
13
  };
13
- export declare const RootPage: (props: PageProps) => Promise<import("react").JSX.Element>;
14
- export declare const NotFoundPage: (props: PageProps) => Promise<import("react").JSX.Element>;
14
+ export declare const RootPage: (props: PageProps) => Promise<React.JSX.Element>;
15
+ export declare const NotFoundPage: (props: PageProps) => Promise<React.JSX.Element>;
15
16
  export {};
16
17
  //# sourceMappingURL=views.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../../src/adapters/views.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,eAAe,EAChB,MAAM,SAAS,CAAA;AAShB,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,oBAAoB,EAAE,UAAU,CAAqB,CAAA;AAE/F,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IACzC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;QACvB,QAAQ,EAAE,MAAM,EAAE,CAAA;KACnB,CAAC,CAAA;IACF,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;QAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KACjC,CAAC,CAAA;CACH,CAAA;AAED,eAAO,MAAM,QAAQ,UAAW,SAAS,yCACmC,CAAA;AAE5E,eAAO,MAAM,YAAY,UAAW,SAAS,yCAAuD,CAAA"}
1
+ {"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../../src/adapters/views.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,eAAe,EAChB,MAAM,SAAS,CAAA;AAMhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,oBAAoB,EAAE,UAAU,CAAqB,CAAA;AAE/F,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IACzC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;QACvB,QAAQ,EAAE,MAAM,EAAE,CAAA;KACnB,CAAC,CAAA;IACF,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;QAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KACjC,CAAC,CAAA;CACH,CAAA;AAKD,eAAO,MAAM,QAAQ,UAAiB,SAAS,+BAI9C,CAAA;AAED,eAAO,MAAM,YAAY,UAAiB,SAAS,+BAIlD,CAAA"}
@@ -1,18 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { renderNotFoundPage } from '@payloadcms/ui/views/NotFound/page';
2
3
  import { renderRoot } from '@payloadcms/ui/views/Root';
3
4
  import { defaultAdminViews } from '@payloadcms/ui/views/Root/adminViews';
4
5
  import { notFound, redirect } from 'next/navigation.js';
6
+ import React from 'react';
5
7
  import { initAdminContext } from '../utilities/initAdminContext.js';
8
+ import { UnmountWhenHidden } from './UnmountWhenHidden/index.js';
6
9
  export const adminViews = defaultAdminViews;
7
- export const RootPage = props => renderRoot({
8
- ...props,
9
- adminViews,
10
- initAdminContext,
11
- notFound,
12
- redirect
13
- });
14
- export const NotFoundPage = props => renderNotFoundPage({
15
- ...props,
16
- initAdminContext
17
- });
10
+ // Set by `withPayload`. Only with `cacheComponents` does Next.js keep hidden pages mounted.
11
+ const isCacheComponentsEnabled = process.env.PAYLOAD_CACHE_COMPONENTS_ENABLED === 'true';
12
+ export const RootPage = async props => {
13
+ const page = await renderRoot({
14
+ ...props,
15
+ adminViews,
16
+ initAdminContext,
17
+ notFound,
18
+ redirect
19
+ });
20
+ return isCacheComponentsEnabled ? /*#__PURE__*/_jsx(UnmountWhenHidden, {
21
+ children: page
22
+ }) : page;
23
+ };
24
+ export const NotFoundPage = async props => {
25
+ const page = await renderNotFoundPage({
26
+ ...props,
27
+ initAdminContext
28
+ });
29
+ return isCacheComponentsEnabled ? /*#__PURE__*/_jsx(UnmountWhenHidden, {
30
+ children: page
31
+ }) : page;
32
+ };
18
33
  //# sourceMappingURL=views.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"views.js","names":["renderNotFoundPage","renderRoot","defaultAdminViews","notFound","redirect","initAdminContext","adminViews","RootPage","props","NotFoundPage"],"sources":["../../src/adapters/views.tsx"],"sourcesContent":["import type {\n AdminViewAdapter,\n AdminViewServerProps,\n ImportMap,\n MetaConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport { renderNotFoundPage } from '@payloadcms/ui/views/NotFound/page'\nimport { renderRoot } from '@payloadcms/ui/views/Root'\nimport { defaultAdminViews } from '@payloadcms/ui/views/Root/adminViews'\nimport { notFound, redirect } from 'next/navigation.js'\n\nimport { initAdminContext } from '../utilities/initAdminContext.js'\n\nexport const adminViews: AdminViewAdapter<AdminViewServerProps, MetaConfig> = defaultAdminViews\n\ntype PageProps = {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}\n\nexport const RootPage = (props: PageProps) =>\n renderRoot({ ...props, adminViews, initAdminContext, notFound, redirect })\n\nexport const NotFoundPage = (props: PageProps) => renderNotFoundPage({ ...props, initAdminContext })\n"],"mappings":"AAQA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,UAAU,QAAQ;AAC3B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AAEnC,SAASC,gBAAgB,QAAQ;AAEjC,OAAO,MAAMC,UAAA,GAAiEJ,iBAAA;AAa9E,OAAO,MAAMK,QAAA,GAAYC,KAAA,IACvBP,UAAA,CAAW;EAAE,GAAGO,KAAK;EAAEF,UAAA;EAAYD,gBAAA;EAAkBF,QAAA;EAAUC;AAAS;AAE1E,OAAO,MAAMK,YAAA,GAAgBD,KAAA,IAAqBR,kBAAA,CAAmB;EAAE,GAAGQ,KAAK;EAAEH;AAAiB","ignoreList":[]}
1
+ {"version":3,"file":"views.js","names":["renderNotFoundPage","renderRoot","defaultAdminViews","notFound","redirect","React","initAdminContext","UnmountWhenHidden","adminViews","isCacheComponentsEnabled","process","env","PAYLOAD_CACHE_COMPONENTS_ENABLED","RootPage","props","page","_jsx","NotFoundPage"],"sources":["../../src/adapters/views.tsx"],"sourcesContent":["import type {\n AdminViewAdapter,\n AdminViewServerProps,\n ImportMap,\n MetaConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport { renderNotFoundPage } from '@payloadcms/ui/views/NotFound/page'\nimport { renderRoot } from '@payloadcms/ui/views/Root'\nimport { defaultAdminViews } from '@payloadcms/ui/views/Root/adminViews'\nimport { notFound, redirect } from 'next/navigation.js'\nimport React from 'react'\n\nimport { initAdminContext } from '../utilities/initAdminContext.js'\nimport { UnmountWhenHidden } from './UnmountWhenHidden/index.js'\n\nexport const adminViews: AdminViewAdapter<AdminViewServerProps, MetaConfig> = defaultAdminViews\n\ntype PageProps = {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}\n\n// Set by `withPayload`. Only with `cacheComponents` does Next.js keep hidden pages mounted.\nconst isCacheComponentsEnabled = process.env.PAYLOAD_CACHE_COMPONENTS_ENABLED === 'true'\n\nexport const RootPage = async (props: PageProps) => {\n const page = await renderRoot({ ...props, adminViews, initAdminContext, notFound, redirect })\n\n return isCacheComponentsEnabled ? <UnmountWhenHidden>{page}</UnmountWhenHidden> : page\n}\n\nexport const NotFoundPage = async (props: PageProps) => {\n const page = await renderNotFoundPage({ ...props, initAdminContext })\n\n return isCacheComponentsEnabled ? <UnmountWhenHidden>{page}</UnmountWhenHidden> : page\n}\n"],"mappings":";AAQA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,UAAU,QAAQ;AAC3B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,OAAOC,KAAA,MAAW;AAElB,SAASC,gBAAgB,QAAQ;AACjC,SAASC,iBAAiB,QAAQ;AAElC,OAAO,MAAMC,UAAA,GAAiEN,iBAAA;AAa9E;AACA,MAAMO,wBAAA,GAA2BC,OAAA,CAAQC,GAAG,CAACC,gCAAgC,KAAK;AAElF,OAAO,MAAMC,QAAA,GAAW,MAAOC,KAAA;EAC7B,MAAMC,IAAA,GAAO,MAAMd,UAAA,CAAW;IAAE,GAAGa,KAAK;IAAEN,UAAA;IAAYF,gBAAA;IAAkBH,QAAA;IAAUC;EAAS;EAE3F,OAAOK,wBAAA,gBAA2BO,IAAA,CAACT,iBAAA;cAAmBQ;OAA4BA,IAAA;AACpF;AAEA,OAAO,MAAME,YAAA,GAAe,MAAOH,KAAA;EACjC,MAAMC,IAAA,GAAO,MAAMf,kBAAA,CAAmB;IAAE,GAAGc,KAAK;IAAER;EAAiB;EAEnE,OAAOG,wBAAA,gBAA2BO,IAAA,CAACT,iBAAA;cAAmBQ;OAA4BA,IAAA;AACpF","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,18 @@ __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
+ var import_meta = {};
26
38
  var poweredByHeader = {
27
39
  key: "X-Powered-By",
28
40
  value: "Next.js, Payload"
29
41
  };
30
42
  var withPayload = (nextConfig = {}, options = {}) => {
31
- const env = nextConfig.env || {};
43
+ const env = {
44
+ ...nextConfig.env
45
+ };
46
+ 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;
47
+ const instantLoaderRule = "**/{layout,page}.{js,jsx,ts,tsx,mjs,mts,cjs,cts}";
32
48
  if (nextConfig.experimental?.staleTimes?.dynamic) {
33
49
  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
50
  env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = "true";
@@ -77,7 +93,24 @@ var withPayload = (nextConfig = {}, options = {}) => {
77
93
  "**/*": [...nextConfig.outputFileTracingExcludes?.["**/*"] || [], "drizzle-kit", "drizzle-kit/api"]
78
94
  },
79
95
  turbopack: {
80
- ...nextConfig.turbopack || {}
96
+ ...nextConfig.turbopack || {},
97
+ ...instantLoader ? {
98
+ rules: {
99
+ ...nextConfig.turbopack?.rules,
100
+ [instantLoaderRule]: [...[].concat(nextConfig.turbopack?.rules?.[instantLoaderRule] ?? []), {
101
+ // Only send files that import the admin root components to the loader, so
102
+ // Turbopack does not run a JavaScript loader for every other layout and page.
103
+ condition: {
104
+ all: [{
105
+ not: "foreign"
106
+ }, {
107
+ content: /['"]@payloadcms\/next\/(?:layouts|views)['"]/
108
+ }]
109
+ },
110
+ loaders: [instantLoader]
111
+ }]
112
+ }
113
+ } : {}
81
114
  },
82
115
  // We disable the poweredByHeader here because we add it manually in the headers function below
83
116
  ...nextConfig.poweredByHeader !== false ? {
@@ -153,6 +186,17 @@ var withPayload = (nextConfig = {}, options = {}) => {
153
186
  const incomingWebpackConfig = typeof nextConfig.webpack === "function" ? nextConfig.webpack(webpackConfig, webpackOptions) : webpackConfig;
154
187
  return {
155
188
  ...incomingWebpackConfig,
189
+ ...instantLoader ? {
190
+ module: {
191
+ ...incomingWebpackConfig.module,
192
+ rules: [...incomingWebpackConfig.module?.rules || [], {
193
+ enforce: "pre",
194
+ exclude: /node_modules/,
195
+ test: /[/\\](layout|page)\.(?:[cm]?[jt]s|[jt]sx)$/,
196
+ use: [instantLoader]
197
+ }]
198
+ }
199
+ } : {},
156
200
  externals: [
157
201
  ...incomingWebpackConfig?.externals || [],
158
202
  /**
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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: 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"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAOA,IAAMA,kBAAkB;EACtBC,KAAK;EACLC,OAAO;AACT;AAOO,IAAMC,cAAcA,CAACC,aAAa,CAAC,GAAGC,UAAU,C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WAAW2C;EAC7C;AAEA,QAAME,gBAAgB7C,WAAW6C,kBAAkB,OAAO,SAAS;AACnEjB,UAAQ1B,IAAI4C,sBAAsBD;AAClC5B,aAAWf,IAAI4C,sBAAsBD;AAErC,SAAO5B;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", "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"]
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'\n\nconst poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n}\n\n/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const env = { ...nextConfig.env }\n // Adds `export const instant = false` to the admin layout and page. See `instantLoader.js` for\n // why this cannot live in the generated admin files.\n const instantLoader = nextConfig.cacheComponents\n ? typeof import.meta?.resolve === 'function'\n ? fileURLToPath(new URL('./instantLoader.js', import.meta.url))\n : require.resolve('@payloadcms/next/withPayload/instantLoader')\n : undefined\n const instantLoaderRule = '**/{layout,page}.{js,jsx,ts,tsx,mjs,mts,cjs,cts}'\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload: detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n if (nextConfig.cacheComponents) {\n env.PAYLOAD_CACHE_COMPONENTS_ENABLED = 'true'\n }\n\n const consoleWarn = console.warn\n\n const sassWarningTexts = [\n // This warning is a lie - without silencing import deprecation warnings, sass will spam the console with deprecation warnings\n 'Future import deprecation is not yet active, so silencing it is unnecessary',\n // Sometimes happens despite silenceDeprecations\n 'The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0',\n ]\n console.warn = (...args) => {\n if (\n (typeof args[1] === 'string' && sassWarningTexts.some((text) => args[1].includes(text))) ||\n (typeof args[0] === 'string' && sassWarningTexts.some((text) => args[0].includes(text)))\n ) {\n return\n }\n\n consoleWarn(...args)\n }\n\n /** @type {import('next').NextConfig} */\n const baseConfig = {\n ...nextConfig,\n devIndicators: nextConfig.devIndicators !== undefined ? nextConfig.devIndicators : false,\n env,\n experimental: {\n ...(nextConfig.experimental || {}),\n },\n sassOptions: {\n ...(nextConfig.sassOptions || {}),\n /**\n * This prevents scss warning spam during pnpm dev that looks like this:\n * ⚠ ./path/to/some/index.scss\n * Issue while running loader\n * SassWarning: Deprecation Warning: Sass @import rules are deprecated and\n * will be removed in Dart Sass 3.0.0.\n *\n * More info and automated migrator: https://sass-lang.com/d/import\n *\n * This can be triggered by any `.scss` file in a consumer's project that\n * still uses `@import`.\n */\n silenceDeprecations: [...(nextConfig.sassOptions?.silenceDeprecations || []), 'import'],\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n ...(instantLoader\n ? {\n rules: {\n ...nextConfig.turbopack?.rules,\n [instantLoaderRule]: [\n ...[].concat(nextConfig.turbopack?.rules?.[instantLoaderRule] ?? []),\n {\n // Only send files that import the admin root components to the loader, so\n // Turbopack does not run a JavaScript loader for every other layout and page.\n condition: {\n all: [\n { not: 'foreign' },\n { content: /['\"]@payloadcms\\/next\\/(?:layouts|views)['\"]/ },\n ],\n },\n loaders: [instantLoader],\n },\n ],\n },\n }\n : {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n // Prevents turbopack build errors by the thread-stream package which is installed by pino\n 'pino',\n // file-type v22 uses `import(specifier)` with a non-literal specifier, which Turbopack rejects\n // with \"Cannot find module as expression is too dynamic\"\n 'file-type',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev 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 ...(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 * 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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAOA,sBAA8B;AAP9B;AASA,IAAMA,kBAAkB;EACtBC,KAAK;EACLC,OAAO;AACT;AAOO,IAAMC,cAAcA,CAACC,aAAa,CAAC,GAAGC,UAAU,CAAC,MAAC;AACvD,QAAMC,MAAM;IAAE,GAAGF,WAAWE;EAAI;AAGhC,QAAMC,gBAAgBH,WAAWI,kBAC7B,OAAOC,aAAaC,YAAY,iBAC9BC,+BAAc,IAAIC,IAAI,sBAAsBH,YAAYI,GAAG,CAAA,IAC3DC,gBAAgB,4CAAA,IAClBC;AACJ,QAAMC,oBAAoB;AAE1B,MAAIZ,WAAWa,cAAcC,YAAYC,SAAS;AAChDC,YAAQC,KACN,gXAAA;AAEFf,QAAIgB,0CAA0C;EAChD;AAEA,MAAIlB,WAAWI,iBAAiB;AAC9BF,QAAIiB,mCAAmC;EACzC;AAEA,QAAMC,cAAcJ,QAAQC;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AS;UACP,GAAI2C,uBAAuB3C,WAAW,CAAC;UACvCqD,OAAO;YACL,GAAIV,uBAAuB3C,SAASqD,SAAS,CAAC;UAChD;UACAC,UAAU;YACR,GAAIX,uBAAuB3C,SAASsD,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;YAoBjDC,MAAM;UACR;QACF;MACF;IACF;EACF;AAEA,MAAI7D,WAAW8D,UAAU;AACvBnB,YAAQzC,IAAI6D,iBAAiB/D,WAAW8D;AACxCpC,eAAWxB,IAAI6D,iBAAiB/D,WAAW8D;EAC7C;AAEA,QAAME,gBAAgBhE,WAAWgE,kBAAkB,OAAO,SAAS;AACnErB,UAAQzC,IAAI+D,sBAAsBD;AAClCtC,aAAWxB,IAAI+D,sBAAsBD;AAErC,SAAOtC;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", "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"]
7
7
  }