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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/adapters/UnmountWhenHidden/index.d.ts +18 -0
  2. package/dist/adapters/UnmountWhenHidden/index.d.ts.map +1 -0
  3. package/dist/adapters/UnmountWhenHidden/index.js +64 -0
  4. package/dist/adapters/UnmountWhenHidden/index.js.map +1 -0
  5. package/dist/adapters/metadata.js.map +1 -1
  6. package/dist/adapters/router.d.ts.map +1 -1
  7. package/dist/adapters/router.js +58 -21
  8. package/dist/adapters/router.js.map +1 -1
  9. package/dist/adapters/views.d.ts +3 -2
  10. package/dist/adapters/views.d.ts.map +1 -1
  11. package/dist/adapters/views.js +26 -11
  12. package/dist/adapters/views.js.map +1 -1
  13. package/dist/auth/login.js.map +1 -1
  14. package/dist/cjs/withPayload.cjs +86 -49
  15. package/dist/cjs/withPayload.cjs.map +4 -4
  16. package/dist/prod/styles.css +1 -1
  17. package/dist/routes/graphql/handler.d.ts.map +1 -1
  18. package/dist/routes/graphql/handler.js +1 -17
  19. package/dist/routes/graphql/handler.js.map +1 -1
  20. package/dist/routes/rest/og/index.d.ts.map +1 -1
  21. package/dist/routes/rest/og/index.js.map +1 -1
  22. package/dist/utilities/initAdminContext.d.ts.map +1 -1
  23. package/dist/utilities/initAdminContext.js +14 -5
  24. package/dist/utilities/initAdminContext.js.map +1 -1
  25. package/dist/withPayload/instantLoader.d.ts +16 -0
  26. package/dist/withPayload/instantLoader.d.ts.map +1 -0
  27. package/dist/withPayload/instantLoader.js +27 -0
  28. package/dist/withPayload/instantLoader.js.map +1 -0
  29. package/dist/withPayload/withPayload.d.ts.map +1 -1
  30. package/dist/withPayload/withPayload.js +41 -42
  31. package/dist/withPayload/withPayload.js.map +1 -1
  32. package/package.json +37 -36
