@payloadcms/tanstack-start 4.0.0-internal.d21c039 → 4.0.0-internal.d3909a9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/dist/adapters/handleServerFunctions.d.ts +3 -0
  2. package/dist/adapters/handleServerFunctions.d.ts.map +1 -0
  3. package/dist/adapters/handleServerFunctions.js +17 -0
  4. package/dist/adapters/handleServerFunctions.js.map +1 -0
  5. package/dist/adapters/layout/RootProviders/index.d.ts +9 -0
  6. package/dist/adapters/layout/RootProviders/index.d.ts.map +1 -0
  7. package/dist/adapters/layout/RootProviders/index.js +21 -0
  8. package/dist/adapters/layout/RootProviders/index.js.map +1 -0
  9. package/dist/{layouts/Root/withPayloadRoot.d.ts → adapters/layout/index.d.ts} +32 -4
  10. package/dist/adapters/layout/index.d.ts.map +1 -0
  11. package/dist/adapters/layout/index.js +107 -0
  12. package/dist/adapters/layout/index.js.map +1 -0
  13. package/dist/adapters/layout/lazy.d.ts +7 -0
  14. package/dist/adapters/layout/lazy.d.ts.map +1 -0
  15. package/dist/adapters/layout/lazy.js +17 -0
  16. package/dist/adapters/layout/lazy.js.map +1 -0
  17. package/dist/adapters/layout/outlet.d.ts +4 -0
  18. package/dist/adapters/layout/outlet.d.ts.map +1 -0
  19. package/dist/adapters/layout/outlet.js +9 -0
  20. package/dist/adapters/layout/outlet.js.map +1 -0
  21. package/dist/adapters/layout/server.d.ts +23 -0
  22. package/dist/adapters/layout/server.d.ts.map +1 -0
  23. package/dist/adapters/layout/server.js +65 -0
  24. package/dist/adapters/layout/server.js.map +1 -0
  25. package/dist/{utilities/meta.d.ts → adapters/metadata.d.ts} +10 -1
  26. package/dist/adapters/metadata.d.ts.map +1 -0
  27. package/dist/{utilities/meta.js → adapters/metadata.js} +60 -1
  28. package/dist/adapters/metadata.js.map +1 -0
  29. package/dist/{elements/RouterAdapter/index.d.ts → adapters/router.d.ts} +1 -1
  30. package/dist/adapters/router.d.ts.map +1 -0
  31. package/dist/{elements/RouterAdapter/index.js → adapters/router.js} +11 -4
  32. package/dist/adapters/router.js.map +1 -0
  33. package/dist/{utilities/serverAdapter.server.d.ts → adapters/server.d.ts} +1 -1
  34. package/dist/adapters/server.d.ts.map +1 -0
  35. package/dist/{utilities/serverAdapter.server.js → adapters/server.js} +3 -30
  36. package/dist/adapters/server.js.map +1 -0
  37. package/dist/{routes/adminRoutes.d.ts → adapters/views/index.d.ts} +10 -11
  38. package/dist/adapters/views/index.d.ts.map +1 -0
  39. package/dist/{routes/adminRoutes.js → adapters/views/index.js} +17 -47
  40. package/dist/adapters/views/index.js.map +1 -0
  41. package/dist/adapters/views/lazy.d.ts +4 -0
  42. package/dist/adapters/views/lazy.d.ts.map +1 -0
  43. package/dist/adapters/views/lazy.js +43 -0
  44. package/dist/adapters/views/lazy.js.map +1 -0
  45. package/dist/{utilities/loadAdminPage.d.ts → adapters/views/server.d.ts} +9 -6
  46. package/dist/adapters/views/server.d.ts.map +1 -0
  47. package/dist/{utilities/loadAdminPage.js → adapters/views/server.js} +25 -78
  48. package/dist/adapters/views/server.js.map +1 -0
  49. package/dist/auth/login.js +1 -1
  50. package/dist/auth/login.js.map +1 -1
  51. package/dist/auth/logout.js +1 -1
  52. package/dist/auth/logout.js.map +1 -1
  53. package/dist/auth/refresh.js +1 -1
  54. package/dist/auth/refresh.js.map +1 -1
  55. package/dist/exports/client/layout.d.ts +2 -0
  56. package/dist/exports/client/layout.d.ts.map +1 -0
  57. package/dist/exports/client/layout.js +4 -0
  58. package/dist/exports/client/layout.js.map +1 -0
  59. package/dist/exports/client.d.ts +3 -5
  60. package/dist/exports/client.d.ts.map +1 -1
  61. package/dist/exports/client.js +3 -5
  62. package/dist/exports/client.js.map +1 -1
  63. package/dist/exports/layouts.d.ts +2 -3
  64. package/dist/exports/layouts.d.ts.map +1 -1
  65. package/dist/exports/layouts.js +1 -2
  66. package/dist/exports/layouts.js.map +1 -1
  67. package/dist/exports/rest.d.ts +2 -0
  68. package/dist/exports/rest.d.ts.map +1 -0
  69. package/dist/exports/rest.js +3 -0
  70. package/dist/exports/rest.js.map +1 -0
  71. package/dist/exports/server.d.ts +7 -11
  72. package/dist/exports/server.d.ts.map +1 -1
  73. package/dist/exports/server.js +7 -11
  74. package/dist/exports/server.js.map +1 -1
  75. package/dist/{utilities/graphqlHandler.server.d.ts → routes/graphql/handler.server.d.ts} +1 -3
  76. package/dist/routes/graphql/handler.server.d.ts.map +1 -0
  77. package/dist/{utilities/graphqlHandler.server.js → routes/graphql/handler.server.js} +9 -6
  78. package/dist/routes/graphql/handler.server.js.map +1 -0
  79. package/dist/routes/rest/handler.server.d.ts +11 -0
  80. package/dist/routes/rest/handler.server.d.ts.map +1 -0
  81. package/dist/routes/rest/handler.server.js +14 -0
  82. package/dist/routes/rest/handler.server.js.map +1 -0
  83. package/dist/routes/{apiRoute.d.ts → rest/index.d.ts} +5 -4
  84. package/dist/routes/rest/index.d.ts.map +1 -0
  85. package/dist/routes/{apiRoute.js → rest/index.js} +6 -5
  86. package/dist/routes/rest/index.js.map +1 -0
  87. package/dist/rsc/CollectionCards.js +1 -1
  88. package/dist/rsc/CollectionCards.js.map +1 -1
  89. package/dist/utilities/devConfigReload.server.js +29 -6
  90. package/dist/utilities/devConfigReload.server.js.map +1 -1
  91. package/dist/utilities/getRequestI18n.server.d.ts +1 -1
  92. package/dist/utilities/getRequestI18n.server.js +1 -1
  93. package/dist/utilities/getRequestI18n.server.js.map +1 -1
  94. package/dist/utilities/initAdminContext.server.d.ts +9 -0
  95. package/dist/utilities/initAdminContext.server.d.ts.map +1 -0
  96. package/dist/utilities/initAdminContext.server.js +13 -0
  97. package/dist/utilities/initAdminContext.server.js.map +1 -0
  98. package/dist/utilities/serverFunctionClient.d.ts +2 -23
  99. package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
  100. package/dist/utilities/serverFunctionClient.js +12 -106
  101. package/dist/utilities/serverFunctionClient.js.map +1 -1
  102. package/dist/withPayload/config/external.d.ts +6 -12
  103. package/dist/withPayload/config/external.d.ts.map +1 -1
  104. package/dist/withPayload/config/external.js +14 -15
  105. package/dist/withPayload/config/external.js.map +1 -1
  106. package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -1
  107. package/dist/withPayload/config/optimizeDeps.js +34 -1
  108. package/dist/withPayload/config/optimizeDeps.js.map +1 -1
  109. package/dist/withPayload/importProtection.js +1 -1
  110. package/dist/withPayload/importProtection.js.map +1 -1
  111. package/dist/withPayload/index.d.ts +11 -11
  112. package/dist/withPayload/index.d.ts.map +1 -1
  113. package/dist/withPayload/index.js +22 -16
  114. package/dist/withPayload/index.js.map +1 -1
  115. package/dist/withPayload/workarounds/stripDistStyleImports.js +1 -1
  116. package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -1
  117. package/package.json +30 -25
  118. package/dist/elements/RouterAdapter/index.d.ts.map +0 -1
  119. package/dist/elements/RouterAdapter/index.js.map +0 -1
  120. package/dist/layouts/Root/getLayoutData.d.ts +0 -34
  121. package/dist/layouts/Root/getLayoutData.d.ts.map +0 -1
  122. package/dist/layouts/Root/getLayoutData.js +0 -97
  123. package/dist/layouts/Root/getLayoutData.js.map +0 -1
  124. package/dist/layouts/Root/withPayloadRoot.d.ts.map +0 -1
  125. package/dist/layouts/Root/withPayloadRoot.js +0 -91
  126. package/dist/layouts/Root/withPayloadRoot.js.map +0 -1
  127. package/dist/node/cssLoader.d.mts +0 -25
  128. package/dist/node/cssLoader.d.mts.map +0 -1
  129. package/dist/node/cssLoader.js +0 -70
  130. package/dist/node/cssLoader.js.map +0 -1
  131. package/dist/node/cssLoader.mjs +0 -75
  132. package/dist/node/registerCssLoader.d.mts +0 -2
  133. package/dist/node/registerCssLoader.d.mts.map +0 -1
  134. package/dist/node/registerCssLoader.js +0 -10
  135. package/dist/node/registerCssLoader.js.map +0 -1
  136. package/dist/node/registerCssLoader.mjs +0 -10
  137. package/dist/routes/adminRoutes.d.ts.map +0 -1
  138. package/dist/routes/adminRoutes.js.map +0 -1
  139. package/dist/routes/apiRoute.d.ts.map +0 -1
  140. package/dist/routes/apiRoute.js.map +0 -1
  141. package/dist/routes/layoutRoute.d.ts +0 -27
  142. package/dist/routes/layoutRoute.d.ts.map +0 -1
  143. package/dist/routes/layoutRoute.js +0 -59
  144. package/dist/routes/layoutRoute.js.map +0 -1
  145. package/dist/utilities/getRequestLocale.d.ts +0 -7
  146. package/dist/utilities/getRequestLocale.d.ts.map +0 -1
  147. package/dist/utilities/getRequestLocale.js +0 -19
  148. package/dist/utilities/getRequestLocale.js.map +0 -1
  149. package/dist/utilities/graphqlHandler.server.d.ts.map +0 -1
  150. package/dist/utilities/graphqlHandler.server.js.map +0 -1
  151. package/dist/utilities/handleAPIRoute.server.d.ts +0 -11
  152. package/dist/utilities/handleAPIRoute.server.d.ts.map +0 -1
  153. package/dist/utilities/handleAPIRoute.server.js +0 -17
  154. package/dist/utilities/handleAPIRoute.server.js.map +0 -1
  155. package/dist/utilities/handleServerFunctions.d.ts +0 -2
  156. package/dist/utilities/handleServerFunctions.d.ts.map +0 -1
  157. package/dist/utilities/handleServerFunctions.js +0 -12
  158. package/dist/utilities/handleServerFunctions.js.map +0 -1
  159. package/dist/utilities/initReq.server.d.ts +0 -20
  160. package/dist/utilities/initReq.server.d.ts.map +0 -1
  161. package/dist/utilities/initReq.server.js +0 -123
  162. package/dist/utilities/initReq.server.js.map +0 -1
  163. package/dist/utilities/loadAdminPage.d.ts.map +0 -1
  164. package/dist/utilities/loadAdminPage.js.map +0 -1
  165. package/dist/utilities/loadLayoutData.d.ts +0 -17
  166. package/dist/utilities/loadLayoutData.d.ts.map +0 -1
  167. package/dist/utilities/loadLayoutData.js +0 -22
  168. package/dist/utilities/loadLayoutData.js.map +0 -1
  169. package/dist/utilities/meta.d.ts.map +0 -1
  170. package/dist/utilities/meta.js.map +0 -1
  171. package/dist/utilities/serializeForRsc.d.ts +0 -26
  172. package/dist/utilities/serializeForRsc.d.ts.map +0 -1
  173. package/dist/utilities/serializeForRsc.js +0 -127
  174. package/dist/utilities/serializeForRsc.js.map +0 -1
  175. package/dist/utilities/serverAdapter.server.d.ts.map +0 -1
  176. package/dist/utilities/serverAdapter.server.js.map +0 -1
  177. package/dist/utilities/toSerializable.d.ts +0 -11
  178. package/dist/utilities/toSerializable.d.ts.map +0 -1
  179. package/dist/utilities/toSerializable.js +0 -127
  180. package/dist/utilities/toSerializable.js.map +0 -1
