@payloadcms/tanstack-start 4.0.0-internal.e7d4ebc → 4.0.0-internal.f05c47f
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/auth/login.d.ts +3 -16
- package/dist/auth/login.d.ts.map +1 -1
- package/dist/auth/login.js +6 -46
- package/dist/auth/login.js.map +1 -1
- package/dist/auth/logout.d.ts +2 -5
- package/dist/auth/logout.d.ts.map +1 -1
- package/dist/auth/logout.js +6 -47
- package/dist/auth/logout.js.map +1 -1
- package/dist/auth/refresh.d.ts +2 -4
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js +6 -49
- package/dist/auth/refresh.js.map +1 -1
- package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
- package/dist/elements/RouterAdapter/index.js +17 -3
- package/dist/elements/RouterAdapter/index.js.map +1 -1
- package/dist/exports/client.d.ts +0 -2
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +0 -2
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/layouts.d.ts +2 -4
- package/dist/exports/layouts.d.ts.map +1 -1
- package/dist/exports/layouts.js +0 -1
- package/dist/exports/layouts.js.map +1 -1
- package/dist/exports/rsc.browser.d.ts +4 -1
- package/dist/exports/rsc.browser.d.ts.map +1 -1
- package/dist/exports/rsc.browser.js +4 -1
- package/dist/exports/rsc.browser.js.map +1 -1
- package/dist/exports/rsc.d.ts +0 -1
- package/dist/exports/rsc.d.ts.map +1 -1
- package/dist/exports/rsc.js +0 -1
- package/dist/exports/rsc.js.map +1 -1
- package/dist/exports/server.d.ts +1 -2
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +0 -1
- package/dist/exports/server.js.map +1 -1
- package/dist/layouts/Root/getLayoutData.d.ts +24 -2
- package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
- package/dist/layouts/Root/getLayoutData.js +6 -0
- package/dist/layouts/Root/getLayoutData.js.map +1 -1
- package/dist/routes/adminRoutes.d.ts +10 -13
- package/dist/routes/adminRoutes.d.ts.map +1 -1
- package/dist/routes/adminRoutes.js +49 -39
- package/dist/routes/adminRoutes.js.map +1 -1
- package/dist/routes/layoutRoute.d.ts +4 -3
- package/dist/routes/layoutRoute.d.ts.map +1 -1
- package/dist/routes/layoutRoute.js +1 -0
- package/dist/routes/layoutRoute.js.map +1 -1
- package/dist/utilities/devConfigReload.server.d.ts +2 -0
- package/dist/utilities/devConfigReload.server.d.ts.map +1 -0
- package/dist/utilities/devConfigReload.server.js +38 -0
- package/dist/utilities/devConfigReload.server.js.map +1 -0
- package/dist/utilities/devConfigReloadEvent.d.ts +9 -0
- package/dist/utilities/devConfigReloadEvent.d.ts.map +1 -0
- package/dist/utilities/devConfigReloadEvent.js +9 -0
- package/dist/utilities/devConfigReloadEvent.js.map +1 -0
- package/dist/utilities/getRequestLocale.d.ts.map +1 -1
- package/dist/utilities/getRequestLocale.js +1 -2
- package/dist/utilities/getRequestLocale.js.map +1 -1
- package/dist/utilities/initReq.server.d.ts +1 -0
- package/dist/utilities/initReq.server.d.ts.map +1 -1
- package/dist/utilities/initReq.server.js +3 -0
- package/dist/utilities/initReq.server.js.map +1 -1
- package/dist/utilities/loadAdminPage.d.ts +5 -2
- package/dist/utilities/loadAdminPage.d.ts.map +1 -1
- package/dist/utilities/loadAdminPage.js +2 -11
- package/dist/utilities/loadAdminPage.js.map +1 -1
- package/dist/utilities/loadLayoutData.d.ts +3 -1
- package/dist/utilities/loadLayoutData.d.ts.map +1 -1
- package/dist/utilities/loadLayoutData.js +2 -3
- package/dist/utilities/loadLayoutData.js.map +1 -1
- package/dist/utilities/toSerializable.d.ts +9 -0
- package/dist/utilities/toSerializable.d.ts.map +1 -1
- package/dist/utilities/toSerializable.js +13 -2
- package/dist/utilities/toSerializable.js.map +1 -1
- package/dist/withPayload/config/external.d.ts +16 -8
- package/dist/withPayload/config/external.d.ts.map +1 -1
- package/dist/withPayload/config/external.js +23 -9
- package/dist/withPayload/config/external.js.map +1 -1
- package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -1
- package/dist/withPayload/config/optimizeDeps.js +7 -3
- package/dist/withPayload/config/optimizeDeps.js.map +1 -1
- package/dist/withPayload/devConfigReload.d.ts +14 -0
- package/dist/withPayload/devConfigReload.d.ts.map +1 -0
- package/dist/withPayload/devConfigReload.js +84 -0
- package/dist/withPayload/devConfigReload.js.map +1 -0
- package/dist/withPayload/importProtection.d.ts.map +1 -1
- package/dist/withPayload/importProtection.js +2 -2
- package/dist/withPayload/importProtection.js.map +1 -1
- package/dist/withPayload/index.d.ts +13 -0
- package/dist/withPayload/index.d.ts.map +1 -1
- package/dist/withPayload/index.js +28 -3
- package/dist/withPayload/index.js.map +1 -1
- package/dist/withPayload/workarounds/stripDistStyleImports.js +1 -1
- package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -1
- package/package.json +8 -7
- package/dist/elements/DocumentHeaderClient/index.d.ts +0 -16
- package/dist/elements/DocumentHeaderClient/index.d.ts.map +0 -1
- package/dist/elements/DocumentHeaderClient/index.js +0 -116
- package/dist/elements/DocumentHeaderClient/index.js.map +0 -1
- package/dist/elements/RenderComponent/index.d.ts +0 -10
- package/dist/elements/RenderComponent/index.d.ts.map +0 -1
- package/dist/elements/RenderComponent/index.js +0 -12
- package/dist/elements/RenderComponent/index.js.map +0 -1
- package/dist/layouts/Root/index.d.ts +0 -32
- package/dist/layouts/Root/index.d.ts.map +0 -1
- package/dist/layouts/Root/index.js +0 -53
- package/dist/layouts/Root/index.js.map +0 -1
- package/dist/rsc/renderPayloadRSC.d.ts +0 -6
- package/dist/rsc/renderPayloadRSC.d.ts.map +0 -1
- package/dist/rsc/renderPayloadRSC.js +0 -6
- package/dist/rsc/renderPayloadRSC.js.map +0 -1
- package/dist/utilities/devReloadStrategy.d.ts +0 -10
- package/dist/utilities/devReloadStrategy.d.ts.map +0 -1
- package/dist/utilities/devReloadStrategy.js +0 -27
- package/dist/utilities/devReloadStrategy.js.map +0 -1
- package/dist/utilities/getExistingAuthToken.d.ts +0 -7
- package/dist/utilities/getExistingAuthToken.d.ts.map +0 -1
- package/dist/utilities/getExistingAuthToken.js +0 -18
- package/dist/utilities/getExistingAuthToken.js.map +0 -1
- package/dist/utilities/getPreferences.d.ts +0 -10
- package/dist/utilities/getPreferences.d.ts.map +0 -1
- package/dist/utilities/getPreferences.js +0 -33
- package/dist/utilities/getPreferences.js.map +0 -1
- package/dist/utilities/importMap.server.d.ts +0 -8
- package/dist/utilities/importMap.server.d.ts.map +0 -1
- package/dist/utilities/importMap.server.js +0 -11
- package/dist/utilities/importMap.server.js.map +0 -1
- package/dist/utilities/setPayloadAuthCookie.d.ts +0 -9
- package/dist/utilities/setPayloadAuthCookie.d.ts.map +0 -1
- package/dist/utilities/setPayloadAuthCookie.js +0 -31
- package/dist/utilities/setPayloadAuthCookie.js.map +0 -1
|
@@ -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|rsc|server)/,
|
|
15
15
|
'sharp',
|
|
16
16
|
'busboy',
|
|
17
17
|
'croner',
|
|
@@ -30,7 +30,7 @@ import { builtinModules } from 'node:module';
|
|
|
30
30
|
* to permit even when they appear to cross a server/client boundary.
|
|
31
31
|
*/ export function onImportProtectionViolation(violation) {
|
|
32
32
|
const info = violation;
|
|
33
|
-
const allowedClientFileImporters = /\/richtext-lexical\/.*\/exports\/client\/|\/
|
|
33
|
+
const allowedClientFileImporters = /\/richtext-lexical\/.*\/exports\/client\/|\/ui\//;
|
|
34
34
|
if (info.envType === 'server' && info.resolved?.includes('.client.') && allowedClientFileImporters.test(info.importer)) {
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
@@ -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
|
|
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"}
|
|
@@ -20,8 +20,13 @@ export type WithPayloadOptions = {
|
|
|
20
20
|
/** Extra Vite config deep-merged over the Payload defaults. Ignored in `build` mode. */
|
|
21
21
|
vite?: UserConfig;
|
|
22
22
|
};
|
|
23
|
+
/** The `nitro()` options Payload's server build requires. Typed structurally — `nitro` is the host's dependency, not Payload's. */
|
|
24
|
+
export type PayloadNitroOptions = {
|
|
25
|
+
traceDeps: string[];
|
|
26
|
+
};
|
|
23
27
|
/** The options Payload's admin requires for each third-party plugin. */
|
|
24
28
|
export type PayloadPluginOptions = {
|
|
29
|
+
nitro: PayloadNitroOptions;
|
|
25
30
|
react: NonNullable<Parameters<typeof viteReact>[0]>;
|
|
26
31
|
rsc: NonNullable<Parameters<typeof rsc>[0]>;
|
|
27
32
|
tanstackStart: NonNullable<Parameters<typeof tanstackStart>[0]>;
|
|
@@ -58,6 +63,7 @@ export type WithPayloadBuilder = (context: WithPayloadBuilderContext) => UserCon
|
|
|
58
63
|
* rsc(pluginOptions.rsc),
|
|
59
64
|
* tanstackStart(pluginOptions.tanstackStart),
|
|
60
65
|
* viteReact(pluginOptions.react),
|
|
66
|
+
* nitro(pluginOptions.nitro), // only if the app deploys through Nitro
|
|
61
67
|
* ],
|
|
62
68
|
* // ...other config options
|
|
63
69
|
* }),
|
|
@@ -68,6 +74,13 @@ export type WithPayloadBuilder = (context: WithPayloadBuilderContext) => UserCon
|
|
|
68
74
|
export declare function withPayload(build: undefined | WithPayloadBuilder, options: WithPayloadOptions): UserConfigFnObject;
|
|
69
75
|
/** `@vitejs/plugin-rsc` options for Payload: `serverHandler: false` (TanStack owns the handler). */
|
|
70
76
|
export declare function payloadRscOptions(): NonNullable<Parameters<typeof rsc>[0]>;
|
|
77
|
+
/**
|
|
78
|
+
* `nitro/vite` options for Payload's server build. `tslib*` full-traces `tslib`
|
|
79
|
+
* so an externalized dep's `tslib/modules/index.js` import (its `import.node`
|
|
80
|
+
* export condition) ships — otherwise the build is green and the server 500s
|
|
81
|
+
* with `ERR_MODULE_NOT_FOUND` on the first request.
|
|
82
|
+
*/
|
|
83
|
+
export declare function payloadNitroOptions(): PayloadNitroOptions;
|
|
71
84
|
/** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */
|
|
72
85
|
export declare function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]>;
|
|
73
86
|
export type PayloadTanstackStartOptionsArgs = {
|
|
@@ -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;AAyEpC,MAAM,MAAM,kBAAkB,GA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B,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"}
|
|
@@ -8,6 +8,7 @@ import { createLogger, mergeConfig } from 'vite';
|
|
|
8
8
|
import { buildExternalPackages, payloadNoExternalPatterns, ssrExternalPackages } from './config/external.js';
|
|
9
9
|
import { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js';
|
|
10
10
|
import { payloadScssImporters } from './config/scss.js';
|
|
11
|
+
import { payloadDevConfigReload } from './devConfigReload.js';
|
|
11
12
|
import { defaultImportProtectionIgnoreImporters, onImportProtectionViolation, serverOnlyClientSpecifiers } from './importProtection.js';
|
|
12
13
|
import { clientModuleResolution } from './workarounds/clientModuleResolution.js';
|
|
13
14
|
import { payloadDevTransforms } from './workarounds/devTransforms.js';
|
|
@@ -19,9 +20,16 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
19
20
|
* Vite dependency warnings Payload consumers can't act on: third-party packages
|
|
20
21
|
* ship sourcemaps whose original sources aren't published, so Vite warns on
|
|
21
22
|
* every one. Suppressed by default (see `silenceDependencyWarnings`).
|
|
23
|
+
*
|
|
24
|
+
* `Failed to load source map` covers deps that ship a `sourceMappingURL` comment
|
|
25
|
+
* without the `.map` file it points at (e.g. `undici`'s `lib/llhttp/*.js`, pulled
|
|
26
|
+
* in via `@vercel/blob`). Vite appends the underlying `ENOENT` stack to that one,
|
|
27
|
+
* so each occurrence is a ~10-line block that buries real log output.
|
|
22
28
|
*/ const suppressibleWarningPatterns = [
|
|
23
29
|
'points to missing source files',
|
|
24
|
-
'Sourcemap for'
|
|
30
|
+
'Sourcemap for',
|
|
31
|
+
'Failed to load source map',
|
|
32
|
+
'references a map file outside its package'
|
|
25
33
|
];
|
|
26
34
|
/**
|
|
27
35
|
* Wraps a Vite logger so warnings matching {@link suppressibleWarningPatterns}
|
|
@@ -70,6 +78,7 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
70
78
|
* rsc(pluginOptions.rsc),
|
|
71
79
|
* tanstackStart(pluginOptions.tanstackStart),
|
|
72
80
|
* viteReact(pluginOptions.react),
|
|
81
|
+
* nitro(pluginOptions.nitro), // only if the app deploys through Nitro
|
|
73
82
|
* ],
|
|
74
83
|
* // ...other config options
|
|
75
84
|
* }),
|
|
@@ -151,7 +160,10 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
151
160
|
ssrStripDistStyleImports(),
|
|
152
161
|
reactDomServerInRsc(),
|
|
153
162
|
stubPrettierInClient(),
|
|
154
|
-
payloadDevTransforms()
|
|
163
|
+
payloadDevTransforms(),
|
|
164
|
+
payloadDevConfigReload({
|
|
165
|
+
payloadConfigPath
|
|
166
|
+
})
|
|
155
167
|
],
|
|
156
168
|
resolve: {
|
|
157
169
|
alias: [
|
|
@@ -184,6 +196,7 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
184
196
|
}
|
|
185
197
|
};
|
|
186
198
|
const pluginOptions = {
|
|
199
|
+
nitro: payloadNitroOptions(),
|
|
187
200
|
react: payloadReactOptions(),
|
|
188
201
|
rsc: payloadRscOptions(),
|
|
189
202
|
tanstackStart: payloadTanstackStartOptions({
|
|
@@ -215,6 +228,18 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
215
228
|
serverHandler: false
|
|
216
229
|
};
|
|
217
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* `nitro/vite` options for Payload's server build. `tslib*` full-traces `tslib`
|
|
233
|
+
* so an externalized dep's `tslib/modules/index.js` import (its `import.node`
|
|
234
|
+
* export condition) ships — otherwise the build is green and the server 500s
|
|
235
|
+
* with `ERR_MODULE_NOT_FOUND` on the first request.
|
|
236
|
+
*/ export function payloadNitroOptions() {
|
|
237
|
+
return {
|
|
238
|
+
traceDeps: [
|
|
239
|
+
'tslib*'
|
|
240
|
+
]
|
|
241
|
+
};
|
|
242
|
+
}
|
|
218
243
|
/** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */ export function payloadReactOptions() {
|
|
219
244
|
return {
|
|
220
245
|
exclude: [],
|
|
@@ -264,7 +289,7 @@ import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
|
264
289
|
},
|
|
265
290
|
// Ignore generated importMap files and colocated `*.functions.ts` modules
|
|
266
291
|
// (they define `createServerFn`s, not routes).
|
|
267
|
-
routeFileIgnorePattern: 'importMap\\.(?:js|server\\.ts)$|\\.functions\\.',
|
|
292
|
+
routeFileIgnorePattern: 'importMap\\.(?:d\\.ts|js|server\\.ts)$|\\.functions\\.',
|
|
268
293
|
routesDirectory
|
|
269
294
|
},
|
|
270
295
|
rsc: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/withPayload/index.ts"],"sourcesContent":["import type { ConfigEnv, Logger, PluginOption, UserConfig, UserConfigFnObject } from 'vite'\n\n// Optional peers, not deps: `plugin-rsc` is a singleton, so bundling our own copy\n// alongside the host's would load two instances and crash.\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite'\nimport viteReact from '@vitejs/plugin-react'\nimport rsc from '@vitejs/plugin-rsc'\nimport path from 'node:path'\nimport { createLogger, mergeConfig } from 'vite'\n\nimport {\n buildExternalPackages,\n payloadNoExternalPatterns,\n ssrExternalPackages,\n} from './config/external.js'\nimport { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js'\nimport { payloadScssImporters } from './config/scss.js'\nimport {\n defaultImportProtectionIgnoreImporters,\n onImportProtectionViolation,\n serverOnlyClientSpecifiers,\n} from './importProtection.js'\nimport { clientModuleResolution } from './workarounds/clientModuleResolution.js'\nimport { payloadDevTransforms } from './workarounds/devTransforms.js'\nimport { reactDomServerInRsc } from './workarounds/reactDomServerInRsc.js'\nimport { ssrStripDistStyleImports } from './workarounds/stripDistStyleImports.js'\nimport { stubPrettierInClient } from './workarounds/stubPrettierInClient.js'\nimport { wrapCjsForClient } from './workarounds/wrapCjsForClient.js'\n\n/**\n * Vite dependency warnings Payload consumers can't act on: third-party packages\n * ship sourcemaps whose original sources aren't published, so Vite warns on\n * every one. Suppressed by default (see `silenceDependencyWarnings`).\n */\nconst suppressibleWarningPatterns = ['points to missing source files', 'Sourcemap for']\n\n/**\n * Wraps a Vite logger so warnings matching {@link suppressibleWarningPatterns}\n * are dropped. Mutates and returns the given logger (or a fresh default one).\n */\nfunction withQuietedDependencyWarnings(existing?: Logger): Logger {\n const logger = existing ?? createLogger()\n const shouldSuppress = (msg: unknown): boolean =>\n typeof msg === 'string' && suppressibleWarningPatterns.some((pattern) => msg.includes(pattern))\n\n const baseWarn = logger.warn.bind(logger)\n const baseWarnOnce = logger.warnOnce.bind(logger)\n logger.warn = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarn(msg, options)\n }\n }\n logger.warnOnce = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarnOnce(msg, options)\n }\n }\n return logger\n}\n\n/** Applies dependency-warning suppression to a config in place when enabled. */\nfunction applyDependencyWarningSuppression(config: UserConfig, enabled: boolean): UserConfig {\n if (enabled) {\n config.customLogger = withQuietedDependencyWarnings(config.customLogger)\n }\n return config\n}\n\nexport type WithPayloadOptions = {\n /** Extra import-protection `ignoreImporters` patterns for the TanStack Start plugin. */\n additionalIgnoreImporters?: RegExp[]\n /** Route id of Payload's admin layout, eager-loaded instead of code-split. Defaults to `'/_payload'`. */\n adminRouteId?: string\n /** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */\n clientDenialExcludeFiles?: string[]\n /** Path to the user's `payload.config.ts` (required) */\n payloadConfigPath: string\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'` */\n routesDirectory?: string\n /** Silence Vite warnings about third-party dependency sourcemaps. Defaults to `true`. */\n silenceDependencyWarnings?: boolean\n /** TanStack source directory. Defaults to `'src'` */\n srcDirectory?: string\n /** Extra Vite config deep-merged over the Payload defaults. Ignored in `build` mode. */\n vite?: UserConfig\n}\n\n/** The options Payload's admin requires for each third-party plugin. */\nexport type PayloadPluginOptions = {\n react: NonNullable<Parameters<typeof viteReact>[0]>\n rsc: NonNullable<Parameters<typeof rsc>[0]>\n tanstackStart: NonNullable<Parameters<typeof tanstackStart>[0]>\n}\n\nexport type WithPayloadBuilderContext = {\n env: ConfigEnv\n /** Options to pass to the `viteReact`/`rsc`/`tanstackStart` factories you import. */\n pluginOptions: PayloadPluginOptions\n}\n\n/**\n * Returns the extra Vite config — the plugins you instantiate plus any overrides.\n * `withPayload` deep-merges it onto Payload's base config, so you don't spread or\n * merge the base yourself.\n */\nexport type WithPayloadBuilder = (context: WithPayloadBuilderContext) => UserConfig\n\n/**\n * Vite config helper for Payload + TanStack Start; the counterpart to Next.js'\n * `withPayload`.\n *\n * Zero-config — Payload instantiates the RSC, React, and TanStack Start plugins:\n *\n * ```ts\n * export default withPayload(undefined, { payloadConfigPath: './src/payload.config.ts' })\n * ```\n *\n * Guest mode — pass a `build` callback to instantiate them yourself (one copy of\n * each; `@vitejs/plugin-rsc` is a hard singleton). Return only your additions;\n * `withPayload` deep-merges them onto Payload's base config:\n *\n * ```ts\n * export default withPayload(\n * ({ pluginOptions }) => ({\n * plugins: [\n * rsc(pluginOptions.rsc),\n * tanstackStart(pluginOptions.tanstackStart),\n * viteReact(pluginOptions.react),\n * ],\n * // ...other config options\n * }),\n * { payloadConfigPath: './src/payload.config.ts' },\n * )\n * ```\n */\nexport function withPayload(\n build: undefined | WithPayloadBuilder,\n options: WithPayloadOptions,\n): UserConfigFnObject {\n const {\n additionalIgnoreImporters = [],\n adminRouteId,\n clientDenialExcludeFiles = [],\n payloadConfigPath,\n routesDirectory = 'app',\n silenceDependencyWarnings = true,\n srcDirectory = 'src',\n vite,\n } = options\n\n return (env) => {\n // `pluralize` ships a UMD wrapper that throws when run through Vite's dev SSR\n // transform, so dev serve keeps it external and lets Node require it.\n // The production build must bundle it instead: it is reached from the\n // force-bundled `@payloadcms/ui` / `@payloadcms/translations`, and Vite would\n // otherwise externalize it into a client chunk as a bare specifier that pnpm\n // can't resolve from `dist/` at runtime. Dropping it from the externals list\n // isn't enough — Vite externalizes deps of `noExternal` packages by default,\n // so it must be forced back in via `noExternal`.\n const isBuild = env.command === 'build'\n const noExternalPatterns = isBuild\n ? [...payloadNoExternalPatterns, 'pluralize']\n : payloadNoExternalPatterns\n // Dev serve externalizes the server-only Node packages (including `pluralize`,\n // whose UMD wrapper breaks under Vite's SSR transform). The prod build instead\n // externalizes the package boundaries (`buildExternalPackages`) and drops\n // `pluralize` so it bundles — leaving it in `ssr.external` here would win over\n // `noExternal` and re-emit the bare specifier.\n const ssrExternal = isBuild ? buildExternalPackages : ssrExternalPackages\n\n const base: UserConfig = {\n build: {\n cssMinify: 'esbuild',\n },\n css: {\n preprocessorOptions: {\n scss: {\n importers: payloadScssImporters,\n silenceDeprecations: ['import', 'global-builtin'],\n } as any,\n },\n },\n define: {\n global: 'globalThis',\n },\n environments: {\n rsc: {\n build: { rollupOptions: { external: buildExternalPackages } },\n resolve: { noExternal: noExternalPatterns },\n },\n ssr: {\n build: { rollupOptions: { external: buildExternalPackages } },\n resolve: { noExternal: noExternalPatterns },\n },\n } as any,\n optimizeDeps: {\n exclude: optimizeDepsExcludeDefaults,\n include: optimizeDepsIncludeDefaults,\n },\n // Payload's internal workaround plugins only. The RSC, TanStack Start, and\n // React plugins are appended below (default form) or by the consumer's\n // `build` callback (guest form).\n plugins: [\n clientModuleResolution(),\n wrapCjsForClient(),\n ssrStripDistStyleImports(),\n reactDomServerInRsc(),\n stubPrettierInClient(),\n payloadDevTransforms(),\n ],\n resolve: {\n alias: [{ find: '@payload-config', replacement: path.resolve(payloadConfigPath) }],\n dedupe: [\n 'react',\n 'react-dom',\n 'scheduler',\n '@payloadcms/ui',\n '@payloadcms/richtext-lexical',\n ],\n extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],\n tsconfigPaths: true,\n } as any,\n ssr: {\n external: ssrExternal,\n noExternal: noExternalPatterns,\n },\n }\n\n const pluginOptions: PayloadPluginOptions = {\n react: payloadReactOptions(),\n rsc: payloadRscOptions(),\n tanstackStart: payloadTanstackStartOptions({\n additionalIgnoreImporters,\n adminRouteId,\n clientDenialExcludeFiles,\n routesDirectory,\n srcDirectory,\n }),\n }\n\n if (build) {\n return applyDependencyWarningSuppression(\n mergeConfig(base, build({ env, pluginOptions })),\n silenceDependencyWarnings,\n )\n }\n\n base.plugins = [\n ...(base.plugins as PluginOption[]),\n rsc(pluginOptions.rsc),\n tanstackStart(pluginOptions.tanstackStart),\n viteReact(pluginOptions.react),\n ]\n\n const merged = vite ? mergeConfig(base, vite) : base\n\n return applyDependencyWarningSuppression(merged, silenceDependencyWarnings)\n }\n}\n\n/** `@vitejs/plugin-rsc` options for Payload: `serverHandler: false` (TanStack owns the handler). */\nexport function payloadRscOptions(): NonNullable<Parameters<typeof rsc>[0]> {\n return { serverHandler: false }\n}\n\n/** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */\nexport function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]> {\n return { exclude: [], include: /\\.[jt]sx?$/ }\n}\n\nexport type PayloadTanstackStartOptionsArgs = {\n /** Additional import-protection `ignoreImporters` patterns. */\n additionalIgnoreImporters?: RegExp[]\n /**\n * Route id of Payload's admin layout route, eager-loaded (not code-split) so it\n * hydrates on first paint. It and its children skip splitting; host routes keep\n * TanStack's default. Defaults to `'/_payload'` (the `_payload.tsx` convention).\n */\n adminRouteId?: string\n /**\n * Extra globs exempted from TanStack's `.client.*` SSR denial, on top of the\n * default node_modules exemption. Needed only when Payload's own `.client.*`\n * files resolve outside node_modules (e.g. the monorepo's `packages` sources).\n */\n clientDenialExcludeFiles?: string[]\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'`. */\n routesDirectory?: string\n /** TanStack source directory. Defaults to `'src'`. */\n srcDirectory?: string\n}\n\n/**\n * The `tanstackStart` options Payload's admin requires (import-protection and\n * code-splitting). TanStack Start is one-per-app, so a host that already runs it\n * should merge these into its single `tanstackStart` call.\n */\nexport function payloadTanstackStartOptions(\n args: PayloadTanstackStartOptionsArgs = {},\n): NonNullable<Parameters<typeof tanstackStart>[0]> {\n const {\n additionalIgnoreImporters = [],\n adminRouteId = '/_payload',\n clientDenialExcludeFiles = [],\n routesDirectory = 'app',\n srcDirectory = 'src',\n } = args\n\n return {\n importProtection: {\n client: { excludeFiles: [], specifiers: serverOnlyClientSpecifiers },\n ignoreImporters: [...defaultImportProtectionIgnoreImporters, ...additionalIgnoreImporters],\n include: ['**/*'],\n mockAccess: 'warn',\n onViolation: onImportProtectionViolation,\n // Payload's `.client.*` components are React Client Components that must be\n // server-rendered during SSR; TanStack's default `**/*.client.*` server\n // denial would mock and crash them. All such files live in `@payloadcms/*`\n // packages, so keep the denial (host `.client.*` files still get it) and\n // just exempt Payload's — `node_modules` covers published installs.\n server: { excludeFiles: ['**/node_modules/**', ...clientDenialExcludeFiles] },\n },\n router: {\n codeSplittingOptions: {\n // Eager-load only Payload's admin routes so they hydrate on first paint —\n // a split admin renders but isn't interactive until its lazy `?tsr-split=`\n // chunk lands. Returning `[]` disables splitting for a route; `undefined`\n // lets host routes keep TanStack's default per-route splitting.\n splitBehavior: ({ routeId }: { routeId: string }) =>\n routeId === adminRouteId || routeId.startsWith(`${adminRouteId}/`) ? [] : undefined,\n },\n // Ignore generated importMap files and colocated `*.functions.ts` modules\n // (they define `createServerFn`s, not routes).\n routeFileIgnorePattern: 'importMap\\\\.(?:js|server\\\\.ts)$|\\\\.functions\\\\.',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }\n}\n"],"names":["tanstackStart","viteReact","rsc","path","createLogger","mergeConfig","buildExternalPackages","payloadNoExternalPatterns","ssrExternalPackages","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadScssImporters","defaultImportProtectionIgnoreImporters","onImportProtectionViolation","serverOnlyClientSpecifiers","clientModuleResolution","payloadDevTransforms","reactDomServerInRsc","ssrStripDistStyleImports","stubPrettierInClient","wrapCjsForClient","suppressibleWarningPatterns","withQuietedDependencyWarnings","existing","logger","shouldSuppress","msg","some","pattern","includes","baseWarn","warn","bind","baseWarnOnce","warnOnce","options","applyDependencyWarningSuppression","config","enabled","customLogger","withPayload","build","additionalIgnoreImporters","adminRouteId","clientDenialExcludeFiles","payloadConfigPath","routesDirectory","silenceDependencyWarnings","srcDirectory","vite","env","isBuild","command","noExternalPatterns","ssrExternal","base","cssMinify","css","preprocessorOptions","scss","importers","silenceDeprecations","define","global","environments","rollupOptions","external","resolve","noExternal","ssr","optimizeDeps","exclude","include","plugins","alias","find","replacement","dedupe","extensions","tsconfigPaths","pluginOptions","react","payloadReactOptions","payloadRscOptions","payloadTanstackStartOptions","merged","serverHandler","args","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","router","codeSplittingOptions","splitBehavior","routeId","startsWith","undefined","routeFileIgnorePattern"],"mappings":"AAEA,kFAAkF;AAClF,2DAA2D;AAC3D,SAASA,aAAa,QAAQ,oCAAmC;AACjE,OAAOC,eAAe,uBAAsB;AAC5C,OAAOC,SAAS,qBAAoB;AACpC,OAAOC,UAAU,YAAW;AAC5B,SAASC,YAAY,EAAEC,WAAW,QAAQ,OAAM;AAEhD,SACEC,qBAAqB,EACrBC,yBAAyB,EACzBC,mBAAmB,QACd,uBAAsB;AAC7B,SAASC,2BAA2B,EAAEC,2BAA2B,QAAQ,2BAA0B;AACnG,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SACEC,sCAAsC,EACtCC,2BAA2B,EAC3BC,0BAA0B,QACrB,wBAAuB;AAC9B,SAASC,sBAAsB,QAAQ,0CAAyC;AAChF,SAASC,oBAAoB,QAAQ,iCAAgC;AACrE,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SAASC,wBAAwB,QAAQ,yCAAwC;AACjF,SAASC,oBAAoB,QAAQ,wCAAuC;AAC5E,SAASC,gBAAgB,QAAQ,oCAAmC;AAEpE;;;;CAIC,GACD,MAAMC,8BAA8B;IAAC;IAAkC;CAAgB;AAEvF;;;CAGC,GACD,SAASC,8BAA8BC,QAAiB;IACtD,MAAMC,SAASD,YAAYnB;IAC3B,MAAMqB,iBAAiB,CAACC,MACtB,OAAOA,QAAQ,YAAYL,4BAA4BM,IAAI,CAAC,CAACC,UAAYF,IAAIG,QAAQ,CAACD;IAExF,MAAME,WAAWN,OAAOO,IAAI,CAACC,IAAI,CAACR;IAClC,MAAMS,eAAeT,OAAOU,QAAQ,CAACF,IAAI,CAACR;IAC1CA,OAAOO,IAAI,GAAG,CAACL,KAAKS;QAClB,IAAI,CAACV,eAAeC,MAAM;YACxBI,SAASJ,KAAKS;QAChB;IACF;IACAX,OAAOU,QAAQ,GAAG,CAACR,KAAKS;QACtB,IAAI,CAACV,eAAe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AAM,EACJ7C,4BAA4B,EAAE,EAC9BC,eAAe,WAAW,EAC1BC,2BAA2B,EAAE,EAC7BE,kBAAkB,KAAK,EACvBE,eAAe,KAAK,EACrB,GAAGuC;IAEJ,OAAO;QACLC,kBAAkB;YAChBC,QAAQ;gBAAEC,cAAc,EAAE;gBAAEC,YAAY7E;YAA2B;YACnE8E,iBAAiB;mBAAIhF;mBAA2C8B;aAA0B;YAC1F8B,SAAS;gBAAC;aAAO;YACjBqB,YAAY;YACZC,aAAajF;YACb,4EAA4E;YAC5E,wEAAwE;YACxE,2EAA2E;YAC3E,yEAAyE;YACzE,oEAAoE;YACpEkF,QAAQ;gBAAEL,cAAc;oBAAC;uBAAyB9C;iBAAyB;YAAC;QAC9E;QACAoD,QAAQ;YACNC,sBAAsB;gBACpB,0EAA0E;gBAC1E,2EAA2E;gBAC3E,0EAA0E;gBAC1E,gEAAgE;gBAChEC,eAAe,CAAC,EAAEC,OAAO,EAAuB,GAC9CA,YAAYxD,gBAAgBwD,QAAQC,UAAU,CAAC,GAAGzD,aAAa,CAAC,CAAC,IAAI,EAAE,GAAG0D;YAC9E;YACA,0EAA0E;YAC1E,+CAA+C;YAC/CC,wBAAwB;YACxBxD;QACF;QACA5C,KAAK;YAAEoC,SAAS;QAAK;QACrBU;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/withPayload/index.ts"],"sourcesContent":["import type { ConfigEnv, Logger, PluginOption, UserConfig, UserConfigFnObject } from 'vite'\n\n// Optional peers, not deps: `plugin-rsc` is a singleton, so bundling our own copy\n// alongside the host's would load two instances and crash.\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite'\nimport viteReact from '@vitejs/plugin-react'\nimport rsc from '@vitejs/plugin-rsc'\nimport path from 'node:path'\nimport { createLogger, mergeConfig } from 'vite'\n\nimport {\n buildExternalPackages,\n payloadNoExternalPatterns,\n ssrExternalPackages,\n} from './config/external.js'\nimport { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js'\nimport { payloadScssImporters } from './config/scss.js'\nimport { payloadDevConfigReload } from './devConfigReload.js'\nimport {\n defaultImportProtectionIgnoreImporters,\n onImportProtectionViolation,\n serverOnlyClientSpecifiers,\n} from './importProtection.js'\nimport { clientModuleResolution } from './workarounds/clientModuleResolution.js'\nimport { payloadDevTransforms } from './workarounds/devTransforms.js'\nimport { reactDomServerInRsc } from './workarounds/reactDomServerInRsc.js'\nimport { ssrStripDistStyleImports } from './workarounds/stripDistStyleImports.js'\nimport { stubPrettierInClient } from './workarounds/stubPrettierInClient.js'\nimport { wrapCjsForClient } from './workarounds/wrapCjsForClient.js'\n\n/**\n * Vite dependency warnings Payload consumers can't act on: third-party packages\n * ship sourcemaps whose original sources aren't published, so Vite warns on\n * every one. Suppressed by default (see `silenceDependencyWarnings`).\n *\n * `Failed to load source map` covers deps that ship a `sourceMappingURL` comment\n * without the `.map` file it points at (e.g. `undici`'s `lib/llhttp/*.js`, pulled\n * in via `@vercel/blob`). Vite appends the underlying `ENOENT` stack to that one,\n * so each occurrence is a ~10-line block that buries real log output.\n */\nconst suppressibleWarningPatterns = [\n 'points to missing source files',\n 'Sourcemap for',\n 'Failed to load source map',\n 'references a map file outside its package',\n]\n\n/**\n * Wraps a Vite logger so warnings matching {@link suppressibleWarningPatterns}\n * are dropped. Mutates and returns the given logger (or a fresh default one).\n */\nfunction withQuietedDependencyWarnings(existing?: Logger): Logger {\n const logger = existing ?? createLogger()\n const shouldSuppress = (msg: unknown): boolean =>\n typeof msg === 'string' && suppressibleWarningPatterns.some((pattern) => msg.includes(pattern))\n\n const baseWarn = logger.warn.bind(logger)\n const baseWarnOnce = logger.warnOnce.bind(logger)\n logger.warn = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarn(msg, options)\n }\n }\n logger.warnOnce = (msg, options) => {\n if (!shouldSuppress(msg)) {\n baseWarnOnce(msg, options)\n }\n }\n return logger\n}\n\n/** Applies dependency-warning suppression to a config in place when enabled. */\nfunction applyDependencyWarningSuppression(config: UserConfig, enabled: boolean): UserConfig {\n if (enabled) {\n config.customLogger = withQuietedDependencyWarnings(config.customLogger)\n }\n return config\n}\n\nexport type WithPayloadOptions = {\n /** Extra import-protection `ignoreImporters` patterns for the TanStack Start plugin. */\n additionalIgnoreImporters?: RegExp[]\n /** Route id of Payload's admin layout, eager-loaded instead of code-split. Defaults to `'/_payload'`. */\n adminRouteId?: string\n /** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */\n clientDenialExcludeFiles?: string[]\n /** Path to the user's `payload.config.ts` (required) */\n payloadConfigPath: string\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'` */\n routesDirectory?: string\n /** Silence Vite warnings about third-party dependency sourcemaps. Defaults to `true`. */\n silenceDependencyWarnings?: boolean\n /** TanStack source directory. Defaults to `'src'` */\n srcDirectory?: string\n /** Extra Vite config deep-merged over the Payload defaults. Ignored in `build` mode. */\n vite?: UserConfig\n}\n\n/** The `nitro()` options Payload's server build requires. Typed structurally — `nitro` is the host's dependency, not Payload's. */\nexport type PayloadNitroOptions = {\n traceDeps: string[]\n}\n\n/** The options Payload's admin requires for each third-party plugin. */\nexport type PayloadPluginOptions = {\n nitro: PayloadNitroOptions\n react: NonNullable<Parameters<typeof viteReact>[0]>\n rsc: NonNullable<Parameters<typeof rsc>[0]>\n tanstackStart: NonNullable<Parameters<typeof tanstackStart>[0]>\n}\n\nexport type WithPayloadBuilderContext = {\n env: ConfigEnv\n /** Options to pass to the `viteReact`/`rsc`/`tanstackStart` factories you import. */\n pluginOptions: PayloadPluginOptions\n}\n\n/**\n * Returns the extra Vite config — the plugins you instantiate plus any overrides.\n * `withPayload` deep-merges it onto Payload's base config, so you don't spread or\n * merge the base yourself.\n */\nexport type WithPayloadBuilder = (context: WithPayloadBuilderContext) => UserConfig\n\n/**\n * Vite config helper for Payload + TanStack Start; the counterpart to Next.js'\n * `withPayload`.\n *\n * Zero-config — Payload instantiates the RSC, React, and TanStack Start plugins:\n *\n * ```ts\n * export default withPayload(undefined, { payloadConfigPath: './src/payload.config.ts' })\n * ```\n *\n * Guest mode — pass a `build` callback to instantiate them yourself (one copy of\n * each; `@vitejs/plugin-rsc` is a hard singleton). Return only your additions;\n * `withPayload` deep-merges them onto Payload's base config:\n *\n * ```ts\n * export default withPayload(\n * ({ pluginOptions }) => ({\n * plugins: [\n * rsc(pluginOptions.rsc),\n * tanstackStart(pluginOptions.tanstackStart),\n * viteReact(pluginOptions.react),\n * nitro(pluginOptions.nitro), // only if the app deploys through Nitro\n * ],\n * // ...other config options\n * }),\n * { payloadConfigPath: './src/payload.config.ts' },\n * )\n * ```\n */\nexport function withPayload(\n build: undefined | WithPayloadBuilder,\n options: WithPayloadOptions,\n): UserConfigFnObject {\n const {\n additionalIgnoreImporters = [],\n adminRouteId,\n clientDenialExcludeFiles = [],\n payloadConfigPath,\n routesDirectory = 'app',\n silenceDependencyWarnings = true,\n srcDirectory = 'src',\n vite,\n } = options\n\n return (env) => {\n // `pluralize` ships a UMD wrapper that throws when run through Vite's dev SSR\n // transform, so dev serve keeps it external and lets Node require it.\n // The production build must bundle it instead: it is reached from the\n // force-bundled `@payloadcms/ui` / `@payloadcms/translations`, and Vite would\n // otherwise externalize it into a client chunk as a bare specifier that pnpm\n // can't resolve from `dist/` at runtime. Dropping it from the externals list\n // isn't enough — Vite externalizes deps of `noExternal` packages by default,\n // so it must be forced back in via `noExternal`.\n const isBuild = env.command === 'build'\n const noExternalPatterns = isBuild\n ? [...payloadNoExternalPatterns, 'pluralize']\n : payloadNoExternalPatterns\n // Dev serve externalizes the server-only Node packages (including `pluralize`,\n // whose UMD wrapper breaks under Vite's SSR transform). The prod build instead\n // externalizes the package boundaries (`buildExternalPackages`) and drops\n // `pluralize` so it bundles — leaving it in `ssr.external` here would win over\n // `noExternal` and re-emit the bare specifier.\n const ssrExternal = isBuild ? buildExternalPackages : ssrExternalPackages\n\n const base: UserConfig = {\n build: {\n cssMinify: 'esbuild',\n },\n css: {\n preprocessorOptions: {\n scss: {\n importers: payloadScssImporters,\n silenceDeprecations: ['import', 'global-builtin'],\n } as any,\n },\n },\n define: {\n global: 'globalThis',\n },\n environments: {\n rsc: {\n build: { rollupOptions: { external: buildExternalPackages } },\n resolve: { noExternal: noExternalPatterns },\n },\n ssr: {\n build: { rollupOptions: { external: buildExternalPackages } },\n resolve: { noExternal: noExternalPatterns },\n },\n } as any,\n optimizeDeps: {\n exclude: optimizeDepsExcludeDefaults,\n include: optimizeDepsIncludeDefaults,\n },\n // Payload's internal workaround plugins only. The RSC, TanStack Start, and\n // React plugins are appended below (default form) or by the consumer's\n // `build` callback (guest form).\n plugins: [\n clientModuleResolution(),\n wrapCjsForClient(),\n ssrStripDistStyleImports(),\n reactDomServerInRsc(),\n stubPrettierInClient(),\n payloadDevTransforms(),\n payloadDevConfigReload({ payloadConfigPath }),\n ],\n resolve: {\n alias: [{ find: '@payload-config', replacement: path.resolve(payloadConfigPath) }],\n dedupe: [\n 'react',\n 'react-dom',\n 'scheduler',\n '@payloadcms/ui',\n '@payloadcms/richtext-lexical',\n ],\n extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],\n tsconfigPaths: true,\n } as any,\n ssr: {\n external: ssrExternal,\n noExternal: noExternalPatterns,\n },\n }\n\n const pluginOptions: PayloadPluginOptions = {\n nitro: payloadNitroOptions(),\n react: payloadReactOptions(),\n rsc: payloadRscOptions(),\n tanstackStart: payloadTanstackStartOptions({\n additionalIgnoreImporters,\n adminRouteId,\n clientDenialExcludeFiles,\n routesDirectory,\n srcDirectory,\n }),\n }\n\n if (build) {\n return applyDependencyWarningSuppression(\n mergeConfig(base, build({ env, pluginOptions })),\n silenceDependencyWarnings,\n )\n }\n\n base.plugins = [\n ...(base.plugins as PluginOption[]),\n rsc(pluginOptions.rsc),\n tanstackStart(pluginOptions.tanstackStart),\n viteReact(pluginOptions.react),\n ]\n\n const merged = vite ? mergeConfig(base, vite) : base\n\n return applyDependencyWarningSuppression(merged, silenceDependencyWarnings)\n }\n}\n\n/** `@vitejs/plugin-rsc` options for Payload: `serverHandler: false` (TanStack owns the handler). */\nexport function payloadRscOptions(): NonNullable<Parameters<typeof rsc>[0]> {\n return { serverHandler: false }\n}\n\n/**\n * `nitro/vite` options for Payload's server build. `tslib*` full-traces `tslib`\n * so an externalized dep's `tslib/modules/index.js` import (its `import.node`\n * export condition) ships — otherwise the build is green and the server 500s\n * with `ERR_MODULE_NOT_FOUND` on the first request.\n */\nexport function payloadNitroOptions(): PayloadNitroOptions {\n return { traceDeps: ['tslib*'] }\n}\n\n/** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */\nexport function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]> {\n return { exclude: [], include: /\\.[jt]sx?$/ }\n}\n\nexport type PayloadTanstackStartOptionsArgs = {\n /** Additional import-protection `ignoreImporters` patterns. */\n additionalIgnoreImporters?: RegExp[]\n /**\n * Route id of Payload's admin layout route, eager-loaded (not code-split) so it\n * hydrates on first paint. It and its children skip splitting; host routes keep\n * TanStack's default. Defaults to `'/_payload'` (the `_payload.tsx` convention).\n */\n adminRouteId?: string\n /**\n * Extra globs exempted from TanStack's `.client.*` SSR denial, on top of the\n * default node_modules exemption. Needed only when Payload's own `.client.*`\n * files resolve outside node_modules (e.g. the monorepo's `packages` sources).\n */\n clientDenialExcludeFiles?: string[]\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'`. */\n routesDirectory?: string\n /** TanStack source directory. Defaults to `'src'`. */\n srcDirectory?: string\n}\n\n/**\n * The `tanstackStart` options Payload's admin requires (import-protection and\n * code-splitting). TanStack Start is one-per-app, so a host that already runs it\n * should merge these into its single `tanstackStart` call.\n */\nexport function payloadTanstackStartOptions(\n args: PayloadTanstackStartOptionsArgs = {},\n): NonNullable<Parameters<typeof tanstackStart>[0]> {\n const {\n additionalIgnoreImporters = [],\n adminRouteId = '/_payload',\n clientDenialExcludeFiles = [],\n routesDirectory = 'app',\n srcDirectory = 'src',\n } = args\n\n return {\n importProtection: {\n client: { excludeFiles: [], specifiers: serverOnlyClientSpecifiers },\n ignoreImporters: [...defaultImportProtectionIgnoreImporters, ...additionalIgnoreImporters],\n include: ['**/*'],\n mockAccess: 'warn',\n onViolation: onImportProtectionViolation,\n // Payload's `.client.*` components are React Client Components that must be\n // server-rendered during SSR; TanStack's default `**/*.client.*` server\n // denial would mock and crash them. All such files live in `@payloadcms/*`\n // packages, so keep the denial (host `.client.*` files still get it) and\n // just exempt Payload's — `node_modules` covers published installs.\n server: { excludeFiles: ['**/node_modules/**', ...clientDenialExcludeFiles] },\n },\n router: {\n codeSplittingOptions: {\n // Eager-load only Payload's admin routes so they hydrate on first paint —\n // a split admin renders but isn't interactive until its lazy `?tsr-split=`\n // chunk lands. Returning `[]` disables splitting for a route; `undefined`\n // lets host routes keep TanStack's default per-route splitting.\n splitBehavior: ({ routeId }: { routeId: string }) =>\n routeId === adminRouteId || routeId.startsWith(`${adminRouteId}/`) ? [] : undefined,\n },\n // Ignore generated importMap files and colocated `*.functions.ts` modules\n // (they define `createServerFn`s, not routes).\n routeFileIgnorePattern: 'importMap\\\\.(?:d\\\\.ts|js|server\\\\.ts)$|\\\\.functions\\\\.',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }\n}\n"],"names":["tanstackStart","viteReact","rsc","path","createLogger","mergeConfig","buildExternalPackages","payloadNoExternalPatterns","ssrExternalPackages","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadScssImporters","payloadDevConfigReload","defaultImportProtectionIgnoreImporters","onImportProtectionViolation","serverOnlyClientSpecifiers","clientModuleResolution","payloadDevTransforms","reactDomServerInRsc","ssrStripDistStyleImports","stubPrettierInClient","wrapCjsForClient","suppressibleWarningPatterns","withQuietedDependencyWarnings","existing","logger","shouldSuppress","msg","some","pattern","includes","baseWarn","warn","bind","baseWarnOnce","warnOnce","options","applyDependencyWarningSuppression","config","enabled","customLogger","withPayload","build","additionalIgnoreImporters","adminRouteId","clientDenialExcludeFiles","payloadConfigPath","routesDirectory","silenceDependencyWarnings","srcDirectory","vite","env","isBuild","command","noExternalPatterns","ssrExternal","base","cssMinify","css","preprocessorOptions","scss","importers","silenceDeprecations","define","global","environments","rollupOptions","external","resolve","noExternal","ssr","optimizeDeps","exclude","include","plugins","alias","find","replacement","dedupe","extensions","tsconfigPaths","pluginOptions","nitro","payloadNitroOptions","react","payloadReactOptions","payloadRscOptions","payloadTanstackStartOptions","merged","serverHandler","traceDeps","args","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","router","codeSplittingOptions","splitBehavior","routeId","startsWith","undefined","routeFileIgnorePattern"],"mappings":"AAEA,kFAAkF;AAClF,2DAA2D;AAC3D,SAASA,aAAa,QAAQ,oCAAmC;AACjE,OAAOC,eAAe,uBAAsB;AAC5C,OAAOC,SAAS,qBAAoB;AACpC,OAAOC,UAAU,YAAW;AAC5B,SAASC,YAAY,EAAEC,WAAW,QAAQ,OAAM;AAEhD,SACEC,qBAAqB,EACrBC,yBAAyB,EACzBC,mBAAmB,QACd,uBAAsB;AAC7B,SAASC,2BAA2B,EAAEC,2BAA2B,QAAQ,2BAA0B;AACnG,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SAASC,sBAAsB,QAAQ,uBAAsB;AAC7D,SACEC,sCAAsC,EACtCC,2BAA2B,EAC3BC,0BAA0B,QACrB,wBAAuB;AAC9B,SAASC,sBAAsB,QAAQ,0CAAyC;AAChF,SAASC,oBAAoB,QAAQ,iCAAgC;AACrE,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SAASC,wBAAwB,QAAQ,yCAAwC;AACjF,SAASC,oBAAoB,QAAQ,wCAAuC;AAC5E,SAASC,gBAAgB,QAAQ,oCAAmC;AAEpE;;;;;;;;;CASC,GACD,MAAMC,8BAA8B;IAClC;IACA;IACA;IACA;CACD;AAED;;;CAGC,GACD,SAASC,8BAA8BC,QAAiB;IACtD,MAAMC,SAASD,YAAYpB;IA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+C;YAC/CC,wBAAwB;YACxB3D;QACF;QACA7C,KAAK;YAAEqC,SAAS;QAAK;QACrBU;IACF;AACF"}
|
|
@@ -37,7 +37,7 @@ const STYLE_EXTENSION_RE = /\.(?:s?css|less)$/i;
|
|
|
37
37
|
* blowing past the e2e waits. Stripping them collapses it back to ~3s.
|
|
38
38
|
*
|
|
39
39
|
* Safe because every one of these components' styles also ship in the global
|
|
40
|
-
* `@payloadcms/ui/
|
|
40
|
+
* `@payloadcms/ui/css/app.css` the admin imports, so dropping the per-module
|
|
41
41
|
* RSC collection here changes nothing visually (verified: diff + Nav stay
|
|
42
42
|
* styled). The admin `Nav` etc. are deliberately excluded — they rely on the
|
|
43
43
|
* RSC collection and a broad strip leaves them unstyled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/withPayload/workarounds/stripDistStyleImports.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\nconst STYLE_EXTENSION_RE = /\\.(?:s?css|less)$/i\n\n/**\n * Static `import './foo.css'` (or .scss/.less) — top-level only.\n * Captures the entire statement so we can replace it with an empty line.\n *\n * Matches:\n * import './foo.css';\n * import \"../bar.scss\"\n * import './baz.less' ;\n */\nconst STATIC_STYLE_IMPORT_RE = /^[ \\t]*import\\s+['\"][^'\"]+\\.(?:s?css|less)['\"]\\s*(?:;[ \\t]*)?$/gm\n\n/**\n * Monorepo Payload package source, e.g. `…/packages/ui/src/…`. In the\n * core-dev / test setup Payload packages resolve to their workspace `src`\n * (not a published `dist`), so the `dist/` rule below doesn't cover them and\n * their `.css` side-effect imports survive into the SSR/RSC graph.\n */\nconst PAYLOAD_PKG_SRC_RE = /\\/packages\\/[^/]+\\/src\\//\n\n/**\n * The version-diff component trees — matched in either published `dist/` or\n * workspace `src/` form. The `.css` side-effect imports of these must be\n * stripped in the RSC env (the rest of `@payloadcms/ui` must NOT be — see the\n * note in `resolveId`/`transform` below), for two reasons rooted in the same\n * `@vitejs/plugin-rsc` behaviour: it wraps every exported CSS-importing\n * component with an async CSS-collector child\n * (`__vite_rsc_wrap_css__` → `await import('virtual:vite-rsc/css?…')`).\n *\n * 1. Correctness: the diff converters render `CheckIcon` (`icons/*`) and `File`\n * (`graphics/*`) through the SYNCHRONOUS `renderToStaticMarkup` (see\n * `reactDomServerInRsc`). The async wrapper suspends, crashing that render\n * with \"A component suspended while responding to synchronous input\" and\n * taking down the entire field-diffs tree.\n * 2. Performance: the diff view (`views/Version/*` — `RenderFieldsToDiff` and\n * its per-field components, `DiffCollapser`, `SelectComparison`, the\n * `Default` template — plus the `HTMLDiff`/`FieldDiffContainer`/\n * `FieldDiffLabel` elements and lexical's `field/Diff/*`) renders dozens of\n * these wrapped components in the Flight stream. Each async CSS import\n * serializes a round-trip, ballooning the render from ~3s to ~25s and\n * blowing past the e2e waits. Stripping them collapses it back to ~3s.\n *\n * Safe because every one of these components' styles also ship in the global\n * `@payloadcms/ui/
|
|
1
|
+
{"version":3,"sources":["../../../src/withPayload/workarounds/stripDistStyleImports.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\nconst STYLE_EXTENSION_RE = /\\.(?:s?css|less)$/i\n\n/**\n * Static `import './foo.css'` (or .scss/.less) — top-level only.\n * Captures the entire statement so we can replace it with an empty line.\n *\n * Matches:\n * import './foo.css';\n * import \"../bar.scss\"\n * import './baz.less' ;\n */\nconst STATIC_STYLE_IMPORT_RE = /^[ \\t]*import\\s+['\"][^'\"]+\\.(?:s?css|less)['\"]\\s*(?:;[ \\t]*)?$/gm\n\n/**\n * Monorepo Payload package source, e.g. `…/packages/ui/src/…`. In the\n * core-dev / test setup Payload packages resolve to their workspace `src`\n * (not a published `dist`), so the `dist/` rule below doesn't cover them and\n * their `.css` side-effect imports survive into the SSR/RSC graph.\n */\nconst PAYLOAD_PKG_SRC_RE = /\\/packages\\/[^/]+\\/src\\//\n\n/**\n * The version-diff component trees — matched in either published `dist/` or\n * workspace `src/` form. The `.css` side-effect imports of these must be\n * stripped in the RSC env (the rest of `@payloadcms/ui` must NOT be — see the\n * note in `resolveId`/`transform` below), for two reasons rooted in the same\n * `@vitejs/plugin-rsc` behaviour: it wraps every exported CSS-importing\n * component with an async CSS-collector child\n * (`__vite_rsc_wrap_css__` → `await import('virtual:vite-rsc/css?…')`).\n *\n * 1. Correctness: the diff converters render `CheckIcon` (`icons/*`) and `File`\n * (`graphics/*`) through the SYNCHRONOUS `renderToStaticMarkup` (see\n * `reactDomServerInRsc`). The async wrapper suspends, crashing that render\n * with \"A component suspended while responding to synchronous input\" and\n * taking down the entire field-diffs tree.\n * 2. Performance: the diff view (`views/Version/*` — `RenderFieldsToDiff` and\n * its per-field components, `DiffCollapser`, `SelectComparison`, the\n * `Default` template — plus the `HTMLDiff`/`FieldDiffContainer`/\n * `FieldDiffLabel` elements and lexical's `field/Diff/*`) renders dozens of\n * these wrapped components in the Flight stream. Each async CSS import\n * serializes a round-trip, ballooning the render from ~3s to ~25s and\n * blowing past the e2e waits. Stripping them collapses it back to ~3s.\n *\n * Safe because every one of these components' styles also ship in the global\n * `@payloadcms/ui/css/app.css` the admin imports, so dropping the per-module\n * RSC collection here changes nothing visually (verified: diff + Nav stay\n * styled). The admin `Nav` etc. are deliberately excluded — they rely on the\n * RSC collection and a broad strip leaves them unstyled.\n */\nconst DIFF_VIEW_COMPONENT_RE =\n /@payloadcms\\/ui\\/(?:dist|src)\\/(?:icons|graphics|views\\/Version|elements\\/(?:HTMLDiff|FieldDiffContainer|FieldDiffLabel))\\/|@payloadcms\\/richtext-lexical\\/(?:dist|src)\\/field\\/Diff\\//\n\n/**\n * Stops Vite (and the underlying Node ESM loader) from trying to load\n * SCSS/CSS/LESS during SSR/RSC when the importer lives inside a built\n * `dist/` directory or when the specifier is a bare package name.\n *\n * We do this two ways, because either layer can fail:\n *\n * 1. `resolveId` redirects style specifiers to a virtual empty module —\n * handles cases where Vite asks us to resolve them.\n * 2. `transform` strips top-level `import './x.css'` statements out of any\n * JS/TS file living under `node_modules/.../dist/` for non-client envs.\n * This is the bulletproof path for prod-packed `@payloadcms/ui` (and\n * similar) dependencies that get pre-bundled by Vite's SSR/RSC dep\n * optimizer (esbuild). Esbuild preserves `.css` import statements as-is,\n * and Node's native ESM loader then crashes with\n * `Unknown file extension \".css\"`. Removing them at the source avoids\n * that entirely.\n */\nexport function ssrStripDistStyleImports(): PluginOption {\n return {\n name: 'payload:ssr-strip-dist-style-imports',\n enforce: 'pre',\n load(id) {\n if (id === '\\0ssr-empty-style') {\n return ''\n }\n },\n resolveId(id, importer, options) {\n const envName = (this as any).environment?.name as string | undefined\n const isServerEnv = options?.ssr || (envName && envName !== 'client')\n if (!isServerEnv) {\n return\n }\n // Do NOT strip in the RSC environment. Server components (e.g. the admin\n // `Nav`, a non-'use client' component that `import './index.css'`) render\n // in the RSC graph, and `@vitejs/plugin-rsc` must SEE their `.css` imports\n // there to collect them as client stylesheets. Stripping them here means\n // their CSS is never emitted and the admin renders unstyled (broken nav\n // scroll/layout, etc.). The Node-side `.css` no-op is handled by\n // `cssLoader.mjs` (dev) and by Vite's CSS extraction (build), so the\n // crash this plugin guards against does not require touching the RSC env.\n if (envName === 'rsc') {\n return\n }\n if (!STYLE_EXTENSION_RE.test(id)) {\n return\n }\n if (importer && (/\\/dist\\//.test(importer) || PAYLOAD_PKG_SRC_RE.test(importer))) {\n return '\\0ssr-empty-style'\n }\n if (/^@?[a-z]/.test(id) && !id.startsWith('.') && !id.startsWith('/')) {\n return '\\0ssr-empty-style'\n }\n },\n transform(code, id) {\n const envName = (this as any).environment?.name as string | undefined\n const isServerEnv = envName && envName !== 'client'\n if (!isServerEnv) {\n return\n }\n // In the RSC env, only strip from the version-diff component trees (see\n // `DIFF_VIEW_COMPONENT_RE`). Every other server component (the admin\n // `Nav`, etc.) must keep its `.css` import so plugin-rsc can collect it —\n // see the matching note in `resolveId` above.\n if (envName === 'rsc' && !DIFF_VIEW_COMPONENT_RE.test(id)) {\n return\n }\n // Only touch Payload dependency files: published `node_modules/.../dist/`\n // builds, or workspace `…/packages/<pkg>/src/…` sources in the core-dev /\n // test setup. Don't strip from the consumer's own app source — devs may\n // legitimately want SSR-rendered <link>s from their own CSS imports.\n const isPayloadDistFile = /\\/node_modules\\//.test(id) && /\\/dist\\//.test(id)\n const isPayloadSrcFile = PAYLOAD_PKG_SRC_RE.test(id)\n if (!isPayloadDistFile && !isPayloadSrcFile) {\n return\n }\n // Allow a trailing query (`?v=…`, `?t=…`): Vite appends version/timestamp\n // queries to module ids, especially in the RSC graph, so a strict `$`\n // anchor would skip e.g. `icons/Check/index.js?v=83de8543`.\n if (!/\\.[mc]?[jt]sx?(?:$|\\?)/.test(id)) {\n return\n }\n if (!STATIC_STYLE_IMPORT_RE.test(code)) {\n STATIC_STYLE_IMPORT_RE.lastIndex = 0\n return\n }\n STATIC_STYLE_IMPORT_RE.lastIndex = 0\n const stripped = code.replace(STATIC_STYLE_IMPORT_RE, '')\n return { code: stripped, map: null }\n },\n }\n}\n"],"names":["STYLE_EXTENSION_RE","STATIC_STYLE_IMPORT_RE","PAYLOAD_PKG_SRC_RE","DIFF_VIEW_COMPONENT_RE","ssrStripDistStyleImports","name","enforce","load","id","resolveId","importer","options","envName","environment","isServerEnv","ssr","test","startsWith","transform","code","isPayloadDistFile","isPayloadSrcFile","lastIndex","stripped","replace","map"],"mappings":"AAEA,MAAMA,qBAAqB;AAE3B;;;;;;;;CAQC,GACD,MAAMC,yBAAyB;AAE/B;;;;;CAKC,GACD,MAAMC,qBAAqB;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,MAAMC,yBACJ;AAEF;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,MAAM;QACNC,SAAS;QACTC,MAAKC,EAAE;YACL,IAAIA,OAAO,qBAAqB;gBAC9B,OAAO;YACT;QACF;QACAC,WAAUD,EAAE,EAAEE,QAAQ,EAAEC,OAAO;YAC7B,MAAMC,UAAU,AAAC,IAAI,CAASC,WAAW,EAAER;YAC3C,MAAMS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,SAAS,GAAG;YACnC,MAAMC,WAAWJ,KAAKK,OAAO,CAACvB,wBAAwB;YACtD,OAAO;gBAAEkB,MAAMI;gBAAUE,KAAK;YAAK;QACrC;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/tanstack-start",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.f05c47f",
|
|
4
4
|
"description": "TanStack Start framework adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"qs-esm": "^7.0.2",
|
|
61
|
-
"@payloadcms/
|
|
62
|
-
"@payloadcms/
|
|
61
|
+
"@payloadcms/ui": "4.0.0-internal.f05c47f",
|
|
62
|
+
"@payloadcms/translations": "4.0.0-internal.f05c47f"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@tanstack/react-router": "^1.120.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"react": "^19.0.0",
|
|
72
72
|
"react-dom": "^19.0.0",
|
|
73
73
|
"vite": ">=8.0.0",
|
|
74
|
-
"payload": "4.0.0-internal.
|
|
74
|
+
"payload": "4.0.0-internal.f05c47f"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@tanstack/react-router": "^1.120.0",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"react": "^19.0.0",
|
|
82
82
|
"react-dom": "^19.0.0",
|
|
83
83
|
"vite": ">=8.0.0",
|
|
84
|
-
"payload": "4.0.0-internal.
|
|
84
|
+
"payload": "4.0.0-internal.f05c47f"
|
|
85
85
|
},
|
|
86
86
|
"peerDependenciesMeta": {
|
|
87
87
|
"@vitejs/plugin-react": {
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"node": "^18.20.2 || >=20.9.0"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
|
-
"build": "pnpm build:types && pnpm build:swc && pnpm build:copy-mjs",
|
|
101
|
+
"build": "pnpm build:types && pnpm test:types && pnpm build:swc && pnpm build:copy-mjs",
|
|
102
102
|
"build:clean": "find . \\( -type d \\( -name build -o -name dist -o -name .cache \\) -o -type f -name tsconfig.tsbuildinfo \\) -exec rm -rf {} + && pnpm build",
|
|
103
103
|
"build:copy-mjs": "node ./scripts/copyMjs.mjs",
|
|
104
104
|
"build:debug": "pnpm build",
|
|
@@ -106,6 +106,7 @@
|
|
|
106
106
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
107
107
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
108
108
|
"lint": "eslint .",
|
|
109
|
-
"lint:fix": "eslint . --fix"
|
|
109
|
+
"lint:fix": "eslint . --fix",
|
|
110
|
+
"test:types": "tsc --project test/tsconfig.json"
|
|
110
111
|
}
|
|
111
112
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ImportMap } from 'payload';
|
|
2
|
-
import '@payloadcms/ui/elements/DocumentHeader/index.scss';
|
|
3
|
-
import '@payloadcms/ui/elements/DocumentHeader/Tabs/index.scss';
|
|
4
|
-
import '@payloadcms/ui/elements/DocumentHeader/Tabs/Tab/index.scss';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
/**
|
|
7
|
-
* Client-only DocumentHeader for non-RSC adapters.
|
|
8
|
-
* Uses hooks to obtain config, permissions, and i18n instead of requiring `req`.
|
|
9
|
-
*/
|
|
10
|
-
export declare function DocumentHeaderClient({ collectionSlug, globalSlug, hideTabs, importMap, }: {
|
|
11
|
-
collectionSlug?: string;
|
|
12
|
-
globalSlug?: string;
|
|
13
|
-
hideTabs?: boolean;
|
|
14
|
-
importMap: ImportMap;
|
|
15
|
-
}): React.JSX.Element;
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/DocumentHeaderClient/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqB,SAAS,EAAE,MAAM,SAAS,CAAA;AAG3D,OAAO,mDAAmD,CAAA;AAC1D,OAAO,wDAAwD,CAAA;AAC/D,OAAO,4DAA4D,CAAA;AAKnE,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,cAAc,EACd,UAAU,EACV,QAAQ,EACR,SAAS,GACV,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,SAAS,CAAA;CACrB,qBAsGA"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Gutter, RenderTitle, useAuth, useConfig, useTranslation } from '@payloadcms/ui';
|
|
4
|
-
import '@payloadcms/ui/elements/DocumentHeader/index.scss';
|
|
5
|
-
import '@payloadcms/ui/elements/DocumentHeader/Tabs/index.scss';
|
|
6
|
-
import '@payloadcms/ui/elements/DocumentHeader/Tabs/Tab/index.scss';
|
|
7
|
-
import { ShouldRenderTabs } from '@payloadcms/ui/elements/DocumentHeader/Tabs/ShouldRenderTabs';
|
|
8
|
-
import { DocumentTabLink } from '@payloadcms/ui/elements/DocumentHeader/Tabs/Tab/TabLink';
|
|
9
|
-
import { getTabs } from '@payloadcms/ui/elements/DocumentHeader/Tabs/tabs';
|
|
10
|
-
import { RenderClientComponent } from '@payloadcms/ui/elements/RenderServerComponent/clientOnly';
|
|
11
|
-
import React, { Fragment } from 'react';
|
|
12
|
-
const baseClass = 'doc-header';
|
|
13
|
-
const tabBaseClass = 'doc-tab';
|
|
14
|
-
/**
|
|
15
|
-
* Client-only DocumentHeader for non-RSC adapters.
|
|
16
|
-
* Uses hooks to obtain config, permissions, and i18n instead of requiring `req`.
|
|
17
|
-
*/ export function DocumentHeaderClient({ collectionSlug, globalSlug, hideTabs, importMap }) {
|
|
18
|
-
const { config, getEntityConfig } = useConfig();
|
|
19
|
-
const { permissions } = useAuth();
|
|
20
|
-
const { t } = useTranslation();
|
|
21
|
-
const collectionConfig = collectionSlug ? getEntityConfig({
|
|
22
|
-
collectionSlug
|
|
23
|
-
}) : null;
|
|
24
|
-
const globalConfig = globalSlug ? getEntityConfig({
|
|
25
|
-
globalSlug
|
|
26
|
-
}) : null;
|
|
27
|
-
const tabs = getTabs({
|
|
28
|
-
collectionConfig: collectionConfig,
|
|
29
|
-
globalConfig: globalConfig
|
|
30
|
-
});
|
|
31
|
-
return /*#__PURE__*/ _jsx(Gutter, {
|
|
32
|
-
className: baseClass,
|
|
33
|
-
children: /*#__PURE__*/ _jsxs("div", {
|
|
34
|
-
className: `${baseClass}__header`,
|
|
35
|
-
children: [
|
|
36
|
-
/*#__PURE__*/ _jsx(RenderTitle, {
|
|
37
|
-
className: `${baseClass}__title`
|
|
38
|
-
}),
|
|
39
|
-
!hideTabs && /*#__PURE__*/ _jsx(ShouldRenderTabs, {
|
|
40
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
41
|
-
className: "doc-tabs",
|
|
42
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
43
|
-
className: "doc-tabs__tabs-container",
|
|
44
|
-
children: /*#__PURE__*/ _jsx("ul", {
|
|
45
|
-
className: "doc-tabs__tabs",
|
|
46
|
-
children: tabs?.map(({ tab: tabConfig, viewPath }, index)=>{
|
|
47
|
-
if (tabConfig?.condition) {
|
|
48
|
-
const meetsCondition = tabConfig.condition({
|
|
49
|
-
collectionConfig: collectionConfig,
|
|
50
|
-
config: config,
|
|
51
|
-
globalConfig: globalConfig,
|
|
52
|
-
permissions: permissions ?? {},
|
|
53
|
-
req: undefined
|
|
54
|
-
});
|
|
55
|
-
if (!meetsCondition) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (tabConfig?.Component) {
|
|
60
|
-
return /*#__PURE__*/ _jsx(RenderClientComponent, {
|
|
61
|
-
clientProps: {
|
|
62
|
-
path: viewPath
|
|
63
|
-
},
|
|
64
|
-
Component: tabConfig.Component,
|
|
65
|
-
importMap: importMap
|
|
66
|
-
}, `tab-${index}`);
|
|
67
|
-
}
|
|
68
|
-
const label = typeof tabConfig.label === 'function' ? tabConfig.label({
|
|
69
|
-
t: t
|
|
70
|
-
}) : tabConfig.label ?? '';
|
|
71
|
-
let href;
|
|
72
|
-
if (typeof tabConfig.href === 'function') {
|
|
73
|
-
href = tabConfig.href({
|
|
74
|
-
apiURL: undefined,
|
|
75
|
-
collection: collectionConfig,
|
|
76
|
-
global: globalConfig,
|
|
77
|
-
routes: config.routes
|
|
78
|
-
});
|
|
79
|
-
} else {
|
|
80
|
-
href = tabConfig.href ?? '';
|
|
81
|
-
}
|
|
82
|
-
const { Pill, Pill_Component } = tabConfig;
|
|
83
|
-
return /*#__PURE__*/ _jsx(DocumentTabLink, {
|
|
84
|
-
adminRoute: config.routes.admin,
|
|
85
|
-
ariaLabel: label,
|
|
86
|
-
baseClass: tabBaseClass,
|
|
87
|
-
href: href,
|
|
88
|
-
newTab: tabConfig.newTab,
|
|
89
|
-
children: /*#__PURE__*/ _jsxs("span", {
|
|
90
|
-
className: `${tabBaseClass}__label`,
|
|
91
|
-
children: [
|
|
92
|
-
label,
|
|
93
|
-
Pill || Pill_Component ? /*#__PURE__*/ _jsxs(Fragment, {
|
|
94
|
-
children: [
|
|
95
|
-
" ",
|
|
96
|
-
RenderClientComponent({
|
|
97
|
-
Component: Pill,
|
|
98
|
-
Fallback: Pill_Component,
|
|
99
|
-
importMap
|
|
100
|
-
})
|
|
101
|
-
]
|
|
102
|
-
}) : null
|
|
103
|
-
]
|
|
104
|
-
})
|
|
105
|
-
}, `tab-${index}`);
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
-
})
|
|
110
|
-
})
|
|
111
|
-
]
|
|
112
|
-
})
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/elements/DocumentHeaderClient/index.tsx"],"sourcesContent":["'use client'\n\nimport type { DocumentTabConfig, ImportMap } from 'payload'\n\nimport { Gutter, RenderTitle, useAuth, useConfig, useTranslation } from '@payloadcms/ui'\nimport '@payloadcms/ui/elements/DocumentHeader/index.scss'\nimport '@payloadcms/ui/elements/DocumentHeader/Tabs/index.scss'\nimport '@payloadcms/ui/elements/DocumentHeader/Tabs/Tab/index.scss'\nimport { ShouldRenderTabs } from '@payloadcms/ui/elements/DocumentHeader/Tabs/ShouldRenderTabs'\nimport { DocumentTabLink } from '@payloadcms/ui/elements/DocumentHeader/Tabs/Tab/TabLink'\nimport { getTabs } from '@payloadcms/ui/elements/DocumentHeader/Tabs/tabs'\nimport { RenderClientComponent } from '@payloadcms/ui/elements/RenderServerComponent/clientOnly'\nimport React, { Fragment } from 'react'\n\nconst baseClass = 'doc-header'\nconst tabBaseClass = 'doc-tab'\n\n/**\n * Client-only DocumentHeader for non-RSC adapters.\n * Uses hooks to obtain config, permissions, and i18n instead of requiring `req`.\n */\nexport function DocumentHeaderClient({\n collectionSlug,\n globalSlug,\n hideTabs,\n importMap,\n}: {\n collectionSlug?: string\n globalSlug?: string\n hideTabs?: boolean\n importMap: ImportMap\n}) {\n const { config, getEntityConfig } = useConfig()\n const { permissions } = useAuth()\n const { t } = useTranslation()\n\n const collectionConfig = collectionSlug ? getEntityConfig({ collectionSlug }) : null\n const globalConfig = globalSlug ? getEntityConfig({ globalSlug }) : null\n\n const tabs = getTabs({\n collectionConfig: collectionConfig as any,\n globalConfig: globalConfig as any,\n })\n\n return (\n <Gutter className={baseClass}>\n <div className={`${baseClass}__header`}>\n <RenderTitle className={`${baseClass}__title`} />\n {!hideTabs && (\n <ShouldRenderTabs>\n <div className=\"doc-tabs\">\n <div className=\"doc-tabs__tabs-container\">\n <ul className=\"doc-tabs__tabs\">\n {tabs?.map(({ tab: tabConfig, viewPath }, index) => {\n if (tabConfig?.condition) {\n const meetsCondition = tabConfig.condition({\n collectionConfig: collectionConfig as any,\n config: config as any,\n globalConfig: globalConfig as any,\n permissions: permissions ?? ({} as any),\n req: undefined as any,\n })\n if (!meetsCondition) {\n return null\n }\n }\n\n if (tabConfig?.Component) {\n return (\n <RenderClientComponent\n clientProps={{ path: viewPath }}\n Component={tabConfig.Component}\n importMap={importMap}\n key={`tab-${index}`}\n />\n )\n }\n\n const label =\n typeof tabConfig.label === 'function'\n ? tabConfig.label({ t: t as any })\n : ((tabConfig.label as string) ?? '')\n\n let href: string\n if (typeof tabConfig.href === 'function') {\n href = tabConfig.href({\n apiURL: undefined as any,\n collection: collectionConfig as any,\n global: globalConfig as any,\n routes: config.routes as any,\n })\n } else {\n href = (tabConfig.href as string) ?? ''\n }\n\n const { Pill, Pill_Component } = tabConfig as {\n Pill?: DocumentTabConfig['Pill']\n Pill_Component?: React.FC\n }\n\n return (\n <DocumentTabLink\n adminRoute={config.routes.admin}\n ariaLabel={label}\n baseClass={tabBaseClass}\n href={href}\n key={`tab-${index}`}\n newTab={tabConfig.newTab}\n >\n <span className={`${tabBaseClass}__label`}>\n {label}\n {Pill || Pill_Component ? (\n <Fragment>\n \n {RenderClientComponent({\n Component: Pill,\n Fallback: Pill_Component,\n importMap,\n })}\n </Fragment>\n ) : null}\n </span>\n </DocumentTabLink>\n )\n })}\n </ul>\n </div>\n </div>\n </ShouldRenderTabs>\n )}\n </div>\n </Gutter>\n )\n}\n"],"names":["Gutter","RenderTitle","useAuth","useConfig","useTranslation","ShouldRenderTabs","DocumentTabLink","getTabs","RenderClientComponent","React","Fragment","baseClass","tabBaseClass","DocumentHeaderClient","collectionSlug","globalSlug","hideTabs","importMap","config","getEntityConfig","permissions","t","collectionConfig","globalConfig","tabs","className","div","ul","map","tab","tabConfig","viewPath","index","condition","meetsCondition","req","undefined","Component","clientProps","path","label","href","apiURL","collection","global","routes","Pill","Pill_Component","adminRoute","admin","ariaLabel","newTab","span","Fallback"],"mappings":"AAAA;;AAIA,SAASA,MAAM,EAAEC,WAAW,EAAEC,OAAO,EAAEC,SAAS,EAAEC,cAAc,QAAQ,iBAAgB;AACxF,OAAO,oDAAmD;AAC1D,OAAO,yDAAwD;AAC/D,OAAO,6DAA4D;AACnE,SAASC,gBAAgB,QAAQ,+DAA8D;AAC/F,SAASC,eAAe,QAAQ,0DAAyD;AACzF,SAASC,OAAO,QAAQ,mDAAkD;AAC1E,SAASC,qBAAqB,QAAQ,2DAA0D;AAChG,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAEvC,MAAMC,YAAY;AAClB,MAAMC,eAAe;AAErB;;;CAGC,GACD,OAAO,SAASC,qBAAqB,EACnCC,cAAc,EACdC,UAAU,EACVC,QAAQ,EACRC,SAAS,EAMV;IACC,MAAM,EAAEC,MAAM,EAAEC,eAAe,EAAE,GAAGhB;IACpC,MAAM,EAAEiB,WAAW,EAAE,GAAGlB;IACxB,MAAM,EAAEmB,CAAC,EAAE,GAAGjB;IAEd,MAAMkB,mBAAmBR,iBAAiBK,gBAAgB;QAAEL;IAAe,KAAK;IAChF,MAAMS,eAAeR,aAAaI,gBAAgB;QAAEJ;IAAW,KAAK;IAEpE,MAAMS,OAAOjB,QAAQ;QACnBe,kBAAkBA;QAClBC,cAAcA;IAChB;IAEA,qBACE,KAACvB;QAAOyB,WAAWd;kBACjB,cAAA,MAACe;YAAID,WAAW,GAAGd,UAAU,QAAQ,CAAC;;8BACpC,KAACV;oBAAYwB,WAAW,GAAGd,UAAU,OAAO,CAAC;;gBAC5C,CAACK,0BACA,KAACX;8BACC,cAAA,KAACqB;wBAAID,WAAU;kCACb,cAAA,KAACC;4BAAID,WAAU;sCACb,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9B;wDACF;;qDAEA;;;uCAdD,CAAC,IAAI,EAAEe,OAAO;gCAkBzB;;;;;;;;AASlB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ComponentRenderer } from 'payload';
|
|
2
|
-
/**
|
|
3
|
-
* TanStack Start component renderer.
|
|
4
|
-
*
|
|
5
|
-
* Uses the RSC-aware renderer that passes `serverProps` to server components
|
|
6
|
-
* (detected via `$$typeof` / `isReactServerComponentOrFunction`) and
|
|
7
|
-
* `clientProps` only to client components.
|
|
8
|
-
*/
|
|
9
|
-
export declare const TanStackComponentRenderer: ComponentRenderer;
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/RenderComponent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAIhD;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,EAAE,iBAEvC,CAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { RenderRSCComponent } from '../../rsc/renderPayloadRSC.js';
|
|
2
|
-
/**
|
|
3
|
-
* TanStack Start component renderer.
|
|
4
|
-
*
|
|
5
|
-
* Uses the RSC-aware renderer that passes `serverProps` to server components
|
|
6
|
-
* (detected via `$$typeof` / `isReactServerComponentOrFunction`) and
|
|
7
|
-
* `clientProps` only to client components.
|
|
8
|
-
*/ export const TanStackComponentRenderer = (args)=>{
|
|
9
|
-
return RenderRSCComponent(args);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/elements/RenderComponent/index.tsx"],"sourcesContent":["import type { ComponentRenderer } from 'payload'\n\nimport { RenderRSCComponent } from '../../rsc/renderPayloadRSC.js'\n\n/**\n * TanStack Start component renderer.\n *\n * Uses the RSC-aware renderer that passes `serverProps` to server components\n * (detected via `$$typeof` / `isReactServerComponentOrFunction`) and\n * `clientProps` only to client components.\n */\nexport const TanStackComponentRenderer: ComponentRenderer = (args) => {\n return RenderRSCComponent(args)\n}\n"],"names":["RenderRSCComponent","TanStackComponentRenderer","args"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,gCAA+B;AAElE;;;;;;CAMC,GACD,OAAO,MAAMC,4BAA+C,CAACC;IAC3D,OAAOF,mBAAmBE;AAC5B,EAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
-
import type { Theme } from '@payloadcms/ui';
|
|
3
|
-
import type { ClientConfig, LanguageOptions, SanitizedPermissions, ServerFunctionClient, User } from 'payload';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import '@payloadcms/ui/scss/app.scss';
|
|
6
|
-
export type RootLayoutData = {
|
|
7
|
-
clientConfig: ClientConfig;
|
|
8
|
-
dateFNSKey: I18nClient['dateFNSKey'];
|
|
9
|
-
fallbackLang: string;
|
|
10
|
-
isNavOpen: boolean;
|
|
11
|
-
languageCode: string;
|
|
12
|
-
languageOptions: LanguageOptions;
|
|
13
|
-
locale?: string;
|
|
14
|
-
permissions: SanitizedPermissions;
|
|
15
|
-
/**
|
|
16
|
-
* Custom admin provider tree (`config.admin.components.providers`) nested
|
|
17
|
-
* around the router `<Outlet />`. Built unrendered by `getLayoutData`; the
|
|
18
|
-
* layout server function renders it to an RSC payload before it reaches the
|
|
19
|
-
* client. `undefined` when no custom providers are configured.
|
|
20
|
-
*/
|
|
21
|
-
providers?: React.ReactNode;
|
|
22
|
-
theme: Theme;
|
|
23
|
-
translations: I18nClient['translations'];
|
|
24
|
-
user: null | User;
|
|
25
|
-
};
|
|
26
|
-
export type RootLayoutProps = {
|
|
27
|
-
readonly children: React.ReactNode;
|
|
28
|
-
readonly data: RootLayoutData;
|
|
29
|
-
readonly serverFunction: ServerFunctionClient;
|
|
30
|
-
};
|
|
31
|
-
export declare function RootLayout({ children, data, serverFunction }: RootLayoutProps): React.JSX.Element;
|
|
32
|
-
//# sourceMappingURL=index.d.ts.map
|