@@ -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,CAACC,wBAAA;MAAAJ;OAA8BC,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,CAAS;EAAA,IAAAM,EAAA;EAAA,IAAAK,EAAA;EAAA,IAAAR,CAAA,QAAAS,MAAA,CAAAC,GAAA;IAE3BP,EAAA,GAAAA,CAAA;MACdI,YAAA,CAAa;MAAA,OAEN,MAAMA,YAAA,CAAa;IAAA,CAC5B;IAAGC,EAAA,KAAE;IAAAR,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,GAAAL,QAAuB,GAAvB,IAAuB;AAAA,CAChC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.js","names":["generatePageMetadata","generateMetadata","getNextRequestI18n","adminViews","config","configPromise","params","paramsPromise","i18n","metadata"],"sources":["../../src/adapters/metadata.ts"],"sourcesContent":["import type { Metadata } from 'next'\nimport type { SanitizedConfig } from 'payload'\n\nimport { generatePageMetadata as generateMetadata } from '@payloadcms/ui/views/Root/generatePageMetadata'\n\nimport { getNextRequestI18n } from '../utilities/getNextRequestI18n.js'\nimport { adminViews } from './views.js'\n\ntype Args = {\n config: Promise<SanitizedConfig>\n params: Promise<{\n [key: string]: string | string[]\n }>\n searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}\n\nexport const generatePageMetadata = async ({\n config: configPromise,\n params: paramsPromise,\n}: Args): Promise<Metadata> => {\n const config = await configPromise\n const params = await paramsPromise\n const i18n = await getNextRequestI18n({ config })\n\n const metadata = await generateMetadata({ adminViews, config, i18n, params })\n\n return metadata as unknown as Metadata\n}\n"],"mappings":"AAGA,SAASA,oBAAA,IAAwBC,gBAAgB,QAAQ;AAEzD,SAASC,kBAAkB,QAAQ;AACnC,SAASC,UAAU,QAAQ;AAY3B,OAAO,MAAMH,oBAAA,GAAuB,MAAAA,CAAO;EACzCI,MAAA,EAAQC,aAAa;EACrBC,MAAA,EAAQC;AAAa,CAChB;EACL,MAAMH,MAAA,GAAS,MAAMC,aAAA;EACrB,MAAMC,MAAA,GAAS,MAAMC,aAAA;EACrB,MAAMC,IAAA,GAAO,MAAMN,kBAAA,CAAmB;IAAEE;EAAO;EAE/C,MAAMK,QAAA,GAAW,MAAMR,gBAAA,CAAiB;IAAEE,UAAA;IAAYC,MAAA;IAAQI,IAAA;IAAMF;EAAO;EAE3E,OAAOG,QAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"metadata.js","names":["generatePageMetadata","generateMetadata","getNextRequestI18n","adminViews","config","configPromise","params","paramsPromise","i18n","metadata"],"sources":["../../src/adapters/metadata.ts"],"sourcesContent":["import type { Metadata } from 'next'\nimport type { SanitizedConfig } from 'payload'\n\nimport { generatePageMetadata as generateMetadata } from '@payloadcms/ui/views/Root/generatePageMetadata'\n\nimport { getNextRequestI18n } from '../utilities/getNextRequestI18n.js'\nimport { adminViews } from './views.js'\n\ntype Args = {\n config: Promise<SanitizedConfig>\n params: Promise<{\n [key: string]: string | string[]\n }>\n searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}\n\nexport const generatePageMetadata = async ({\n config: configPromise,\n params: paramsPromise,\n}: Args): Promise<Metadata> => {\n const config = await configPromise\n const params = await paramsPromise\n const i18n = await getNextRequestI18n({ config })\n\n const metadata = await generateMetadata({ adminViews, config, i18n, params })\n\n return metadata\n}\n"],"mappings":"AAGA,SAASA,oBAAA,IAAwBC,gBAAgB,QAAQ;AAEzD,SAASC,kBAAkB,QAAQ;AACnC,SAASC,UAAU,QAAQ;AAY3B,OAAO,MAAMH,oBAAA,GAAuB,MAAAA,CAAO;EACzCI,MAAA,EAAQC,aAAa;EACrBC,MAAA,EAAQC;AAAa,CAChB;EACL,MAAMH,MAAA,GAAS,MAAMC,aAAA;EACrB,MAAMC,MAAA,GAAS,MAAMC,aAAA;EACrB,MAAMC,IAAA,GAAO,MAAMN,kBAAA,CAAmB;IAAEE;EAAO;EAE/C,MAAMK,QAAA,GAAW,MAAMR,gBAAA,CAAiB;IAAEE,UAAA;IAAYC,MAAA;IAAQI,IAAA;IAAMF;EAAO;EAE3E,OAAOG,QAAA;AACT","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/adapters/router.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,MAAM,OAAO,CAAA;AAiCzB,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CA6BrE,CAAA"}
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/adapters/router.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,MAAM,OAAO,CAAA;AAgCzB,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CA6BrE,CAAA"}
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
 
3
+ import { c as _c } from "react/compiler-runtime";
3
4
  import { jsx as _jsx } from "react/jsx-runtime";
4
5
  import { RouterAdapterContext } from '@payloadcms/ui';
5
6
  import NextLinkImport from 'next/link.js';
@@ -25,30 +26,66 @@ const NextLinkAdapter = ({
25
26
  children: children
26
27
  });
27
28
  };