@@ -1,29 +1,8 @@
1
1
  import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload';
2
- /**
3
- * Builds the client-side `ServerFunctionClient` wired into
4
- * `RootProvider.serverFunction`, given the app's `createServerFn`-based
5
- * dispatcher (`runServerFn`).
6
- *
7
- * Strips functions / symbols / RegExps / React elements from the args before
8
- * dispatching: the previous `fetch + JSON.stringify` pipeline silently dropped
9
- * those, but TanStack Start's seroval-based wire format errors instead. We
10
- * mirror the relaxed behaviour so existing callers (e.g. `getFormState` in
11
- * `ServerFunctionsProvider`) that may pass the live form state — which can
12
- * carry stray functions — keep working without each call site sanitising.
13
- *
14
- * Delegates to `runServerFn`, so the response (including any RSC handles for
15
- * server-rendered custom components) is decoded by TanStack Start back into
16
- * renderable React nodes on the client.
17
- */
2
+ /** Builds the admin dispatcher with native Flight response decoding. */
18
3
  export declare function createServerFunctionClient({ runServerFn, }: {
19
4
  runServerFn: (input: {
20
5
  data: ServerFunctionClientArgs;
21
- }) => Promise<unknown>;
6
+ }) => Promise<Response>;
22
7
  }): ServerFunctionClient;
23
- /**
24
- * Recursively removes values TanStack Start's seroval wire format cannot
25
- * serialize (functions, symbols, RegExps, React elements, cyclic refs) and
26
- * normalizes `Date` subclasses to plain `Date`.
27
- */
28
- export declare function stripUnserializable(value: unknown, cache?: WeakMap<object, unknown>, ancestors?: WeakSet<object>): unknown;
29
8
  //# sourceMappingURL=serverFunctionClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serverFunctionClient.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAI7E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,wBAAwB,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAC7E,GAAG,oBAAoB,CAKvB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,KAAK,GAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAiB,EAC/C,SAAS,GAAE,OAAO,CAAC,MAAM,CAAiB,GACzC,OAAO,CA4FT"}
