@payloadcms/tanstack-start 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.
- package/dist/adapters/handleServerFunctions.d.ts +2 -1
- package/dist/adapters/handleServerFunctions.d.ts.map +1 -1
- package/dist/adapters/handleServerFunctions.js +12 -4
- package/dist/adapters/handleServerFunctions.js.map +1 -1
- package/dist/adapters/layout/RootProviders/index.d.ts +9 -0
- package/dist/adapters/layout/RootProviders/index.d.ts.map +1 -0
- package/dist/adapters/layout/RootProviders/index.js +21 -0
- package/dist/adapters/layout/RootProviders/index.js.map +1 -0
- package/dist/adapters/layout/index.d.ts +7 -4
- package/dist/adapters/layout/index.d.ts.map +1 -1
- package/dist/adapters/layout/index.js +3 -1
- package/dist/adapters/layout/index.js.map +1 -1
- package/dist/adapters/layout/lazy.d.ts +1 -5
- package/dist/adapters/layout/lazy.d.ts.map +1 -1
- package/dist/adapters/layout/lazy.js +9 -15
- package/dist/adapters/layout/lazy.js.map +1 -1
- package/dist/adapters/layout/outlet.d.ts +4 -0
- package/dist/adapters/layout/outlet.d.ts.map +1 -0
- package/dist/adapters/layout/outlet.js +9 -0
- package/dist/adapters/layout/outlet.js.map +1 -0
- package/dist/adapters/layout/server.d.ts +7 -13
- package/dist/adapters/layout/server.d.ts.map +1 -1
- package/dist/adapters/layout/server.js +18 -16
- package/dist/adapters/layout/server.js.map +1 -1
- package/dist/adapters/router.d.ts.map +1 -1
- package/dist/adapters/router.js +17 -13
- package/dist/adapters/router.js.map +1 -1
- package/dist/adapters/server.d.ts.map +1 -1
- package/dist/adapters/server.js +2 -29
- package/dist/adapters/server.js.map +1 -1
- package/dist/adapters/views/index.d.ts +5 -2
- package/dist/adapters/views/index.d.ts.map +1 -1
- package/dist/adapters/views/index.js +29 -8
- package/dist/adapters/views/index.js.map +1 -1
- package/dist/adapters/views/lazy.d.ts.map +1 -1
- package/dist/adapters/views/lazy.js +5 -4
- package/dist/adapters/views/lazy.js.map +1 -1
- package/dist/adapters/views/server.d.ts +5 -2
- package/dist/adapters/views/server.d.ts.map +1 -1
- package/dist/adapters/views/server.js +12 -3
- package/dist/adapters/views/server.js.map +1 -1
- package/dist/auth/login.js.map +1 -1
- package/dist/exports/client/layout.d.ts +2 -0
- package/dist/exports/client/layout.d.ts.map +1 -0
- package/dist/exports/client/layout.js +4 -0
- package/dist/exports/client/layout.js.map +1 -0
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +1 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/routes.d.ts +2 -0
- package/dist/exports/routes.d.ts.map +1 -0
- package/dist/exports/routes.js +3 -0
- package/dist/exports/routes.js.map +1 -0
- package/dist/exports/server.d.ts +0 -3
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +0 -3
- package/dist/exports/server.js.map +1 -1
- package/dist/routes/rest/handler.server.d.ts +3 -3
- package/dist/routes/rest/handler.server.d.ts.map +1 -1
- package/dist/routes/rest/handler.server.js +4 -7
- package/dist/routes/rest/handler.server.js.map +1 -1
- package/dist/routes/rest/index.d.ts +4 -3
- package/dist/routes/rest/index.d.ts.map +1 -1
- package/dist/routes/rest/index.js +4 -3
- package/dist/routes/rest/index.js.map +1 -1
- package/dist/utilities/devConfigReload.server.js +2 -4
- package/dist/utilities/devConfigReload.server.js.map +1 -1
- package/dist/utilities/serverFunctionClient.d.ts +2 -23
- package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
- package/dist/utilities/serverFunctionClient.js +12 -106
- package/dist/utilities/serverFunctionClient.js.map +1 -1
- package/dist/withPayload/config/external.d.ts +6 -16
- package/dist/withPayload/config/external.d.ts.map +1 -1
- package/dist/withPayload/config/external.js +18 -26
- package/dist/withPayload/config/external.js.map +1 -1
- package/dist/withPayload/importProtection.js +1 -1
- package/dist/withPayload/importProtection.js.map +1 -1
- package/dist/withPayload/index.d.ts +3 -1
- package/dist/withPayload/index.d.ts.map +1 -1
- package/dist/withPayload/index.js +14 -6
- package/dist/withPayload/index.js.map +1 -1
- package/package.json +31 -28
- package/dist/utilities/serializeForRsc.d.ts +0 -26
- package/dist/utilities/serializeForRsc.d.ts.map +0 -1
- package/dist/utilities/serializeForRsc.js +0 -127
- package/dist/utilities/serializeForRsc.js.map +0 -1
- package/dist/utilities/toSerializable.d.ts +0 -11
- package/dist/utilities/toSerializable.d.ts.map +0 -1
- package/dist/utilities/toSerializable.js +0 -127
- package/dist/utilities/toSerializable.js.map +0 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import '../../utilities/devConfigReload.server.js';
|
|
1
2
|
/**
|
|
2
3
|
* Builds the method handlers for the Payload REST/GraphQL catch-all
|
|
3
4
|
* (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
|
|
4
5
|
* import) since the package cannot resolve the consumer's config.
|
|
5
6
|
*
|
|
6
|
-
* Imported from `@payloadcms/tanstack-start/
|
|
7
|
-
* the
|
|
7
|
+
* Imported from `@payloadcms/tanstack-start/routes` so API routes do not load
|
|
8
|
+
* the admin rendering graph from the shared server entrypoint.
|
|
8
9
|
*
|
|
9
10
|
* Spread the result into a literal `server.handlers` key so TanStack Start's
|
|
10
11
|
* client compiler can statically see — and prune — the server-only route:
|
|
11
12
|
*
|
|
12
13
|
* ```ts
|
|
13
|
-
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/
|
|
14
|
+
* import { payloadApiHandlers } from '@payloadcms/tanstack-start/routes'
|
|
14
15
|
*
|
|
15
16
|
* export const Route = createFileRoute('/_payload/api/$')({
|
|
16
17
|
* server: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/routes/rest/index.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\ntype ApiRouteHandler = (ctx: { request: Request }) => Promise<Response>\n\n/**\n * Builds the method handlers for the Payload REST/GraphQL catch-all\n * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`\n * import) since the package cannot resolve the consumer's config.\n *\n * Imported from `@payloadcms/tanstack-start/
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/rest/index.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport '../../utilities/devConfigReload.server.js'\n\ntype ApiRouteHandler = (ctx: { request: Request }) => Promise<Response>\n\n/**\n * Builds the method handlers for the Payload REST/GraphQL catch-all\n * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`\n * import) since the package cannot resolve the consumer's config.\n *\n * Imported from `@payloadcms/tanstack-start/routes` so API routes do not load\n * the admin rendering graph from the shared server entrypoint.\n *\n * Spread the result into a literal `server.handlers` key so TanStack Start's\n * client compiler can statically see — and prune — the server-only route:\n *\n * ```ts\n * import { payloadApiHandlers } from '@payloadcms/tanstack-start/routes'\n *\n * export const Route = createFileRoute('/_payload/api/$')({\n * server: {\n * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),\n * },\n * })\n * ```\n *\n * The compiler only strips a literal `server:` key from a route-options object\n * expression; wrapping the whole options object in a factory call hides the\n * key, leaking the config graph into the client bundle.\n */\nexport function payloadApiHandlers({\n getConfig,\n}: {\n getConfig: () => Promise<SanitizedConfig>\n}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler> {\n const handler: ApiRouteHandler = async ({ request }) => {\n const { handleAPIRoute } = await import('./handler.server.js')\n return handleAPIRoute({ config: await getConfig(), request })\n }\n\n return {\n DELETE: handler,\n GET: handler,\n OPTIONS: handler,\n PATCH: handler,\n POST: handler,\n PUT: handler,\n }\n}\n"],"names":["payloadApiHandlers","getConfig","handler","request","handleAPIRoute","config","DELETE","GET","OPTIONS","PATCH","POST","PUT"],"mappings":"AAEA,OAAO,4CAA2C;AAIlD;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASA,mBAAmB,EACjCC,SAAS,EAGV;IACC,MAAMC,UAA2B,OAAO,EAAEC,OAAO,EAAE;QACjD,MAAM,EAAEC,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC;QACxC,OAAOA,eAAe;YAAEC,QAAQ,MAAMJ;YAAaE;QAAQ;IAC7D;IAEA,OAAO;QACLG,QAAQJ;QACRK,KAAKL;QACLM,SAASN;QACTO,OAAOP;QACPQ,MAAMR;QACNS,KAAKT;IACP;AACF"}
|
|
@@ -4,10 +4,8 @@ import { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js';
|
|
|
4
4
|
* Subscribes the Payload instance to the config-changed event that the
|
|
5
5
|
* `payload:dev-config-reload` Vite plugin broadcasts.
|
|
6
6
|
*
|
|
7
|
-
* Imported
|
|
8
|
-
*
|
|
9
|
-
* be built. Registration is module-scoped on both ends: this runs inside the
|
|
10
|
-
* app's server graph and so resolves the same copy of `payload` that
|
|
7
|
+
* Imported by the admin context and REST route module, so the strategy is registered before an instance can be built or a config-change event can arrive after a program reload.
|
|
8
|
+
* Registration is module-scoped on both ends: this runs inside the app's server graph and so resolves the same copy of `payload` that
|
|
11
9
|
* `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers
|
|
12
10
|
* its own listener against its own copy.
|
|
13
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/devConfigReload.server.ts"],"sourcesContent":["import { registerDevReloadStrategy } from 'payload'\n\nimport { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js'\n\n/**\n * Subscribes the Payload instance to the config-changed event that the\n * `payload:dev-config-reload` Vite plugin broadcasts.\n *\n * Imported
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/devConfigReload.server.ts"],"sourcesContent":["import { registerDevReloadStrategy } from 'payload'\n\nimport { PAYLOAD_CONFIG_CHANGED_EVENT } from './devConfigReloadEvent.js'\n\n/**\n * Subscribes the Payload instance to the config-changed event that the\n * `payload:dev-config-reload` Vite plugin broadcasts.\n *\n * Imported by the admin context and REST route module, so the strategy is registered before an instance can be built or a config-change event can arrive after a program reload.\n * Registration is module-scoped on both ends: this runs inside the app's server graph and so resolves the same copy of `payload` that\n * `getPayload` is called on, and each Vite environment (`ssr`, `rsc`) registers\n * its own listener against its own copy.\n *\n * Vite re-evaluates this module on a program reload, which drops the listeners\n * the previous instance had collected. `getPayload` reconnects on its next call\n * because the registered strategy is a new object - see `connectDevReload`.\n *\n * `import.meta.hot` is only defined during dev serve, so this is inert in a\n * production build.\n */\nconst hot = (import.meta as unknown as { hot?: ViteHotContext }).hot\n\nif (hot) {\n registerDevReloadStrategy(createConfigChangedStrategy({ hot }))\n}\n\n/**\n * Builds a dev reload strategy that forwards the config-changed event to every\n * connected instance.\n *\n * After a program reload, the first request to re-import this module replaces\n * the old listener with a new one, but the cached Payload instance only connects\n * to it on its next `getPayload` call - and a request such as a frontend page\n * render may never make one. An event that lands in that gap has no one to\n * notify, so it is held and replayed to the next connection instead of being\n * dropped - which would otherwise leave the instance serving the old config\n * indefinitely.\n */\nfunction createConfigChangedStrategy({ hot }: { hot: ViteHotContext }): {\n connect: (onReload: () => void) => () => void\n} {\n const listeners = new Set<() => void>()\n let hasPendingReload = false\n\n hot.on(PAYLOAD_CONFIG_CHANGED_EVENT, () => {\n if (listeners.size === 0) {\n hasPendingReload = true\n return\n }\n\n for (const onReload of listeners) {\n onReload()\n }\n })\n\n return {\n connect: (onReload) => {\n listeners.add(onReload)\n\n if (hasPendingReload) {\n hasPendingReload = false\n onReload()\n }\n\n return () => {\n listeners.delete(onReload)\n }\n },\n }\n}\n\ntype ViteHotContext = {\n on: (event: string, cb: () => void) => void\n}\n"],"names":["registerDevReloadStrategy","PAYLOAD_CONFIG_CHANGED_EVENT","hot","createConfigChangedStrategy","listeners","Set","hasPendingReload","on","size","onReload","connect","add","delete"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,UAAS;AAEnD,SAASC,4BAA4B,QAAQ,4BAA2B;AAExE;;;;;;;;;;;;;;;CAeC,GACD,MAAMC,MAAM,AAAC,YAAoDA,GAAG;AAEpE,IAAIA,KAAK;IACPF,0BAA0BG,4BAA4B;QAAED;IAAI;AAC9D;AAEA;;;;;;;;;;;CAWC,GACD,SAASC,4BAA4B,EAAED,GAAG,EAA2B;IAGnE,MAAME,YAAY,IAAIC;IACtB,IAAIC,mBAAmB;IAEvBJ,IAAIK,EAAE,CAACN,8BAA8B;QACnC,IAAIG,UAAUI,IAAI,KAAK,GAAG;YACxBF,mBAAmB;YACnB;QACF;QAEA,KAAK,MAAMG,YAAYL,UAAW;YAChCK;QACF;IACF;IAEA,OAAO;QACLC,SAAS,CAACD;YACRL,UAAUO,GAAG,CAACF;YAEd,IAAIH,kBAAkB;gBACpBA,mBAAmB;gBACnBG;YACF;YAEA,OAAO;gBACLL,UAAUQ,MAAM,CAACH;YACnB;QACF;IACF;AACF"}
|
|
@@ -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<
|
|
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;
|
|
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
|
-
|
|
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
|
|
20
|
-
|
|
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
|
-
|
|
71
|
-
|
|
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
|
-
|
|
83
|
-
|
|
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
|
-
|
|
92
|
-
return
|
|
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\
|
|
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"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SSR/RSC externalization config used by `withPayload`. Kept separate from the
|
|
3
|
-
* client optimizer config (`./optimizeDeps.ts`) so each concern stays small.
|
|
4
|
-
*/
|
|
5
1
|
/**
|
|
6
2
|
* Packages externalized during dev serve (`ssr.external`). Node's loader resolves
|
|
7
3
|
* their CJS/UMD directly; letting Vite's dev SSR transform touch them can break
|
|
@@ -25,19 +21,13 @@ export declare const ssrExternalPackages: string[];
|
|
|
25
21
|
* storage leaves don't, since their adapters are already `noExternal`.
|
|
26
22
|
*/
|
|
27
23
|
export declare const buildBundledPackages: string[];
|
|
24
|
+
/** Server-only package boundaries loaded directly by Node in development and production. */
|
|
25
|
+
export declare const serverExternalPackages: string[];
|
|
26
|
+
/** Additional installed packages that can bypass Vite's development server transforms. */
|
|
27
|
+
export declare const devExternalPackages: string[];
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
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.
|
|
29
|
+
* Externalizes package boundaries so packages resolve their own transitive dependencies under pnpm.
|
|
30
|
+
* Leaves that must bundle in production are excluded; see {@link buildBundledPackages}.
|
|
41
31
|
*/
|
|
42
32
|
export declare const buildExternalPackages: string[];
|
|
43
33
|
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":"
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../../src/withPayload/config/external.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EAwBvC,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,EAOvC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAGzC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
+
import { devServerExternalPackages as devServerExternalPayloadPackages, serverExternalPackages as serverExternalPayloadPackages } from 'payload/build-config';
|
|
1
2
|
/**
|
|
2
|
-
* SSR/RSC externalization config used by `withPayload`. Kept separate from the
|
|
3
|
-
* client optimizer config (`./optimizeDeps.ts`) so each concern stays small.
|
|
4
|
-
*/ /**
|
|
5
3
|
* Packages externalized during dev serve (`ssr.external`). Node's loader resolves
|
|
6
4
|
* their CJS/UMD directly; letting Vite's dev SSR transform touch them can break
|
|
7
5
|
* fragile UMD wrappers (e.g. `pluralize`, whose `this`-based global assignment
|
|
@@ -13,15 +11,9 @@
|
|
|
13
11
|
*/ export const ssrExternalPackages = [
|
|
14
12
|
'zod',
|
|
15
13
|
'fast-uri',
|
|
16
|
-
|
|
17
|
-
'drizzle-kit/api',
|
|
14
|
+
...serverExternalPayloadPackages,
|
|
18
15
|
'drizzle-orm',
|
|
19
|
-
'sharp',
|
|
20
|
-
'require-in-the-middle',
|
|
21
|
-
'json-schema-to-typescript',
|
|
22
|
-
'pino',
|
|
23
16
|
'pino-pretty',
|
|
24
|
-
'graphql',
|
|
25
17
|
'nodemailer',
|
|
26
18
|
'aws4',
|
|
27
19
|
'pluralize',
|
|
@@ -37,7 +29,6 @@
|
|
|
37
29
|
'pg-cloudflare',
|
|
38
30
|
// SQLite (`@payloadcms/db-sqlite`)
|
|
39
31
|
'better-sqlite3',
|
|
40
|
-
'libsql',
|
|
41
32
|
// Mongo (`@payloadcms/db-mongodb`)
|
|
42
33
|
'mongodb',
|
|
43
34
|
'mongoose'
|
|
@@ -60,20 +51,7 @@
|
|
|
60
51
|
'@azure/storage-blob',
|
|
61
52
|
'@google-cloud/storage'
|
|
62
53
|
];
|
|
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 = [
|
|
54
|
+
/** Server-only package boundaries loaded directly by Node in development and production. */ export const serverExternalPackages = [
|
|
77
55
|
'payload',
|
|
78
56
|
'payload/node',
|
|
79
57
|
'@payloadcms/drizzle',
|
|
@@ -81,7 +59,21 @@
|
|
|
81
59
|
'@payloadcms/db-postgres',
|
|
82
60
|
'@payloadcms/db-vercel-postgres',
|
|
83
61
|
'@payloadcms/db-sqlite',
|
|
84
|
-
'@payloadcms/db-d1-sqlite'
|
|
62
|
+
'@payloadcms/db-d1-sqlite'
|
|
63
|
+
];
|
|
64
|
+
/** Additional installed packages that can bypass Vite's development server transforms. */ export const devExternalPackages = [
|
|
65
|
+
...new Set([
|
|
66
|
+
// Vite otherwise transforms date-fns' full module graph during SSR.
|
|
67
|
+
'date-fns',
|
|
68
|
+
...devServerExternalPayloadPackages,
|
|
69
|
+
...serverExternalPackages
|
|
70
|
+
])
|
|
71
|
+
];
|
|
72
|
+
/**
|
|
73
|
+
* Externalizes package boundaries so packages resolve their own transitive dependencies under pnpm.
|
|
74
|
+
* Leaves that must bundle in production are excluded; see {@link buildBundledPackages}.
|
|
75
|
+
*/ export const buildExternalPackages = [
|
|
76
|
+
...serverExternalPackages,
|
|
85
77
|
...ssrExternalPackages.filter((pkg)=>!buildBundledPackages.includes(pkg))
|
|
86
78
|
];
|
|
87
79
|
export const payloadNoExternalPatterns = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/withPayload/config/external.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/withPayload/config/external.ts"],"sourcesContent":["import {\n devServerExternalPackages as devServerExternalPayloadPackages,\n serverExternalPackages as serverExternalPayloadPackages,\n} from 'payload/build-config'\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 ...serverExternalPayloadPackages,\n 'drizzle-orm',\n 'pino-pretty',\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 // 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 ...new Set([\n // Vite otherwise transforms date-fns' full module graph during SSR.\n 'date-fns',\n ...devServerExternalPayloadPackages,\n ...serverExternalPackages,\n ]),\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":["devServerExternalPackages","devServerExternalPayloadPackages","serverExternalPackages","serverExternalPayloadPackages","ssrExternalPackages","buildBundledPackages","devExternalPackages","Set","buildExternalPackages","filter","pkg","includes","payloadNoExternalPatterns"],"mappings":"AAAA,SACEA,6BAA6BC,gCAAgC,EAC7DC,0BAA0BC,6BAA6B,QAClD,uBAAsB;AAE7B;;;;;;;;;CASC,GACD,OAAO,MAAMC,sBAAgC;IAC3C;IACA;OACGD;IACH;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,8EAA8E;IAC9E,yEAAyE;IACzE;IACA;IACA;IACA,mCAAmC;IACnC;IACA,mCAAmC;IACnC;IACA;CACD,CAAA;AAED;;;;;;;;;;CAUC,GACD,OAAO,MAAME,uBAAiC;IAC5C;IACA,qDAAqD;IACrD;IACA;IACA;IACA;CACD,CAAA;AAED,0FAA0F,GAC1F,OAAO,MAAMH,yBAAmC;IAC9C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED,wFAAwF,GACxF,OAAO,MAAMI,sBAAgC;OACxC,IAAIC,IAAI;QACT,oEAAoE;QACpE;WACGN;WACAC;KACJ;CACF,CAAA;AAED;;;CAGC,GACD,OAAO,MAAMM,wBAAkC;OAC1CN;OACAE,oBAAoBK,MAAM,CAAC,CAACC,MAAQ,CAACL,qBAAqBM,QAAQ,CAACD;CACvE,CAAA;AAED,OAAO,MAAME,4BAAoD;IAC/D;IACA;IACA;IACA;IACA;IACA;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|routes|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|routes|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"}
|
|
@@ -7,6 +7,8 @@ export type WithPayloadOptions = {
|
|
|
7
7
|
additionalIgnoreImporters?: RegExp[];
|
|
8
8
|
/** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */
|
|
9
9
|
clientDenialExcludeFiles?: string[];
|
|
10
|
+
/** Transform server packages in development. Enable when linking Payload source. Defaults to `false`. */
|
|
11
|
+
devBundleServerPackages?: boolean;
|
|
10
12
|
/**
|
|
11
13
|
* Packages added to `ssr.external` on dev serve only (the build bundles them).
|
|
12
14
|
* List CommonJS deps that 500 with `__cjs_module_runner_transform` — the RSC
|
|
@@ -85,7 +87,7 @@ export declare function payloadRscOptions(): NonNullable<Parameters<typeof rsc>[
|
|
|
85
87
|
* with `ERR_MODULE_NOT_FOUND` on the first request.
|
|
86
88
|
*/
|
|
87
89
|
export declare function payloadNitroOptions(): PayloadNitroOptions;
|
|
88
|
-
/**
|
|
90
|
+
/** Transforms application and workspace source without refreshing installed dependencies. */
|
|
89
91
|
export declare function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]>;
|
|
90
92
|
export type PayloadTanstackStartOptionsArgs = {
|
|
91
93
|
/** Additional import-protection `ignoreImporters` patterns. */
|
|
@@ -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;
|
|
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 = [], clientDenialExcludeFiles = [], devServerExternalPackages = [], 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.
|
|
@@ -110,8 +110,11 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
110
110
|
// dependencies that break under the RSC plugin's CJS-to-ESM rewrite; the build
|
|
111
111
|
// needs none of it, since Rollup bundles CJS correctly.
|
|
112
112
|
const ssrExternal = isBuild ? buildExternalPackages : [
|
|
113
|
-
...
|
|
114
|
-
|
|
113
|
+
...new Set([
|
|
114
|
+
...devBundleServerPackages ? [] : devExternalPackages,
|
|
115
|
+
...devServerExternalPackages,
|
|
116
|
+
...ssrExternalPackages
|
|
117
|
+
])
|
|
115
118
|
];
|
|
116
119
|
const base = {
|
|
117
120
|
build: {
|
|
@@ -139,6 +142,7 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
139
142
|
}
|
|
140
143
|
},
|
|
141
144
|
resolve: {
|
|
145
|
+
external: isBuild ? undefined : ssrExternal,
|
|
142
146
|
noExternal: noExternalPatterns
|
|
143
147
|
}
|
|
144
148
|
},
|
|
@@ -149,6 +153,7 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
149
153
|
}
|
|
150
154
|
},
|
|
151
155
|
resolve: {
|
|
156
|
+
external: isBuild ? undefined : ssrExternal,
|
|
152
157
|
noExternal: noExternalPatterns
|
|
153
158
|
}
|
|
154
159
|
}
|
|
@@ -245,9 +250,9 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
245
250
|
]
|
|
246
251
|
};
|
|
247
252
|
}
|
|
248
|
-
/**
|
|
253
|
+
/** Transforms application and workspace source without refreshing installed dependencies. */ export function payloadReactOptions() {
|
|
249
254
|
return {
|
|
250
|
-
exclude:
|
|
255
|
+
exclude: /node_modules/,
|
|
251
256
|
include: /\.[jt]sx?$/
|
|
252
257
|
};
|
|
253
258
|
}
|
|
@@ -263,6 +268,9 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
263
268
|
excludeFiles: [],
|
|
264
269
|
specifiers: serverOnlyClientSpecifiers
|
|
265
270
|
},
|
|
271
|
+
exclude: [
|
|
272
|
+
'**/node_modules/**'
|
|
273
|
+
],
|
|
266
274
|
ignoreImporters: [
|
|
267
275
|
...defaultImportProtectionIgnoreImporters,
|
|
268
276
|
...additionalIgnoreImporters
|