28
- export const NextRouterAdapter = ({
29
- children
30
- }) => {
29
+ export const NextRouterAdapter = t0 => {
30
+ const $ = _c(13);
31
+ const {
32
+ children
33
+ } = t0;
31
34
  const nextRouter = useNextRouter();
32
35
  const pathname = useNextPathname();
33
36
  const searchParams = useNextSearchParams();
34
37
  const params = useNextParams();
35
- const router = React.useMemo(() => ({
36
- back: nextRouter.back,
37
- push: nextRouter.push,
38
- refresh: nextRouter.refresh,
39
- replace: nextRouter.replace,
40
- replaceState: url => window.history.replaceState(null, '', url)
41
- }), [nextRouter]);
42
- const value = React.useMemo(() => ({
43
- Link: NextLinkAdapter,
44
- params: params,
45
- pathname,
46
- router,
47
- searchParams
48
- }), [params, pathname, router, searchParams]);
49
- return /*#__PURE__*/_jsx(RouterAdapterContext, {
50
- value: value,
51
- children: children
52
- });
38
+ let t1;
39
+ if ($[0] !== nextRouter.back || $[1] !== nextRouter.push || $[2] !== nextRouter.refresh || $[3] !== nextRouter.replace) {
40
+ t1 = {
41
+ back: nextRouter.back,
42
+ push: nextRouter.push,
43
+ refresh: nextRouter.refresh,
44
+ replace: nextRouter.replace,
45
+ replaceState: _temp
46
+ };
47
+ $[0] = nextRouter.back;
48
+ $[1] = nextRouter.push;
49
+ $[2] = nextRouter.refresh;
50
+ $[3] = nextRouter.replace;
51
+ $[4] = t1;
52
+ } else {
53
+ t1 = $[4];
54
+ }
55
+ const router = t1;
56
+ let t2;
57
+ if ($[5] !== params || $[6] !== pathname || $[7] !== router || $[8] !== searchParams) {
58
+ t2 = {
59
+ Link: NextLinkAdapter,
60
+ params,
61
+ pathname,
62
+ router,
63
+ searchParams
64
+ };
65
+ $[5] = params;
66
+ $[6] = pathname;
67
+ $[7] = router;
68
+ $[8] = searchParams;
69
+ $[9] = t2;
70
+ } else {
71
+ t2 = $[9];
72
+ }
73
+ const value = t2;
74
+ let t3;
75
+ if ($[10] !== children || $[11] !== value) {
76
+ t3 = _jsx(RouterAdapterContext, {
77
+ value,
78
+ children
79
+ });
80
+ $[10] = children;
81
+ $[11] = value;
82
+ $[12] = t3;
83
+ } else {
84
+ t3 = $[12];
85
+ }
86
+ return t3;
53
87
  };
88
+ function _temp(url) {
89
+ return window.history.replaceState(null, "", url);
90
+ }
54
91
  //# sourceMappingURL=router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","names":["RouterAdapterContext","NextLinkImport","useParams","useNextParams","usePathname","useNextPathname","useRouter","useNextRouter","useSearchParams","useNextSearchParams","React","NextLink","default","NextLinkAdapter","children","href","prefetch","ref","replace","scroll","rest","_jsx","NextRouterAdapter","nextRouter","pathname","searchParams","params","router","useMemo","back","push","refresh","replaceState","url","window","history","value","Link"],"sources":["../../src/adapters/router.tsx"],"sourcesContent":["'use client'\nimport type { RouterAdapterContextValue } from '@payloadcms/ui'\nimport type { LinkAdapterProps } from 'payload'\n\nimport { RouterAdapterContext } from '@payloadcms/ui'\nimport NextLinkImport from 'next/link.js'\nimport {\n useParams as useNextParams,\n usePathname as useNextPathname,\n useRouter as useNextRouter,\n useSearchParams as useNextSearchParams,\n} from 'next/navigation.js'\nimport React from 'react'\n\ntype LinkComponent = React.FC<\n {\n children?: React.ReactNode\n href: string\n prefetch?: boolean\n ref?: React.Ref<HTMLAnchorElement>\n replace?: boolean\n scroll?: boolean\n } & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>\n>\n\nconst NextLink: LinkComponent = ('default' in NextLinkImport\n ? NextLinkImport.default\n : NextLinkImport) as unknown as LinkComponent\n\nconst NextLinkAdapter: React.FC<LinkAdapterProps> = ({\n children,\n href,\n prefetch,\n ref,\n replace,\n scroll,\n ...rest\n}) => {\n return (\n <NextLink href={href} prefetch={prefetch} ref={ref} replace={replace} scroll={scroll} {...rest}>\n {children}\n </NextLink>\n )\n}\n\nexport const NextRouterAdapter: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const nextRouter = useNextRouter()\n const pathname = useNextPathname()\n const searchParams = useNextSearchParams()\n const params = useNextParams()\n\n const router = React.useMemo<RouterAdapterContextValue['router']>(\n () => ({\n back: nextRouter.back,\n push: nextRouter.push,\n refresh: nextRouter.refresh,\n replace: nextRouter.replace,\n replaceState: (url) => window.history.replaceState(null, '', url),\n }),\n [nextRouter],\n )\n\n const value = React.useMemo<RouterAdapterContextValue>(\n () => ({\n Link: NextLinkAdapter,\n params: params as Record<string, string | string[]>,\n pathname,\n router,\n searchParams,\n }),\n [params, pathname, router, searchParams],\n )\n\n return <RouterAdapterContext value={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CAAMkB,OAAO,CACzB,OAAO;IACLS,IAAA,EAAMxB,eAAA;IACNa,MAAA,EAAQA,MAAA;IACRF,QAAA;IACAG,MAAA;IACAF;EACF,IACA,CAACC,MAAA,EAAQF,QAAA,EAAUG,MAAA,EAAQF,YAAA,CAAa;EAG1C,oBAAOJ,IAAA,CAACrB,oBAAA;IAAqBoC,KAAA,EAAOA,KAAA;cAAQtB;;AAC9C","ignoreList":[]}
1
+ {"version":3,"file":"router.js","names":["c","_c","RouterAdapterContext","NextLinkImport","useParams","useNextParams","usePathname","useNextPathname","useRouter","useNextRouter","useSearchParams","useNextSearchParams","React","NextLink","default","NextLinkAdapter","children","href","prefetch","ref","replace","scroll","rest","_jsx","NextRouterAdapter","t0","$","nextRouter","pathname","searchParams","params","t1","back","push","refresh","replaceState","_temp","router","t2","Link","value","t3","url","window","history"],"sources":["../../src/adapters/router.tsx"],"sourcesContent":["'use client'\nimport type { RouterAdapterContextValue } from '@payloadcms/ui'\nimport type { LinkAdapterProps } from 'payload'\n\nimport { RouterAdapterContext } from '@payloadcms/ui'\nimport NextLinkImport from 'next/link.js'\nimport {\n useParams as useNextParams,\n usePathname as useNextPathname,\n useRouter as useNextRouter,\n useSearchParams as useNextSearchParams,\n} from 'next/navigation.js'\nimport React from 'react'\n\ntype LinkComponent = React.FC<\n {\n children?: React.ReactNode\n href: string\n prefetch?: boolean\n ref?: React.Ref<HTMLAnchorElement>\n replace?: boolean\n scroll?: boolean\n } & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>\n>\n\nconst NextLink: LinkComponent =\n 'default' in NextLinkImport ? NextLinkImport.default : NextLinkImport\n\nconst NextLinkAdapter: React.FC<LinkAdapterProps> = ({\n children,\n href,\n prefetch,\n ref,\n replace,\n scroll,\n ...rest\n}) => {\n return (\n <NextLink href={href} prefetch={prefetch} ref={ref} replace={replace} scroll={scroll} {...rest}>\n {children}\n </NextLink>\n )\n}\n\nexport const NextRouterAdapter: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const nextRouter = useNextRouter()\n const pathname = useNextPathname()\n const searchParams = useNextSearchParams()\n const params = useNextParams()\n\n const router = React.useMemo<RouterAdapterContextValue['router']>(\n () => ({\n back: nextRouter.back,\n push: nextRouter.push,\n refresh: nextRouter.refresh,\n replace: nextRouter.replace,\n replaceState: (url) => window.history.replaceState(null, '', url),\n }),\n [nextRouter],\n )\n\n const value = React.useMemo<RouterAdapterContextValue>(\n () => ({\n Link: NextLinkAdapter,\n params,\n pathname,\n router,\n searchParams,\n }),\n [params, pathname, router, searchParams],\n )\n\n return <RouterAdapterContext value={value}>{children}</RouterAdapterContext>\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,oBAAoB,QAAQ;AACrC,OAAOC,cAAA,MAAoB;AAC3B,SACEC,SAAA,IAAaC,aAAa,EAC1BC,WAAA,IAAeC,eAAe,EAC9BC,SAAA,IAAaC,aAAa,EAC1BC,eAAA,IAAmBC,mBAAmB,QACjC;AACP,OAAOC,KAAA,MAAW;AAalB,MAAMC,QAAA,GACJ,aAAaV,cAAA,GAAiBA,cAAA,CAAeW,OAAO,GAAGX,cAAA;AAEzD,MAAMY,eAAA,GAA8CA,CAAC;EACnDC,QAAQ;EACRC,IAAI;EACJC,QAAQ;EACRC,GAAG;EACHC,OAAO;EACPC,MAAM;EACN,GAAGC;AAAA,CACJ;EACC,oBACEC,IAAA,CAACV,QAAA;IAASI,IAAA,EAAMA,IAAA;IAAMC,QAAA,EAAUA,QAAA;IAAUC,GAAA,EAAKA,GAAA;IAAKC,OAAA,EAASA,OAAA;IAASC,MAAA,EAAQA,MAAA;IAAS,GAAGC,IAAI;cAC3FN;;AAGP;AAEA,OAAO,MAAMQ,iBAAA,GAA6DC,EAAA;EAAA,MAAAC,CAAA,GAAAzB,EAAA;EAAC;IAAAe;EAAA,IAAAS,EAAY;EACrF,MAAAE,UAAA,GAAmBlB,aAAA;EACnB,MAAAmB,QAAA,GAAiBrB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AA,GAAAlB,IAAA,CAACrB,oBAAA;MAAAsC,KAAA;MAAAxB;;;;;;;;SAADyB,E;CACT;AA7B0E,SAAAL,MAAAM,GAAA;EAAA,OAY7CC,MAAA,CAAAC,OAAc,CAAAT,YAAa,CAAC,MAAM,IAAIO,GAAA;AAAA","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 +1 @@
1
- {"version":3,"file":"login.js","names":["login","loginFn","nextServerAdapter","args","serverAdapter"],"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type { AuthCollectionSlug, LoginResult } from 'payload'\n\nimport { type LoginArgs, type LoginArgsWithoutServerAdapter, login as loginFn } from 'payload/auth'\n\nimport { nextServerAdapter } from '../adapters/server.js'\n\nexport async function login<TSlug extends AuthCollectionSlug>(\n args: LoginArgsWithoutServerAdapter<TSlug>,\n): Promise<LoginResult<TSlug>> {\n return loginFn({ ...args, serverAdapter: nextServerAdapter } as LoginArgs<TSlug>)\n}\n"],"mappings":"AAAA;;AAIA,SAA6DA,KAAA,IAASC,OAAO,QAAQ;AAErF,SAASC,iBAAiB,QAAQ;AAElC,OAAO,eAAeF,MACpBG,IAA0C;EAE1C,OAAOF,OAAA,CAAQ;IAAE,GAAGE,IAAI;IAAEC,aAAA,EAAeF;EAAkB;AAC7D","ignoreList":[]}
1
+ {"version":3,"file":"login.js","names":["login","loginFn","nextServerAdapter","args","serverAdapter"],"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type { AuthCollectionSlug, LoginResult } from 'payload'\n\nimport { type LoginArgs, type LoginArgsWithoutServerAdapter, login as loginFn } from 'payload/auth'\n\nimport { nextServerAdapter } from '../adapters/server.js'\n\nexport async function login<TSlug extends AuthCollectionSlug>(\n args: LoginArgsWithoutServerAdapter<TSlug>,\n): Promise<LoginResult<TSlug>> {\n return loginFn({ ...args, serverAdapter: nextServerAdapter })\n}\n"],"mappings":"AAAA;;AAIA,SAA6DA,KAAA,IAASC,OAAO,QAAQ;AAErF,SAASC,iBAAiB,QAAQ;AAElC,OAAO,eAAeF,MACpBG,IAA0C;EAE1C,OAAOF,OAAA,CAAQ;IAAE,GAAGE,IAAI;IAAEC,aAAA,EAAeF;EAAkB;AAC7D","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";
@@ -77,7 +129,24 @@ var withPayload = (nextConfig = {}, options = {}) => {
77
129
  "**/*": [...nextConfig.outputFileTracingExcludes?.["**/*"] || [], "drizzle-kit", "drizzle-kit/api"]
78
130
  },
79
131
  turbopack: {
80
- ...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
+ } : {}
81
150
  },
82
151
  // We disable the poweredByHeader here because we add it manually in the headers function below
83
152
  ...nextConfig.poweredByHeader !== false ? {
@@ -99,64 +168,32 @@ var withPayload = (nextConfig = {}, options = {}) => {
99
168
  source: "/:path*"
100
169
  }];
101
170
  },