1
+ {"version":3,"file":"serverFunctionClient.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAE7E,wEAAwE;AACxE,wBAAgB,0BAA0B,CAAC,EACzC,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,wBAAwB,CAAA;KAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC9E,GAAG,oBAAoB,CAoBvB"}
@@ -1,114 +1,20 @@
1
- import { setOwnProperty } from 'payload/shared';
2
- /**
3
- * Builds the client-side `ServerFunctionClient` wired into
4
- * `RootProvider.serverFunction`, given the app's `createServerFn`-based
5
- * dispatcher (`runServerFn`).
6
- *
7
- * Strips functions / symbols / RegExps / React elements from the args before
8
- * dispatching: the previous `fetch + JSON.stringify` pipeline silently dropped
9
- * those, but TanStack Start's seroval-based wire format errors instead. We
10
- * mirror the relaxed behaviour so existing callers (e.g. `getFormState` in
11
- * `ServerFunctionsProvider`) that may pass the live form state — which can
12
- * carry stray functions — keep working without each call site sanitising.
13
- *
14
- * Delegates to `runServerFn`, so the response (including any RSC handles for
15
- * server-rendered custom components) is decoded by TanStack Start back into
16
- * renderable React nodes on the client.
17
- */ export function createServerFunctionClient({ runServerFn }) {
1
+ /** Builds the admin dispatcher with native Flight response decoding. */ export function createServerFunctionClient({ runServerFn }) {
18
2
  return async (args)=>{
19
- const safeArgs = stripUnserializable(args);
20
- return await runServerFn({
21
- data: safeArgs
3
+ const response = await runServerFn({
4
+ data: args
22
5
  });
23
- };
24
- }
25
- /**
26
- * Recursively removes values TanStack Start's seroval wire format cannot
27
- * serialize (functions, symbols, RegExps, React elements, cyclic refs) and
28
- * normalizes `Date` subclasses to plain `Date`.
29
- */ export function stripUnserializable(value, cache = new WeakMap(), ancestors = new WeakSet()) {
30
- if (value === null || value === undefined) {
31
- return value;
32
- }
33
- const t = typeof value;
34
- if (t === 'function' || t === 'symbol') {
35
- return undefined;
36
- }
37
- if (t !== 'object') {
38
- return value;
39
- }
40
- const obj = value;
41
- if (typeof obj.$$typeof === 'symbol') {
42
- return undefined;
43
- }
44
- if (ancestors.has(obj)) {
45
- return undefined;
46
- }
47
- if (cache.has(obj)) {
48
- return cache.get(obj);
49
- }
50
- if (obj instanceof Date) {
51
- // Normalize to a plain `Date`. Subclasses (e.g. `@date-fns/tz`'s `TZDate`,
52
- // used by the schedule-publish drawer) are `instanceof Date` but have a
53
- // different `constructor`, which TanStack Start's seroval serializer
54
- // rejects with "The value [object Date] ... cannot be parsed/serialized".
55
- return new Date(obj.getTime());
56
- }
57
- if (obj instanceof RegExp) {
58
- return undefined;
59
- }
60
- ancestors.add(obj);
61
- if (obj instanceof Map) {
62
- const cleaned = new Map();
63
- cache.set(obj, cleaned);
64
- for (const [k, v] of obj){
65
- const cv = stripUnserializable(v, cache, ancestors);
66
- if (cv !== undefined) {
67
- cleaned.set(k, cv);
68
- }
6
+ if (!response.ok) {
7
+ throw new Error(`Payload server function failed with status ${response.status}`);
69
8
  }
70
- ancestors.delete(obj);
71
- return cleaned;
72
- }
73
- if (obj instanceof Set) {
74
- const cleaned = new Set();
75
- cache.set(obj, cleaned);
76
- for (const v of obj){
77
- const cv = stripUnserializable(v, cache, ancestors);
78
- if (cv !== undefined) {
79
- cleaned.add(cv);
80
- }
9
+ if (response.headers.get('content-type')?.split(';')[0]?.trim() !== 'text/x-component') {
10
+ throw new Error('Expected a React Flight response from the Payload server function');
81
11
  }
82
- ancestors.delete(obj);
83
- return cleaned;
84
- }
85
- if (Array.isArray(obj)) {
86
- const arr = [];
87
- cache.set(obj, arr);
88
- for (const item of obj){
89
- arr.push(stripUnserializable(item, cache, ancestors));
12
+ if (!response.body) {
13
+ throw new Error('The Payload server function returned an empty Flight response');
90
14
  }
91
- ancestors.delete(obj);
92
- return arr;
93
- }
94
- if (ArrayBuffer.isView(obj)) {
95
- ancestors.delete(obj);
96
- return obj;
97
- }
98
- const result = {};
99
- cache.set(obj, result);
100
- for (const key of Object.keys(obj)){
101
- const v = stripUnserializable(obj[key], cache, ancestors);
102
- if (v !== undefined) {
103
- setOwnProperty({
104
- key,
105
- target: result,
106
- value: v
107
- });
108
- }
109
- }
110
- ancestors.delete(obj);
111
- return result;
15
+ const { createFromReadableStream } = await import('@tanstack/react-start/rsc');
16
+ return await createFromReadableStream(response.body);
17
+ };
112
18
  }
113
19
 
114
20
  //# sourceMappingURL=serverFunctionClient.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/serverFunctionClient.ts"],"sourcesContent":["import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload'\n\nimport { setOwnProperty } from 'payload/shared'\n\n/**\n * Builds the client-side `ServerFunctionClient` wired into\n * `RootProvider.serverFunction`, given the app's `createServerFn`-based\n * dispatcher (`runServerFn`).\n *\n * Strips functions / symbols / RegExps / React elements from the args before\n * dispatching: the previous `fetch + JSON.stringify` pipeline silently dropped\n * those, but TanStack Start's seroval-based wire format errors instead. We\n * mirror the relaxed behaviour so existing callers (e.g. `getFormState` in\n * `ServerFunctionsProvider`) that may pass the live form state — which can\n * carry stray functions — keep working without each call site sanitising.\n *\n * Delegates to `runServerFn`, so the response (including any RSC handles for\n * server-rendered custom components) is decoded by TanStack Start back into\n * renderable React nodes on the client.\n */\nexport function createServerFunctionClient({\n runServerFn,\n}: {\n runServerFn: (input: { data: ServerFunctionClientArgs }) => Promise<unknown>\n}): ServerFunctionClient {\n return (async (args: ServerFunctionClientArgs) => {\n const safeArgs = stripUnserializable(args) as ServerFunctionClientArgs\n return await runServerFn({ data: safeArgs })\n }) as ServerFunctionClient\n}\n\n/**\n * Recursively removes values TanStack Start's seroval wire format cannot\n * serialize (functions, symbols, RegExps, React elements, cyclic refs) and\n * normalizes `Date` subclasses to plain `Date`.\n */\nexport function stripUnserializable(\n value: unknown,\n cache: WeakMap<object, unknown> = new WeakMap(),\n ancestors: WeakSet<object> = new WeakSet(),\n): unknown {\n if (value === null || value === undefined) {\n return value\n }\n\n const t = typeof value\n if (t === 'function' || t === 'symbol') {\n return undefined\n }\n if (t !== 'object') {\n return value\n }\n\n const obj = value as Record<string, unknown>\n\n if (typeof obj.$$typeof === 'symbol') {\n return undefined\n }\n\n if (ancestors.has(obj)) {\n return undefined\n }\n\n if (cache.has(obj)) {\n return cache.get(obj)\n }\n\n if (obj instanceof Date) {\n // Normalize to a plain `Date`. Subclasses (e.g. `@date-fns/tz`'s `TZDate`,\n // used by the schedule-publish drawer) are `instanceof Date` but have a\n // different `constructor`, which TanStack Start's seroval serializer\n // rejects with \"The value [object Date] ... cannot be parsed/serialized\".\n return new Date(obj.getTime())\n }\n\n if (obj instanceof RegExp) {\n return undefined\n }\n\n ancestors.add(obj)\n\n if (obj instanceof Map) {\n const cleaned = new Map()\n cache.set(obj, cleaned)\n for (const [k, v] of obj) {\n const cv = stripUnserializable(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.set(k, cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (obj instanceof Set) {\n const cleaned = new Set()\n cache.set(obj, cleaned)\n for (const v of obj) {\n const cv = stripUnserializable(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.add(cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (Array.isArray(obj)) {\n const arr: unknown[] = []\n cache.set(obj, arr)\n for (const item of obj) {\n arr.push(stripUnserializable(item, cache, ancestors))\n }\n ancestors.delete(obj)\n return arr\n }\n\n if (ArrayBuffer.isView(obj)) {\n ancestors.delete(obj)\n return obj\n }\n\n const result: Record<string, unknown> = {}\n cache.set(obj, result)\n for (const key of Object.keys(obj)) {\n const v = stripUnserializable(obj[key], cache, ancestors)\n if (v !== undefined) {\n setOwnProperty({ key, target: result, value: v })\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["setOwnProperty","createServerFunctionClient","runServerFn","args","safeArgs","stripUnserializable","data","value","cache","WeakMap","ancestors","WeakSet","undefined","t","obj","$$typeof","has","get","Date","getTime","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","arr","item","push","ArrayBuffer","isView","result","key","Object","keys","target"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAE/C;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASC,2BAA2B,EACzCC,WAAW,EAGZ;IACC,OAAQ,OAAOC;QACb,MAAMC,WAAWC,oBAAoBF;QACrC,OAAO,MAAMD,YAAY;YAAEI,MAAMF;QAAS;IAC5C;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASC,oBACdE,KAAc,EACdC,QAAkC,IAAIC,SAAS,EAC/CC,YAA6B,IAAIC,SAAS;IAE1C,IAAIJ,UAAU,QAAQA,UAAUK,WAAW;QACzC,OAAOL;IACT;IAEA,MAAMM,IAAI,OAAON;IACjB,IAAIM,MAAM,cAAcA,MAAM,UAAU;QACtC,OAAOD;IACT;IACA,IAAIC,MAAM,UAAU;QAClB,OAAON;IACT;IAEA,MAAMO,MAAMP;IAEZ,IAAI,OAAOO,IAAIC,QAAQ,KAAK,UAAU;QACpC,OAAOH;IACT;IAEA,IAAIF,UAAUM,GAAG,CAACF,MAAM;QACtB,OAAOF;IACT;IAEA,IAAIJ,MAAMQ,GAAG,CAACF,MAAM;QAClB,OAAON,MAAMS,GAAG,CAACH;IACnB;IAEA,IAAIA,eAAeI,MAAM;QACvB,2EAA2E;QAC3E,wEAAwE;QACxE,qEAAqE;QACrE,0EAA0E;QAC1E,OAAO,IAAIA,KAAKJ,IAAIK,OAAO;IAC7B;IAEA,IAAIL,eAAeM,QAAQ;QACzB,OAAOR;IACT;IAEAF,UAAUW,GAAG,CAACP;IAEd,IAAIA,eAAeQ,KAAK;QACtB,MAAMC,UAAU,IAAID;QACpBd,MAAMgB,GAAG,CAACV,KAAKS;QACf,KAAK,MAAM,CAACE,GAAGC,EAAE,IAAIZ,IAAK;YACxB,MAAMa,KAAKtB,oBAAoBqB,GAAGlB,OAAOE;YACzC,IAAIiB,OAAOf,WAAW;gBACpBW,QAAQC,GAAG,CAACC,GAAGE;YACjB;QACF;QACAjB,UAAUkB,MAAM,CAACd;QACjB,OAAOS;IACT;IAEA,IAAIT,eAAee,KAAK;QACtB,MAAMN,UAAU,IAAIM;QACpBrB,MAAMgB,GAAG,CAACV,KAAKS;QACf,KAAK,MAAMG,KAAKZ,IAAK;YACnB,MAAMa,KAAKtB,oBAAoBqB,GAAGlB,OAAOE;YACzC,IAAIiB,OAAOf,WAAW;gBACpBW,QAAQF,GAAG,CAACM;YACd;QACF;QACAjB,UAAUkB,MAAM,CAACd;QACjB,OAAOS;IACT;IAEA,IAAIO,MAAMC,OAAO,CAACjB,MAAM;QACtB,MAAMkB,MAAiB,EAAE;QACzBxB,MAAMgB,GAAG,CAACV,KAAKkB;QACf,KAAK,MAAMC,QAAQnB,IAAK;YACtBkB,IAAIE,IAAI,CAAC7B,oBAAoB4B,MAAMzB,OAAOE;QAC5C;QACAA,UAAUkB,MAAM,CAACd;QACjB,OAAOkB;IACT;IAEA,IAAIG,YAAYC,MAAM,CAACtB,MAAM;QAC3BJ,UAAUkB,MAAM,CAACd;QACjB,OAAOA;IACT;IAEA,MAAMuB,SAAkC,CAAC;IACzC7B,MAAMgB,GAAG,CAACV,KAAKuB;IACf,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC1B,KAAM;QAClC,MAAMY,IAAIrB,oBAAoBS,GAAG,CAACwB,IAAI,EAAE9B,OAAOE;QAC/C,IAAIgB,MAAMd,WAAW;YACnBZ,eAAe;gBAAEsC;gBAAKG,QAAQJ;gBAAQ9B,OAAOmB;YAAE;QACjD;IACF;IACAhB,UAAUkB,MAAM,CAACd;IACjB,OAAOuB;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/serverFunctionClient.ts"],"sourcesContent":["import type { ServerFunctionClient, ServerFunctionClientArgs } from 'payload'\n\n/** Builds the admin dispatcher with native Flight response decoding. */\nexport function createServerFunctionClient({\n runServerFn,\n}: {\n runServerFn: (input: { data: ServerFunctionClientArgs }) => Promise<Response>\n}): ServerFunctionClient {\n return (async (args: ServerFunctionClientArgs) => {\n const response = await runServerFn({ data: args })\n\n if (!response.ok) {\n throw new Error(`Payload server function failed with status ${response.status}`)\n }\n\n if (response.headers.get('content-type')?.split(';')[0]?.trim() !== 'text/x-component') {\n throw new Error('Expected a React Flight response from the Payload server function')\n }\n\n if (!response.body) {\n throw new Error('The Payload server function returned an empty Flight response')\n }\n\n const { createFromReadableStream } = await import('@tanstack/react-start/rsc')\n\n return await createFromReadableStream(response.body)\n }) as ServerFunctionClient\n}\n"],"names":["createServerFunctionClient","runServerFn","args","response","data","ok","Error","status","headers","get","split","trim","body","createFromReadableStream"],"mappings":"AAEA,sEAAsE,GACtE,OAAO,SAASA,2BAA2B,EACzCC,WAAW,EAGZ;IACC,OAAQ,OAAOC;QACb,MAAMC,WAAW,MAAMF,YAAY;YAAEG,MAAMF;QAAK;QAEhD,IAAI,CAACC,SAASE,EAAE,EAAE;YAChB,MAAM,IAAIC,MAAM,CAAC,2CAA2C,EAAEH,SAASI,MAAM,EAAE;QACjF;QAEA,IAAIJ,SAASK,OAAO,CAACC,GAAG,CAAC,iBAAiBC,MAAM,IAAI,CAAC,EAAE,EAAEC,WAAW,oBAAoB;YACtF,MAAM,IAAIL,MAAM;QAClB;QAEA,IAAI,CAACH,SAASS,IAAI,EAAE;YAClB,MAAM,IAAIN,MAAM;QAClB;QAEA,MAAM,EAAEO,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC;QAElD,OAAO,MAAMA,yBAAyBV,SAASS,IAAI;IACrD;AACF"}
@@ -25,19 +25,13 @@ export declare const ssrExternalPackages: string[];
25
25
  * storage leaves don't, since their adapters are already `noExternal`.
26
26
  */
27
27
  export declare const buildBundledPackages: string[];
28
+ /** Server-only package boundaries loaded directly by Node in development and production. */
29
+ export declare const serverExternalPackages: string[];
30
+ /** Additional installed packages that can bypass Vite's development server transforms. */
31
+ export declare const devExternalPackages: string[];
28
32
  /**
29
- * External packages for the production `vite build` only (not dev serve).
30
- *
31
- * Externalizes the `@payloadcms/*` package boundaries — plus `payload` — so each
32
- * resolves its own transitive Node deps (`pino`, `drizzle-orm`, `libsql`, …) from
33
- * its own `node_modules` at runtime. Externalizing only the leaf deps breaks under
34
- * pnpm: a leaf imported by bundled code becomes an unresolvable bare specifier from
35
- * `dist/`, since pnpm does not hoist it; see {@link buildBundledPackages}.
36
- *
37
- * Kept out of dev's `ssr.external` on purpose: the monorepo resolves these to
38
- * TypeScript source (`.ts` imported via `.js` specifiers), which only Vite's
39
- * transform can resolve — an externalized copy would hit Node's raw resolver and
40
- * fail on the `.js`→`.ts` mismatch.
33
+ * Externalizes package boundaries so packages resolve their own transitive dependencies under pnpm.
34
+ * Leaves that must bundle in production are excluded; see {@link buildBundledPackages}.
41
35
  */
42
36
  export declare const buildExternalPackages: string[];
43
37
  export declare const payloadNoExternalPatterns: Array<RegExp | string>;
@@ -1 +1 @@
1
- {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../../src/withPayload/config/external.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA+BvC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAOxC,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAUzC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA"}
1
+ {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../../src/withPayload/config/external.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA+BvC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAOxC,CAAA;AAED,4FAA4F;AAC5F,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAS1C,CAAA;AAED,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,EAAE,MAAM,EAKvC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAGzC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA"}
@@ -60,20 +60,7 @@
60
60
  '@azure/storage-blob',
61
61
  '@google-cloud/storage'
62
62
  ];
63
- /**
64
- * External packages for the production `vite build` only (not dev serve).
65
- *
66
- * Externalizes the `@payloadcms/*` package boundaries — plus `payload` — so each
67
- * resolves its own transitive Node deps (`pino`, `drizzle-orm`, `libsql`, …) from
68
- * its own `node_modules` at runtime. Externalizing only the leaf deps breaks under
69
- * pnpm: a leaf imported by bundled code becomes an unresolvable bare specifier from
70
- * `dist/`, since pnpm does not hoist it; see {@link buildBundledPackages}.
71
- *
72
- * Kept out of dev's `ssr.external` on purpose: the monorepo resolves these to
73
- * TypeScript source (`.ts` imported via `.js` specifiers), which only Vite's
74
- * transform can resolve — an externalized copy would hit Node's raw resolver and
75
- * fail on the `.js`→`.ts` mismatch.
76
- */ export const buildExternalPackages = [
63
+ /** Server-only package boundaries loaded directly by Node in development and production. */ export const serverExternalPackages = [
77
64
  'payload',
78
65
  'payload/node',
79
66
  '@payloadcms/drizzle',
@@ -81,7 +68,19 @@
81
68
  '@payloadcms/db-postgres',
82
69
  '@payloadcms/db-vercel-postgres',
83
70
  '@payloadcms/db-sqlite',
84
- '@payloadcms/db-d1-sqlite',
71
+ '@payloadcms/db-d1-sqlite'
72
+ ];
73
+ /** Additional installed packages that can bypass Vite's development server transforms. */ export const devExternalPackages = [
74
+ ...serverExternalPackages,
75
+ '@payloadcms/plugin-mcp',
76
+ 'date-fns',
77
+ 'undici'
78
+ ];
79
+ /**
80
+ * Externalizes package boundaries so packages resolve their own transitive dependencies under pnpm.
81
+ * Leaves that must bundle in production are excluded; see {@link buildBundledPackages}.
82
+ */ export const buildExternalPackages = [
83
+ ...serverExternalPackages,
85
84
  ...ssrExternalPackages.filter((pkg)=>!buildBundledPackages.includes(pkg))
86
85
  ];
87
86
  export const payloadNoExternalPatterns = [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/withPayload/config/external.ts"],"sourcesContent":["/**\n * SSR/RSC externalization config used by `withPayload`. Kept separate from the\n * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.\n */\n\n/**\n * Packages externalized during dev serve (`ssr.external`). Node's loader resolves\n * their CJS/UMD directly; letting Vite's dev SSR transform touch them can break\n * fragile UMD wrappers (e.g. `pluralize`, whose `this`-based global assignment\n * throws when transformed rather than required).\n *\n * Safe here whoever declared the entry: Node resolves from the importing package,\n * so pnpm's isolated layout never applies. The build is stricter — see\n * {@link buildBundledPackages}.\n */\nexport const ssrExternalPackages: string[] = [\n 'zod',\n 'fast-uri',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'drizzle-orm',\n 'sharp',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n 'pino',\n 'pino-pretty',\n 'graphql',\n 'nodemailer',\n 'aws4',\n 'pluralize',\n 'console-table-printer',\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n // Database drivers + their lazily-required companions, one group per adapter.\n // Postgres (`@payloadcms/db-postgres`, `@payloadcms/db-vercel-postgres`)\n 'pg',\n 'pg-native',\n 'pg-cloudflare',\n // SQLite (`@payloadcms/db-sqlite`)\n 'better-sqlite3',\n 'libsql',\n // Mongo (`@payloadcms/db-mongodb`)\n 'mongodb',\n 'mongoose',\n]\n\n/**\n * Entries of {@link ssrExternalPackages} that must bundle in the production build.\n *\n * Externalizing only works for specifiers resolvable from the project root. These\n * are leaf deps of Payload packages, so under pnpm they live in `.pnpm/…` and a bare\n * specifier in a root-resolved chunk is invisible — `ERR_MODULE_NOT_FOUND` at\n * runtime, or a build-time resolve failure under Nitro's re-bundle pass.\n *\n * `pluralize` also needs forcing back via `noExternal` (see `withPayload`); the\n * storage leaves don't, since their adapters are already `noExternal`.\n */\nexport const buildBundledPackages: string[] = [\n 'pluralize',\n // Leaf deps of the `@payloadcms/storage-*` adapters.\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@azure/storage-blob',\n '@google-cloud/storage',\n]\n\n/**\n * External packages for the production `vite build` only (not dev serve).\n *\n * Externalizes the `@payloadcms/*` package boundaries — plus `payload` — so each\n * resolves its own transitive Node deps (`pino`, `drizzle-orm`, `libsql`, …) from\n * its own `node_modules` at runtime. Externalizing only the leaf deps breaks under\n * pnpm: a leaf imported by bundled code becomes an unresolvable bare specifier from\n * `dist/`, since pnpm does not hoist it; see {@link buildBundledPackages}.\n *\n * Kept out of dev's `ssr.external` on purpose: the monorepo resolves these to\n * TypeScript source (`.ts` imported via `.js` specifiers), which only Vite's\n * transform can resolve — an externalized copy would hit Node's raw resolver and\n * fail on the `.js`→`.ts` mismatch.\n */\nexport const buildExternalPackages: string[] = [\n 'payload',\n 'payload/node',\n '@payloadcms/drizzle',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-d1-sqlite',\n ...ssrExternalPackages.filter((pkg) => !buildBundledPackages.includes(pkg)),\n]\n\nexport const payloadNoExternalPatterns: Array<RegExp | string> = [\n '@payloadcms/ui',\n '@payloadcms/translations',\n '@payloadcms/tanstack-start',\n /^@payloadcms\\/richtext-lexical/,\n /^@payloadcms\\/plugin-/,\n /^@payloadcms\\/storage-/,\n]\n"],"names":["ssrExternalPackages","buildBundledPackages","buildExternalPackages","filter","pkg","includes","payloadNoExternalPatterns"],"mappings":"AAAA;;;CAGC,GAED;;;;;;;;;CASC,GACD,OAAO,MAAMA,sBAAgC;IAC3C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,8EAA8E;IAC9E,yEAAyE;IACzE;IACA;IACA;IACA,mCAAmC;IACnC;IACA;IACA,mCAAmC;IACnC;IACA;CACD,CAAA;AAED;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,uBAAiC;IAC5C;IACA,qDAAqD;IACrD;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,wBAAkC;IAC7C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;OACGF,oBAAoBG,MAAM,CAAC,CAACC,MAAQ,CAACH,qBAAqBI,QAAQ,CAACD;CACvE,CAAA;AAED,OAAO,MAAME,4BAAoD;IAC/D;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
1
+ {"version":3,"sources":["../../../src/withPayload/config/external.ts"],"sourcesContent":["/**\n * SSR/RSC externalization config used by `withPayload`. Kept separate from the\n * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.\n */\n\n/**\n * Packages externalized during dev serve (`ssr.external`). Node's loader resolves\n * their CJS/UMD directly; letting Vite's dev SSR transform touch them can break\n * fragile UMD wrappers (e.g. `pluralize`, whose `this`-based global assignment\n * throws when transformed rather than required).\n *\n * Safe here whoever declared the entry: Node resolves from the importing package,\n * so pnpm's isolated layout never applies. The build is stricter — see\n * {@link buildBundledPackages}.\n */\nexport const ssrExternalPackages: string[] = [\n 'zod',\n 'fast-uri',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'drizzle-orm',\n 'sharp',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n 'pino',\n 'pino-pretty',\n 'graphql',\n 'nodemailer',\n 'aws4',\n 'pluralize',\n 'console-table-printer',\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n // Database drivers + their lazily-required companions, one group per adapter.\n // Postgres (`@payloadcms/db-postgres`, `@payloadcms/db-vercel-postgres`)\n 'pg',\n 'pg-native',\n 'pg-cloudflare',\n // SQLite (`@payloadcms/db-sqlite`)\n 'better-sqlite3',\n 'libsql',\n // Mongo (`@payloadcms/db-mongodb`)\n 'mongodb',\n 'mongoose',\n]\n\n/**\n * Entries of {@link ssrExternalPackages} that must bundle in the production build.\n *\n * Externalizing only works for specifiers resolvable from the project root. These\n * are leaf deps of Payload packages, so under pnpm they live in `.pnpm/…` and a bare\n * specifier in a root-resolved chunk is invisible — `ERR_MODULE_NOT_FOUND` at\n * runtime, or a build-time resolve failure under Nitro's re-bundle pass.\n *\n * `pluralize` also needs forcing back via `noExternal` (see `withPayload`); the\n * storage leaves don't, since their adapters are already `noExternal`.\n */\nexport const buildBundledPackages: string[] = [\n 'pluralize',\n // Leaf deps of the `@payloadcms/storage-*` adapters.\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@azure/storage-blob',\n '@google-cloud/storage',\n]\n\n/** Server-only package boundaries loaded directly by Node in development and production. */\nexport const serverExternalPackages: string[] = [\n 'payload',\n 'payload/node',\n '@payloadcms/drizzle',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-d1-sqlite',\n]\n\n/** Additional installed packages that can bypass Vite's development server transforms. */\nexport const devExternalPackages: string[] = [\n ...serverExternalPackages,\n '@payloadcms/plugin-mcp',\n 'date-fns',\n 'undici',\n]\n\n/**\n * Externalizes package boundaries so packages resolve their own transitive dependencies under pnpm.\n * Leaves that must bundle in production are excluded; see {@link buildBundledPackages}.\n */\nexport const buildExternalPackages: string[] = [\n ...serverExternalPackages,\n ...ssrExternalPackages.filter((pkg) => !buildBundledPackages.includes(pkg)),\n]\n\nexport const payloadNoExternalPatterns: Array<RegExp | string> = [\n '@payloadcms/ui',\n '@payloadcms/translations',\n '@payloadcms/tanstack-start',\n /^@payloadcms\\/richtext-lexical/,\n /^@payloadcms\\/plugin-/,\n /^@payloadcms\\/storage-/,\n]\n"],"names":["ssrExternalPackages","buildBundledPackages","serverExternalPackages","devExternalPackages","buildExternalPackages","filter","pkg","includes","payloadNoExternalPatterns"],"mappings":"AAAA;;;CAGC,GAED;;;;;;;;;CASC,GACD,OAAO,MAAMA,sBAAgC;IAC3C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,8EAA8E;IAC9E,yEAAyE;IACzE;IACA;IACA;IACA,mCAAmC;IACnC;IACA;IACA,mCAAmC;IACnC;IACA;CACD,CAAA;AAED;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,uBAAiC;IAC5C;IACA,qDAAqD;IACrD;IACA;IACA;IACA;CACD,CAAA;AAED,0FAA0F,GAC1F,OAAO,MAAMC,yBAAmC;IAC9C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED,wFAAwF,GACxF,OAAO,MAAMC,sBAAgC;OACxCD;IACH;IACA;IACA;CACD,CAAA;AAED;;;CAGC,GACD,OAAO,MAAME,wBAAkC;OAC1CF;OACAF,oBAAoBK,MAAM,CAAC,CAACC,MAAQ,CAACL,qBAAqBM,QAAQ,CAACD;CACvE,CAAA;AAED,OAAO,MAAME,4BAAoD;IAC/D;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"optimizeDeps.d.ts","sourceRoot":"","sources":["../../../src/withPayload/config/optimizeDeps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAyB/C,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EA+E/C,CAAA"}
1
+ {"version":3,"file":"optimizeDeps.d.ts","sourceRoot":"","sources":["../../../src/withPayload/config/optimizeDeps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EA0D/C,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EA+E/C,CAAA"}
@@ -27,10 +27,43 @@
27
27
  '@azure/storage-blob',
28
28
  // Preserve RSC client boundaries on storage admin upload handlers.
29
29
  '@payloadcms/storage-azure',
30
+ '@payloadcms/storage-r2',
30
31
  '@payloadcms/storage-vercel-blob',
31
32
  '@aws-sdk/client-s3',
32
33
  '@aws-sdk/s3-request-presigner',
33
- '@google-cloud/storage'
34
+ '@google-cloud/storage',
35
+ // Packages whose admin component barrel re-exports `'use client'` modules
36
+ // without carrying the directive itself. Pre-bundling one puts those modules
37
+ // in the optimized dep chunk *and* in the `rsc` environment as client
38
+ // references, which `@vitejs/plugin-rsc` warns about ("client component
39
+ // dependency is inconsistently optimized") once per component. Barrels that
40
+ // start with `'use client'` (e.g. `richtext-lexical`, `plugin-stripe`) don't
41
+ // warn and stay pre-bundled. Only shows up in published installs; workspace
42
+ // source is never pre-bundled.
43
+ '@payloadcms/plugin-cloud-storage',
44
+ '@payloadcms/plugin-ecommerce',
45
+ '@payloadcms/plugin-form-builder',
46
+ '@payloadcms/plugin-import-export',
47
+ '@payloadcms/plugin-multi-tenant',
48
+ '@payloadcms/plugin-search',
49
+ '@payloadcms/plugin-sentry',
50
+ '@payloadcms/plugin-seo',
51
+ // Database adapters and their drivers. The client scan reaches them through the
52
+ // Payload config (it follows server functions' `import('@payload-config')`
53
+ // without TanStack's server-fn stripping), so Vite would pre-bundle the whole
54
+ // driver for a browser that never loads it. Mongoose 9 has no browser build, so
55
+ // that bundles `mongodb`, whose optional `@aws-sdk/credential-providers` peer —
56
+ // when linked, as in the monorepo via `@payloadcms/payload-cloud` — fails the
57
+ // same `MISSING_EXPORT` way. Published installs reach the adapter packages;
58
+ // the monorepo, which resolves them to source, reaches the drivers.
59
+ '@payloadcms/db-d1-sqlite',
60
+ '@payloadcms/db-mongodb',
61
+ '@payloadcms/db-postgres',
62
+ '@payloadcms/db-sqlite',
63
+ '@payloadcms/db-vercel-postgres',
64
+ '@payloadcms/drizzle',
65
+ 'mongodb',
66
+ 'mongoose'
34
67
  ];
35
68
  /**
36
69
  * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/withPayload/config/optimizeDeps.ts"],"sourcesContent":["/**\n * Client dep-optimizer config used by `withPayload`. Kept separate from the\n * SSR/RSC externalization config (`./external.ts`) so each concern stays small.\n */\n\n/**\n * Packages we know contain Node-only code or top-level side effects requiring\n * Node APIs. Excluding them from the client optimizer prevents Vite from\n * walking into their main entries and trying to bundle server-only imports\n * for the browser.\n */\nexport const optimizeDepsExcludeDefaults: string[] = [\n 'sharp',\n '@payloadcms/ui',\n '@payloadcms/tanstack-start',\n 'payload',\n 'pino',\n 'pino-pretty',\n 'busboy',\n 'get-tsconfig',\n 'ws',\n 'croner',\n 'prompts',\n 'file-type',\n // Server-only SDKs used by `@payloadcms/storage-*` adapters. Vite\n // sometimes walks these from the main package entry while scanning\n // workspace deps, and the browser sub-bundles do not expose the\n // server-only APIs (e.g. `BlobSASPermissions`), which crashes the dev\n // server with a `MISSING_EXPORT` error before any test runs.\n '@azure/storage-blob',\n // Preserve RSC client boundaries on storage admin upload handlers.\n '@payloadcms/storage-azure',\n '@payloadcms/storage-vercel-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n]\n\n/**\n * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be\n * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick\n * these up because their parent packages are in `optimizeDeps.exclude`, so we\n * list them explicitly using the `parent > child` syntax.\n *\n * Each entry below fixes a specific late-discovery re-optimization: without it,\n * Vite discovers the dep *after* its initial crawl, forcing a full dep\n * re-optimization mid-session that 404s in-flight `.vite/deps/*` chunks and\n * remounts the admin (dropping client state). This is why the list can't simply\n * be deleted — it is the \"complete first pass\" for the admin's dep graph.\n */\nexport const optimizeDepsIncludeDefaults: string[] = [\n '@payloadcms/ui > sonner',\n '@payloadcms/ui > @faceless-ui/modal',\n '@payloadcms/ui > @faceless-ui/window-info',\n '@payloadcms/ui > @faceless-ui/scroll-info',\n '@payloadcms/ui > @dnd-kit/core',\n '@payloadcms/ui > @dnd-kit/sortable',\n '@payloadcms/ui > @dnd-kit/utilities',\n '@payloadcms/ui > react-datepicker',\n '@payloadcms/ui > react-select',\n '@payloadcms/ui > react-select/creatable',\n '@payloadcms/ui > react-image-crop',\n '@payloadcms/ui > @monaco-editor/react',\n '@payloadcms/ui > date-fns',\n '@payloadcms/ui > date-fns/transpose',\n '@payloadcms/ui > @date-fns/tz/date/mini',\n '@payloadcms/ui > uuid',\n '@payloadcms/ui > use-context-selector',\n '@payloadcms/ui > bson-objectid',\n '@payloadcms/ui > dequal',\n '@payloadcms/ui > object-to-formdata',\n '@payloadcms/ui > md5',\n 'payload > deepmerge',\n 'payload > pluralize',\n // `scheduler` is a transitive dep of `react-dom`, not a direct dependency of\n // the app, so a bare `'scheduler'` specifier fails to resolve from an isolated\n // install (`test/node_modules` built with `pnpm i --ignore-workspace`), where\n // it isn't hoisted to the top level. Path it through `react-dom` so the\n // optimizer resolves the exact copy the runtime loads.\n 'react-dom > scheduler',\n // `@payloadcms/ui` (in `optimizeDeps.exclude`) ships compiled output that the\n // React Compiler rewrote to `import { c } from 'react/compiler-runtime'`.\n // Because its parent is excluded, the optimizer never crawls in to discover\n // this entry, so Vite serves `react/compiler-runtime` raw. That file is\n // CommonJS (`module.exports = require(...)`), so the named `c` export can't be\n // statically extracted and every client component throws \"does not provide an\n // export named 'c'\". Pre-bundling it lets esbuild synthesize the named export.\n 'react/compiler-runtime',\n // Transitive deps that Vite otherwise discovers *after* the initial crawl\n // (react-select pulls in @floating-ui at runtime; react-is is reached via\n // react-transition-group/prop-types; the default date-fns locale is loaded\n // through a dynamic `date-fns/locale/${key}` import). A late discovery forces\n // a full dep re-optimization mid-session, which 404s every in-flight\n // `.vite/deps/*` chunk (\"Pre-transform error: file does not exist in the\n // optimize deps directory\") and breaks the admin UI in CI cold starts.\n // Pre-bundling them keeps the first optimization pass complete.\n '@payloadcms/ui > react-select > @floating-ui/dom',\n '@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',\n '@payloadcms/ui > react-select > prop-types > react-is',\n '@payloadcms/ui > date-fns/locale/en-US',\n // Further late discoveries observed re-optimizing mid-run in CI cold starts\n // (see CI logs: \"✨ new dependencies optimized: @dnd-kit/modifiers / zod /\n // dequal/lite\"). The modular dashboard pulls in `@dnd-kit/modifiers` on first\n // render; form-state diffing reaches `dequal/lite` (a distinct entry point\n // from the already-listed `dequal`); client-side field validation reaches\n // `zod` *through `payload`* — it is `ssrExternal` server-side but still\n // bundled into the client, and must be pathed via `payload` so the optimizer\n // pre-bundles the exact copy the runtime loads.\n '@payloadcms/ui > @dnd-kit/modifiers',\n '@payloadcms/ui > dequal/lite',\n 'payload > zod',\n // The storage client-upload suites (esp. vercel-blob) crawl part of the\n // `payload` server runtime into the client bundle and discover these late,\n // triggering several \"optimized dependencies changed. reloading\" waves that\n // reload the page mid-test (the bulk-upload drawer's Create New button /\n // dropzone vanish and the direct-to-bucket PUT never fires). Pre-bundle the\n // whole observed set so the first pass is complete.\n 'payload > undici',\n 'payload > jose',\n 'payload > dataloader',\n 'payload > path-to-regexp',\n 'payload > console-table-printer',\n 'payload > ci-info',\n 'payload > image-dimensions',\n 'payload > ipaddr.js',\n 'payload > range-parser',\n 'payload > sanitize-filename',\n // `@azure/storage-blob` is excluded, so pre-bundle its CommonJS browser dependency explicitly.\n '@azure/storage-blob > events',\n]\n"],"names":["optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults"],"mappings":"AAAA;;;CAGC,GAED;;;;;CAKC,GACD,OAAO,MAAMA,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,kEAAkE;IAClE,mEAAmE;IACnE,gEAAgE;IAChE,sEAAsE;IACtE,6DAA6D;IAC7D;IACA,mEAAmE;IACnE;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,6EAA6E;IAC7E,+EAA+E;IAC/E,8EAA8E;IAC9E,wEAAwE;IACxE,uDAAuD;IACvD;IACA,8EAA8E;IAC9E,0EAA0E;IAC1E,4EAA4E;IAC5E,wEAAwE;IACxE,+EAA+E;IAC/E,8EAA8E;IAC9E,+EAA+E;IAC/E;IACA,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,8EAA8E;IAC9E,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,gEAAgE;IAChE;IACA;IACA;IACA;IACA,4EAA4E;IAC5E,0EAA0E;IAC1E,8EAA8E;IAC9E,2EAA2E;IAC3E,0EAA0E;IAC1E,wEAAwE;IACxE,6EAA6E;IAC7E,gDAAgD;IAChD;IACA;IACA;IACA,wEAAwE;IACxE,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,4EAA4E;IAC5E,oDAAoD;IACpD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,+FAA+F;IAC/F;CACD,CAAA"}
1
+ {"version":3,"sources":["../../../src/withPayload/config/optimizeDeps.ts"],"sourcesContent":["/**\n * Client dep-optimizer config used by `withPayload`. Kept separate from the\n * SSR/RSC externalization config (`./external.ts`) so each concern stays small.\n */\n\n/**\n * Packages we know contain Node-only code or top-level side effects requiring\n * Node APIs. Excluding them from the client optimizer prevents Vite from\n * walking into their main entries and trying to bundle server-only imports\n * for the browser.\n */\nexport const optimizeDepsExcludeDefaults: string[] = [\n 'sharp',\n '@payloadcms/ui',\n '@payloadcms/tanstack-start',\n 'payload',\n 'pino',\n 'pino-pretty',\n 'busboy',\n 'get-tsconfig',\n 'ws',\n 'croner',\n 'prompts',\n 'file-type',\n // Server-only SDKs used by `@payloadcms/storage-*` adapters. Vite\n // sometimes walks these from the main package entry while scanning\n // workspace deps, and the browser sub-bundles do not expose the\n // server-only APIs (e.g. `BlobSASPermissions`), which crashes the dev\n // server with a `MISSING_EXPORT` error before any test runs.\n '@azure/storage-blob',\n // Preserve RSC client boundaries on storage admin upload handlers.\n '@payloadcms/storage-azure',\n '@payloadcms/storage-r2',\n '@payloadcms/storage-vercel-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n // Packages whose admin component barrel re-exports `'use client'` modules\n // without carrying the directive itself. Pre-bundling one puts those modules\n // in the optimized dep chunk *and* in the `rsc` environment as client\n // references, which `@vitejs/plugin-rsc` warns about (\"client component\n // dependency is inconsistently optimized\") once per component. Barrels that\n // start with `'use client'` (e.g. `richtext-lexical`, `plugin-stripe`) don't\n // warn and stay pre-bundled. Only shows up in published installs; workspace\n // source is never pre-bundled.\n '@payloadcms/plugin-cloud-storage',\n '@payloadcms/plugin-ecommerce',\n '@payloadcms/plugin-form-builder',\n '@payloadcms/plugin-import-export',\n '@payloadcms/plugin-multi-tenant',\n '@payloadcms/plugin-search',\n '@payloadcms/plugin-sentry',\n '@payloadcms/plugin-seo',\n // Database adapters and their drivers. The client scan reaches them through the\n // Payload config (it follows server functions' `import('@payload-config')`\n // without TanStack's server-fn stripping), so Vite would pre-bundle the whole\n // driver for a browser that never loads it. Mongoose 9 has no browser build, so\n // that bundles `mongodb`, whose optional `@aws-sdk/credential-providers` peer —\n // when linked, as in the monorepo via `@payloadcms/payload-cloud` — fails the\n // same `MISSING_EXPORT` way. Published installs reach the adapter packages;\n // the monorepo, which resolves them to source, reaches the drivers.\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/drizzle',\n 'mongodb',\n 'mongoose',\n]\n\n/**\n * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be\n * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick\n * these up because their parent packages are in `optimizeDeps.exclude`, so we\n * list them explicitly using the `parent > child` syntax.\n *\n * Each entry below fixes a specific late-discovery re-optimization: without it,\n * Vite discovers the dep *after* its initial crawl, forcing a full dep\n * re-optimization mid-session that 404s in-flight `.vite/deps/*` chunks and\n * remounts the admin (dropping client state). This is why the list can't simply\n * be deleted — it is the \"complete first pass\" for the admin's dep graph.\n */\nexport const optimizeDepsIncludeDefaults: string[] = [\n '@payloadcms/ui > sonner',\n '@payloadcms/ui > @faceless-ui/modal',\n '@payloadcms/ui > @faceless-ui/window-info',\n '@payloadcms/ui > @faceless-ui/scroll-info',\n '@payloadcms/ui > @dnd-kit/core',\n '@payloadcms/ui > @dnd-kit/sortable',\n '@payloadcms/ui > @dnd-kit/utilities',\n '@payloadcms/ui > react-datepicker',\n '@payloadcms/ui > react-select',\n '@payloadcms/ui > react-select/creatable',\n '@payloadcms/ui > react-image-crop',\n '@payloadcms/ui > @monaco-editor/react',\n '@payloadcms/ui > date-fns',\n '@payloadcms/ui > date-fns/transpose',\n '@payloadcms/ui > @date-fns/tz/date/mini',\n '@payloadcms/ui > uuid',\n '@payloadcms/ui > use-context-selector',\n '@payloadcms/ui > bson-objectid',\n '@payloadcms/ui > dequal',\n '@payloadcms/ui > object-to-formdata',\n '@payloadcms/ui > md5',\n 'payload > deepmerge',\n 'payload > pluralize',\n // `scheduler` is a transitive dep of `react-dom`, not a direct dependency of\n // the app, so a bare `'scheduler'` specifier fails to resolve from an isolated\n // install (`test/node_modules` built with `pnpm i --ignore-workspace`), where\n // it isn't hoisted to the top level. Path it through `react-dom` so the\n // optimizer resolves the exact copy the runtime loads.\n 'react-dom > scheduler',\n // `@payloadcms/ui` (in `optimizeDeps.exclude`) ships compiled output that the\n // React Compiler rewrote to `import { c } from 'react/compiler-runtime'`.\n // Because its parent is excluded, the optimizer never crawls in to discover\n // this entry, so Vite serves `react/compiler-runtime` raw. That file is\n // CommonJS (`module.exports = require(...)`), so the named `c` export can't be\n // statically extracted and every client component throws \"does not provide an\n // export named 'c'\". Pre-bundling it lets esbuild synthesize the named export.\n 'react/compiler-runtime',\n // Transitive deps that Vite otherwise discovers *after* the initial crawl\n // (react-select pulls in @floating-ui at runtime; react-is is reached via\n // react-transition-group/prop-types; the default date-fns locale is loaded\n // through a dynamic `date-fns/locale/${key}` import). A late discovery forces\n // a full dep re-optimization mid-session, which 404s every in-flight\n // `.vite/deps/*` chunk (\"Pre-transform error: file does not exist in the\n // optimize deps directory\") and breaks the admin UI in CI cold starts.\n // Pre-bundling them keeps the first optimization pass complete.\n '@payloadcms/ui > react-select > @floating-ui/dom',\n '@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',\n '@payloadcms/ui > react-select > prop-types > react-is',\n '@payloadcms/ui > date-fns/locale/en-US',\n // Further late discoveries observed re-optimizing mid-run in CI cold starts\n // (see CI logs: \"✨ new dependencies optimized: @dnd-kit/modifiers / zod /\n // dequal/lite\"). The modular dashboard pulls in `@dnd-kit/modifiers` on first\n // render; form-state diffing reaches `dequal/lite` (a distinct entry point\n // from the already-listed `dequal`); client-side field validation reaches\n // `zod` *through `payload`* — it is `ssrExternal` server-side but still\n // bundled into the client, and must be pathed via `payload` so the optimizer\n // pre-bundles the exact copy the runtime loads.\n '@payloadcms/ui > @dnd-kit/modifiers',\n '@payloadcms/ui > dequal/lite',\n 'payload > zod',\n // The storage client-upload suites (esp. vercel-blob) crawl part of the\n // `payload` server runtime into the client bundle and discover these late,\n // triggering several \"optimized dependencies changed. reloading\" waves that\n // reload the page mid-test (the bulk-upload drawer's Create New button /\n // dropzone vanish and the direct-to-bucket PUT never fires). Pre-bundle the\n // whole observed set so the first pass is complete.\n 'payload > undici',\n 'payload > jose',\n 'payload > dataloader',\n 'payload > path-to-regexp',\n 'payload > console-table-printer',\n 'payload > ci-info',\n 'payload > image-dimensions',\n 'payload > ipaddr.js',\n 'payload > range-parser',\n 'payload > sanitize-filename',\n // `@azure/storage-blob` is excluded, so pre-bundle its CommonJS browser dependency explicitly.\n '@azure/storage-blob > events',\n]\n"],"names":["optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults"],"mappings":"AAAA;;;CAGC,GAED;;;;;CAKC,GACD,OAAO,MAAMA,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,kEAAkE;IAClE,mEAAmE;IACnE,gEAAgE;IAChE,sEAAsE;IACtE,6DAA6D;IAC7D;IACA,mEAAmE;IACnE;IACA;IACA;IACA;IACA;IACA;IACA,0EAA0E;IAC1E,6EAA6E;IAC7E,sEAAsE;IACtE,wEAAwE;IACxE,4EAA4E;IAC5E,6EAA6E;IAC7E,4EAA4E;IAC5E,+BAA+B;IAC/B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,gFAAgF;IAChF,2EAA2E;IAC3E,8EAA8E;IAC9E,gFAAgF;IAChF,gFAAgF;IAChF,8EAA8E;IAC9E,4EAA4E;IAC5E,oEAAoE;IACpE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,6EAA6E;IAC7E,+EAA+E;IAC/E,8EAA8E;IAC9E,wEAAwE;IACxE,uDAAuD;IACvD;IACA,8EAA8E;IAC9E,0EAA0E;IAC1E,4EAA4E;IAC5E,wEAAwE;IACxE,+EAA+E;IAC/E,8EAA8E;IAC9E,+EAA+E;IAC/E;IACA,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,8EAA8E;IAC9E,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,gEAAgE;IAChE;IACA;IACA;IACA;IACA,4EAA4E;IAC5E,0EAA0E;IAC1E,8EAA8E;IAC9E,2EAA2E;IAC3E,0EAA0E;IAC1E,wEAAwE;IACxE,6EAA6E;IAC7E,gDAAgD;IAChD;IACA;IACA;IACA,wEAAwE;IACxE,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,4EAA4E;IAC5E,oDAAoD;IACpD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,+FAA+F;IAC/F;CACD,CAAA"}
@@ -11,7 +11,7 @@ import { builtinModules } from 'node:module';
11
11
  /^@payloadcms\/richtext-lexical\/rsc/,
12
12
  /^@payloadcms\/richtext-slate\/rsc/,
13
13
  '@payloadcms/ui/server',
14
- /^@payloadcms\/tanstack-start\/(layouts|rsc|server)/,
14
+ /^@payloadcms\/tanstack-start\/(layouts|rest|rsc|server)/,
15
15
  'sharp',
16
16
  'busboy',
17
17
  'croner',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/withPayload/importProtection.ts"],"sourcesContent":["import { builtinModules } from 'node:module'\n\n/**\n * Specifiers that must never appear in the client module graph. These are the\n * server-only Payload entry points plus Node.js built-ins and a handful of\n * Node-only npm packages that Payload pulls in transitively.\n */\nexport const serverOnlyClientSpecifiers: Array<RegExp | string> = [\n /^node:/,\n new RegExp(`^(${builtinModules.join('|')})(\\\\/|$)`),\n '@payload-config',\n /^@payloadcms\\/next\\/rsc/,\n /^@payloadcms\\/richtext-lexical\\/rsc/,\n /^@payloadcms\\/richtext-slate\\/rsc/,\n '@payloadcms/ui/server',\n /^@payloadcms\\/tanstack-start\\/(layouts|rsc|server)/,\n 'sharp',\n 'busboy',\n 'croner',\n 'pino',\n 'pino-pretty',\n 'prompts',\n 'ws',\n 'undici',\n 'get-tsconfig',\n /^file-type/,\n /^react-dom\\/server/,\n]\n\n/**\n * Allowlist callback for the `tanstackStart` plugin's import-protection. These\n * are the legitimate cross-environment imports in our monorepo that we want\n * to permit even when they appear to cross a server/client boundary.\n */\nexport function onImportProtectionViolation(violation: unknown): boolean | void {\n const info = violation as {\n envType: 'client' | 'server'\n importer: string\n resolved?: string\n }\n\n const allowedClientFileImporters = /\\/richtext-lexical\\/.*\\/exports\\/client\\/|\\/ui\\//\n\n if (\n info.envType === 'server' &&\n info.resolved?.includes('.client.') &&\n allowedClientFileImporters.test(info.importer)\n ) {\n return false\n }\n\n if (info.importer.includes('/richtext-lexical/') && info.importer.includes('/field/Diff/')) {\n return false\n }\n\n if (info.importer.includes('/packages/payload/') || info.importer.includes('/payload/dist/')) {\n return false\n }\n\n if (\n info.importer.includes('@payloadcms/ui') &&\n (info.importer.includes('/exports/rsc/') || info.importer.includes('/rsc/index'))\n ) {\n return false\n }\n\n if (info.envType === 'server' && info.importer.includes('vite-rsc/client-references')) {\n return false\n }\n}\n\nexport const defaultImportProtectionIgnoreImporters: RegExp[] = [/^src\\/importMap\\.js(?:\\?.*)?$/]\n"],"names":["builtinModules","serverOnlyClientSpecifiers","RegExp","join","onImportProtectionViolation","violation","info","allowedClientFileImporters","envType","resolved","includes","test","importer","defaultImportProtectionIgnoreImporters"],"mappings":"AAAA,SAASA,cAAc,QAAQ,cAAa;AAE5C;;;;CAIC,GACD,OAAO,MAAMC,6BAAqD;IAChE;IACA,IAAIC,OAAO,CAAC,EAAE,EAAEF,eAAeG,IAAI,CAAC,KAAK,QAAQ,CAAC;IAClD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;CAIC,GACD,OAAO,SAASC,4BAA4BC,SAAkB;IAC5D,MAAMC,OAAOD;IAMb,MAAME,6BAA6B;IAEnC,IACED,KAAKE,OAAO,KAAK,YACjBF,KAAKG,QAAQ,EAAEC,SAAS,eACxBH,2BAA2BI,IAAI,CAACL,KAAKM,QAAQ,GAC7C;QACA,OAAO;IACT;IAEA,IAAIN,KAAKM,QAAQ,CAACF,QAAQ,CAAC,yBAAyBJ,KAAKM,QAAQ,CAACF,QAAQ,CAAC,iBAAiB;QAC1F,OAAO;IACT;IAEA,IAAIJ,KAAKM,QAAQ,CAACF,QAAQ,CAAC,yBAAyBJ,KAAKM,QAAQ,CAACF,QAAQ,CAAC,mBAAmB;QAC5F,OAAO;IACT;IAEA,IACEJ,KAAKM,QAAQ,CAACF,QAAQ,CAAC,qBACtBJ,CAAAA,KAAKM,QAAQ,CAACF,QAAQ,CAAC,oBAAoBJ,KAAKM,QAAQ,CAACF,QAAQ,CAAC,aAAY,GAC/E;QACA,OAAO;IACT;IAEA,IAAIJ,KAAKE,OAAO,KAAK,YAAYF,KAAKM,QAAQ,CAACF,QAAQ,CAAC,+BAA+B;QACrF,OAAO;IACT;AACF;AAEA,OAAO,MAAMG,yCAAmD;IAAC;CAAgC,CAAA"}
1
+ {"version":3,"sources":["../../src/withPayload/importProtection.ts"],"sourcesContent":["import { builtinModules } from 'node:module'\n\n/**\n * Specifiers that must never appear in the client module graph. These are the\n * server-only Payload entry points plus Node.js built-ins and a handful of\n * Node-only npm packages that Payload pulls in transitively.\n */\nexport const serverOnlyClientSpecifiers: Array<RegExp | string> = [\n /^node:/,\n new RegExp(`^(${builtinModules.join('|')})(\\\\/|$)`),\n '@payload-config',\n /^@payloadcms\\/next\\/rsc/,\n /^@payloadcms\\/richtext-lexical\\/rsc/,\n /^@payloadcms\\/richtext-slate\\/rsc/,\n '@payloadcms/ui/server',\n /^@payloadcms\\/tanstack-start\\/(layouts|rest|rsc|server)/,\n 'sharp',\n 'busboy',\n 'croner',\n 'pino',\n 'pino-pretty',\n 'prompts',\n 'ws',\n 'undici',\n 'get-tsconfig',\n /^file-type/,\n /^react-dom\\/server/,\n]\n\n/**\n * Allowlist callback for the `tanstackStart` plugin's import-protection. These\n * are the legitimate cross-environment imports in our monorepo that we want\n * to permit even when they appear to cross a server/client boundary.\n */\nexport function onImportProtectionViolation(violation: unknown): boolean | void {\n const info = violation as {\n envType: 'client' | 'server'\n importer: string\n resolved?: string\n }\n\n const allowedClientFileImporters = /\\/richtext-lexical\\/.*\\/exports\\/client\\/|\\/ui\\//\n\n if (\n info.envType === 'server' &&\n info.resolved?.includes('.client.') &&\n allowedClientFileImporters.test(info.importer)\n ) {\n return false\n }\n\n if (info.importer.includes('/richtext-lexical/') && info.importer.includes('/field/Diff/')) {\n return false\n }\n\n if (info.importer.includes('/packages/payload/') || info.importer.includes('/payload/dist/')) {\n return false\n }\n\n if (\n info.importer.includes('@payloadcms/ui') &&\n (info.importer.includes('/exports/rsc/') || info.importer.includes('/rsc/index'))\n ) {\n return false\n }\n\n if (info.envType === 'server' && info.importer.includes('vite-rsc/client-references')) {\n return false\n }\n}\n\nexport const defaultImportProtectionIgnoreImporters: RegExp[] = [/^src\\/importMap\\.js(?:\\?.*)?$/]\n"],"names":["builtinModules","serverOnlyClientSpecifiers","RegExp","join","onImportProtectionViolation","violation","info","allowedClientFileImporters","envType","resolved","includes","test","importer","defaultImportProtectionIgnoreImporters"],"mappings":"AAAA,SAASA,cAAc,QAAQ,cAAa;AAE5C;;;;CAIC,GACD,OAAO,MAAMC,6BAAqD;IAChE;IACA,IAAIC,OAAO,CAAC,EAAE,EAAEF,eAAeG,IAAI,CAAC,KAAK,QAAQ,CAAC;IAClD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;CAIC,GACD,OAAO,SAASC,4BAA4BC,SAAkB;IAC5D,MAAMC,OAAOD;IAMb,MAAME,6BAA6B;IAEnC,IACED,KAAKE,OAAO,KAAK,YACjBF,KAAKG,QAAQ,EAAEC,SAAS,eACxBH,2BAA2BI,IAAI,CAACL,KAAKM,QAAQ,GAC7C;QACA,OAAO;IACT;IAEA,IAAIN,KAAKM,QAAQ,CAACF,QAAQ,CAAC,yBAAyBJ,KAAKM,QAAQ,CAACF,QAAQ,CAAC,iBAAiB;QAC1F,OAAO;IACT;IAEA,IAAIJ,KAAKM,QAAQ,CAACF,QAAQ,CAAC,yBAAyBJ,KAAKM,QAAQ,CAACF,QAAQ,CAAC,mBAAmB;QAC5F,OAAO;IACT;IAEA,IACEJ,KAAKM,QAAQ,CAACF,QAAQ,CAAC,qBACtBJ,CAAAA,KAAKM,QAAQ,CAACF,QAAQ,CAAC,oBAAoBJ,KAAKM,QAAQ,CAACF,QAAQ,CAAC,aAAY,GAC/E;QACA,OAAO;IACT;IAEA,IAAIJ,KAAKE,OAAO,KAAK,YAAYF,KAAKM,QAAQ,CAACF,QAAQ,CAAC,+BAA+B;QACrF,OAAO;IACT;AACF;AAEA,OAAO,MAAMG,yCAAmD;IAAC;CAAgC,CAAA"}
@@ -5,10 +5,16 @@ import rsc from '@vitejs/plugin-rsc';
5
5
  export type WithPayloadOptions = {
6
6
  /** Extra import-protection `ignoreImporters` patterns for the TanStack Start plugin. */
7
7
  additionalIgnoreImporters?: RegExp[];
8
- /** Route id of Payload's admin layout, eager-loaded instead of code-split. Defaults to `'/_payload'`. */
9
- adminRouteId?: string;
10
8
  /** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */
11
9
  clientDenialExcludeFiles?: string[];
10
+ /** Transform server packages in development. Enable when linking Payload source. Defaults to `false`. */
11
+ devBundleServerPackages?: boolean;
12
+ /**
13
+ * Packages added to `ssr.external` on dev serve only (the build bundles them).
14
+ * List CommonJS deps that 500 with `__cjs_module_runner_transform` — the RSC
15
+ * plugin's CJS-to-ESM rewrite breaks on their circular `require`s.
16
+ */
17
+ devServerExternalPackages?: string[];
12
18
  /** Path to the user's `payload.config.ts` (required) */
13
19
  payloadConfigPath: string;
14
20
  /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'` */
@@ -81,17 +87,11 @@ export declare function payloadRscOptions(): NonNullable<Parameters<typeof rsc>[
81
87
  * with `ERR_MODULE_NOT_FOUND` on the first request.
82
88
  */
83
89
  export declare function payloadNitroOptions(): PayloadNitroOptions;
84
- /** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */
90
+ /** Transforms application and workspace source without refreshing installed dependencies. */
85
91
  export declare function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]>;
86
92
  export type PayloadTanstackStartOptionsArgs = {
87
93
  /** Additional import-protection `ignoreImporters` patterns. */
88
94
  additionalIgnoreImporters?: RegExp[];
89
- /**
90
- * Route id of Payload's admin layout route, eager-loaded (not code-split) so it
91
- * hydrates on first paint. It and its children skip splitting; host routes keep
92
- * TanStack's default. Defaults to `'/_payload'` (the `_payload.tsx` convention).
93
- */
94
- adminRouteId?: string;
95
95
  /**
96
96
  * Extra globs exempted from TanStack's `.client.*` SSR denial, on top of the
97
97
  * default node_modules exemption. Needed only when Payload's own `.client.*`
@@ -104,8 +104,8 @@ export type PayloadTanstackStartOptionsArgs = {
104
104
  srcDirectory?: string;
105
105
  };
106
106
  /**
107
- * The `tanstackStart` options Payload's admin requires (import-protection and
108
- * code-splitting). TanStack Start is one-per-app, so a host that already runs it
107
+ * The `tanstackStart` options Payload's admin requires (import protection and
108
+ * route discovery). TanStack Start is one-per-app, so a host that already runs it
109
109
  * should merge these into its single `tanstackStart` call.
110
110
  */
111
111
  export declare function payloadTanstackStartOptions(args?: PayloadTanstackStartOptionsArgs): NonNullable<Parameters<typeof tanstackStart>[0]>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/withPayload/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAwB,UAAU,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAI3F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AACjE,OAAO,SAAS,MAAM,sBAAsB,CAAA;AAC5C,OAAO,GAAG,MAAM,oBAAoB,CAAA;AAyEpC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wFAAwF;IACxF,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;IACpC,yGAAyG;IACzG,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wGAAwG;IACxG,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,wDAAwD;IACxD,iBAAiB,EAAE,MAAM,CAAA;IACzB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,yFAAyF;IACzF,yBAAyB,CAAC,EAAE,OAAO,CAAA;IACnC,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wFAAwF;IACxF,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED,mIAAmI;AACnI,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,wEAAwE;AACxE,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,mBAAmB,CAAA;IAC1B,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACnD,GAAG,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3C,aAAa,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAChE,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,SAAS,CAAA;IACd,qFAAqF;IACrF,aAAa,EAAE,oBAAoB,CAAA;CACpC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,yBAAyB,KAAK,UAAU,CAAA;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,GAAG,kBAAkB,EACrC,OAAO,EAAE,kBAAkB,GAC1B,kBAAkB,CA0HpB;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,mBAAmB,CAEzD;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAElF;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,+DAA+D;IAC/D,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;IACpC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,wFAAwF;IACxF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,GAAE,+BAAoC,GACzC,WAAW,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAwClD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/withPayload/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAwB,UAAU,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAI3F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AACjE,OAAO,SAAS,MAAM,sBAAsB,CAAA;AAC5C,OAAO,GAAG,MAAM,oBAAoB,CAAA;AA0EpC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wFAAwF;IACxF,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;IACpC,wGAAwG;IACxG,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,yGAAyG;IACzG,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;IACpC,wDAAwD;IACxD,iBAAiB,EAAE,MAAM,CAAA;IACzB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,yFAAyF;IACzF,yBAAyB,CAAC,EAAE,OAAO,CAAA;IACnC,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wFAAwF;IACxF,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED,mIAAmI;AACnI,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,wEAAwE;AACxE,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,mBAAmB,CAAA;IAC1B,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACnD,GAAG,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3C,aAAa,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAChE,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,SAAS,CAAA;IACd,qFAAqF;IACrF,aAAa,EAAE,oBAAoB,CAAA;CACpC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,yBAAyB,KAAK,UAAU,CAAA;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,GAAG,kBAAkB,EACrC,OAAO,EAAE,kBAAkB,GAC1B,kBAAkB,CA2IpB;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,mBAAmB,CAEzD;AAED,6FAA6F;AAC7F,wBAAgB,mBAAmB,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAElF;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,+DAA+D;IAC/D,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;IACpC;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,wFAAwF;IACxF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,GAAE,+BAAoC,GACzC,WAAW,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAgClD"}
@@ -5,7 +5,7 @@ import viteReact from '@vitejs/plugin-react';
5
5
  import rsc from '@vitejs/plugin-rsc';
6
6
  import path from 'node:path';
7
7
  import { createLogger, mergeConfig } from 'vite';
8
- import { buildExternalPackages, payloadNoExternalPatterns, ssrExternalPackages } from './config/external.js';
8
+ import { buildExternalPackages, devExternalPackages, payloadNoExternalPatterns, ssrExternalPackages } from './config/external.js';
9
9
  import { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js';
10
10
  import { payloadScssImporters } from './config/scss.js';
11
11
  import { payloadDevConfigReload } from './devConfigReload.js';
@@ -86,7 +86,7 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
86
86
  * )
87
87
  * ```
88
88
  */ export function withPayload(build, options) {
89
- const { additionalIgnoreImporters = [], adminRouteId, clientDenialExcludeFiles = [], payloadConfigPath, routesDirectory = 'app', silenceDependencyWarnings = true, srcDirectory = 'src', vite } = options;
89
+ const { additionalIgnoreImporters = [], clientDenialExcludeFiles = [], devBundleServerPackages = false, devServerExternalPackages = [], payloadConfigPath, routesDirectory = 'app', silenceDependencyWarnings = true, srcDirectory = 'src', vite } = options;
90
90
  return (env)=>{
91
91
  // `pluralize` ships a UMD wrapper that throws when run through Vite's dev SSR
92
92
  // transform, so dev serve keeps it external and lets Node require it.
@@ -106,7 +106,16 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
106
106
  // externalizes the package boundaries (`buildExternalPackages`) and drops
107
107
  // `pluralize` so it bundles — leaving it in `ssr.external` here would win over
108
108
  // `noExternal` and re-emit the bare specifier.
109
- const ssrExternal = isBuild ? buildExternalPackages : ssrExternalPackages;
109
+ // Dev serve also honors `devServerExternalPackages`, the app's own CJS
110
+ // dependencies that break under the RSC plugin's CJS-to-ESM rewrite; the build
111
+ // needs none of it, since Rollup bundles CJS correctly.
112
+ const ssrExternal = isBuild ? buildExternalPackages : [
113
+ ...new Set([
114
+ ...devBundleServerPackages ? [] : devExternalPackages,
115
+ ...devServerExternalPackages,
116
+ ...ssrExternalPackages
117
+ ])
118
+ ];
110
119
  const base = {
111
120
  build: {
112
121
  cssMinify: 'esbuild'
@@ -133,6 +142,7 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
133
142
  }
134
143
  },
135
144
  resolve: {
145
+ external: isBuild ? undefined : ssrExternal,
136
146
  noExternal: noExternalPatterns
137
147
  }
138
148
  },
@@ -143,6 +153,7 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
143
153
  }
144
154
  },
145
155
  resolve: {
156
+ external: isBuild ? undefined : ssrExternal,
146
157
  noExternal: noExternalPatterns
147
158
  }
148
159
  }
@@ -201,7 +212,6 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
201
212
  rsc: payloadRscOptions(),
202
213
  tanstackStart: payloadTanstackStartOptions({
203
214
  additionalIgnoreImporters,
204
- adminRouteId,
205
215
  clientDenialExcludeFiles,
206
216
  routesDirectory,
207
217
  srcDirectory
@@ -240,24 +250,27 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
240
250
  ]
241
251
  };
242
252
  }
243
- /** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */ export function payloadReactOptions() {
253
+ /** Transforms application and workspace source without refreshing installed dependencies. */ export function payloadReactOptions() {
244
254
  return {
245
- exclude: [],
255
+ exclude: /node_modules/,
246
256
  include: /\.[jt]sx?$/
247
257
  };
248
258
  }
249
259
  /**
250
- * The `tanstackStart` options Payload's admin requires (import-protection and
251
- * code-splitting). TanStack Start is one-per-app, so a host that already runs it
260
+ * The `tanstackStart` options Payload's admin requires (import protection and
261
+ * route discovery). TanStack Start is one-per-app, so a host that already runs it
252
262
  * should merge these into its single `tanstackStart` call.
253
263
  */ export function payloadTanstackStartOptions(args = {}) {
254
- const { additionalIgnoreImporters = [], adminRouteId = '/_payload', clientDenialExcludeFiles = [], routesDirectory = 'app', srcDirectory = 'src' } = args;
264
+ const { additionalIgnoreImporters = [], clientDenialExcludeFiles = [], routesDirectory = 'app', srcDirectory = 'src' } = args;
255
265
  return {
256
266
  importProtection: {
257
267
  client: {
258
268
  excludeFiles: [],
259
269
  specifiers: serverOnlyClientSpecifiers
260
270
  },
271
+ exclude: [
272
+ '**/node_modules/**'
273
+ ],
261
274
  ignoreImporters: [
262
275
  ...defaultImportProtectionIgnoreImporters,
263
276
  ...additionalIgnoreImporters
@@ -280,13 +293,6 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
280
293
  }
281
294
  },
282
295
  router: {
283
- codeSplittingOptions: {
284
- // Eager-load only Payload's admin routes so they hydrate on first paint —
285
- // a split admin renders but isn't interactive until its lazy `?tsr-split=`
286
- // chunk lands. Returning `[]` disables splitting for a route; `undefined`
287
- // lets host routes keep TanStack's default per-route splitting.
288
- splitBehavior: ({ routeId })=>routeId === adminRouteId || routeId.startsWith(`${adminRouteId}/`) ? [] : undefined
289
- },
290
296
  // Ignore generated importMap files and colocated `*.functions.ts` modules
291
297
  // (they define `createServerFn`s, not routes).
292
298
  routeFileIgnorePattern: 'importMap\\.(?:d\\.ts|js|server\\.ts)$|\\.functions\\.',