102
- serverExternalPackages: [
171
+ serverExternalPackages: [.../* @__PURE__ */ new Set([
103
172
  ...nextConfig.serverExternalPackages || [],
104
- // WHY: without externalizing graphql, a graphql version error will be thrown
105
- // during runtime ("Ensure that there is only one instance of \"graphql\" in the node_modules\ndirectory.")
106
- "graphql",
107
- "drizzle-kit",
108
- "drizzle-kit/api",
109
- "sharp",
110
- "libsql",
111
- "require-in-the-middle",
112
- "json-schema-to-typescript",
113
- // Prevents turbopack build errors by the thread-stream package which is installed by pino
114
- "pino",
173
+ ...serverExternalPackages,
115
174
  // file-type v22 uses `import(specifier)` with a non-literal specifier, which Turbopack rejects
116
175
  // with "Cannot find module as expression is too dynamic"
117
176
  "file-type",
118
- ...process.env.NODE_ENV === "development" && options.devBundleServerPackages !== true ? (
119
- /**
120
- * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we
121
- * do not bundle server-only packages during dev for two reasons:
122
- *
123
- * 1. Performance: Fewer files to compile means faster compilation speeds.
124
- * 2. Turbopack support: Webpack's externals are not supported by Turbopack.
125
- *
126
- * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to
127
- * externalized packages that are not resolvable from the project root. So including a package like
128
- * "drizzle-kit" in here would do nothing - Next.js will ignore the rule and still bundle the package -
129
- * because it detects that the package is not resolvable from the project root (= not directly installed
130
- * by the user in their own package.json).
131
- *
132
- * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly
133
- * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).
134
- *
135
- *
136
- *
137
- * We should only do this during development, not build, because externalizing these packages can hurt
138
- * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the
139
- * same package.
140
- *
141
- * Example:
142
- * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)
143
- * - payload (not in bundle, external) -> installs qs-esm (external because of importer)
144
- * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.
145
- *
146
- * During development, these bundle size difference do not matter much, and development speed /
147
- * turbopack support are more important.
148
- */
149
- ["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"]
150
- ) : []
151
- ],
177
+ ...process.env.NODE_ENV === "development" && options.devBundleServerPackages !== true ? devServerExternalPackages : []
178
+ ])],
152
179
  webpack: (webpackConfig, webpackOptions) => {
153
180
  const incomingWebpackConfig = typeof nextConfig.webpack === "function" ? nextConfig.webpack(webpackConfig, webpackOptions) : webpackConfig;
154
181
  return {
155
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
+ } : {},
156
194
  externals: [
157
195
  ...incomingWebpackConfig?.externals || [],
158
196
  /**
159
- * See the explanation in the serverExternalPackages section above.
160
197
  * We need to force Webpack to emit require() calls for these packages, even though they are not
161
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.
162
199
  *
@@ -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: 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,CAAC,MAAC;AACvD,QAAMC,MAAMF,WAAWE,OAAO,CAAC;AAE/B,MAAIF,WAAWG,cAAcC,YAAYC,SAAS;AAChDC,YAAQC,KACN,gXAAA;AAEFL,QAAIM,0CAA0C;EAChD;AAEA,MAAIR,WAAWS,iBAAiB;AAC9BP,QAAIQ,mCAAmC;EACzC;AAEA,QAAMC,cAAcL,QAAQC;AAE5B,QAAMK,mBAAmB;;IAEvB;;IAEA;EAAA;AAEFN,UAAQC,OAAO,IAAIM,SAAA;AACjB,QACE,OAAQA,KAAK,CAAA,MAAO,YAAYD,iBAAiBE,KAAMC,UAASF,KAAK,CAAA,EAAGG,SAASD,IAAA,CAAA,KAChF,OAAOF,KAAK,CAAA,MAAO,YAAYD,iBAAiBE,KAAMC,UAASF,KAAK,CAAA,EAAGG,SAASD,IAAA,CAAA,GACjF;AACA;IACF;AAEAJ,gBAAA,GAAeE,IAAA;EAC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AACC,eAAeC,mBAAA;AACvB,YAAMC,wBACJ,OAAOlC,WAAW+B,YAAY,aAC1B/B,WAAW+B,QAAQC,eAAeC,cAAA,IAClCD;AAEN,aAAO;QACL,GAAGE;QACHC,WAAW;UAAA,GACLD,uBAAuBC,aAAa,CAAA;;;;;;;;;UASxC;UACA;UACA;UACA;UACA;UACA;QAAA;QAEFC,SAAS;UAAA,GACHF,uBAAuBE,WAAW,CAAA;;UAEtC,IAAIH,eAAeF,QAAQM,aAAa;YACtCC,gBAAgB;UAClB,CAAA;QAAA;QAEFC,SAAS;UACP,GAAIL,uBAAuBK,WAAW,CAAC;UACvCC,OAAO;YACL,GAAIN,uBAAuBK,SAASC,SAAS,CAAC;UAChD;UACAC,UAAU;YACR,GAAIP,uBAAuBK,SAASE,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;YAoBjDC,MAAM;UACR;QACF;MACF;IACF;EACF;AAEA,MAAI1C,WAAW2C,UAAU;AACvBf,YAAQ1B,IAAI0C,iBAAiB5C,WAAW2C;AACxC1B,eAAWf,IAAI0C,iBAAiB5C,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"]
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
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAOA,sBAA8B;;;ACFvB,IAAM,4BAA4B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,yBAAyB;AAAA;AAAA,EAEpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AACF;;;ADtCA;AAaA,IAAMA,kBAAkB;EACtBC,KAAK;EACLC,OAA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AAO,CAAA,GACDoB,sBAAsBC,QAAQrB,SAAS,CAAA,GAC3C;cACEsB,SAAS;cACTC,SAAS;cACTC,MAAM;cACNC,KAAK,CAACtD,aAAA;YACR,CAAA;UAEJ;QACF,IACA,CAAC;QACLuD,WAAW;UAAA,GACLN,uBAAuBM,aAAa,CAAA;;;;;;;;UAQxC;UACA;UACA;UACA;UACA;UACA;QAAA;QAEFC,SAAS;UAAA,GACHP,uBAAuBO,WAAW,CAAA;;UAEtC,IAAIR,eAAeF,QAAQW,aAAa;YACtCC,gBAAgB;UAClB,CAAA;QAAA;QAEFvD,SAAS;UACP,GAAI8C,uBAAuB9C,WAAW,CAAC;UACvCwD,OAAO;YACL,GAAIV,uBAAuB9C,SAASwD,SAAS,CAAC;UAChD;UACAC,UAAU;YACR,GAAIX,uBAAuB9C,SAASyD,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;YAoBjDC,MAAM;UACR;QACF;MACF;IACF;EACF;AAEA,MAAIhE,WAAWiE,UAAU;AACvBpB,YAAQ3C,IAAIgE,iBAAiBlE,WAAWiE;AACxCvC,eAAWxB,IAAIgE,iBAAiBlE,WAAWiE;EAC7C;AAEA,QAAME,gBAAgBnE,WAAWmE,kBAAkB,OAAO,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
  }