@payloadcms/tanstack-start 4.0.0-internal.183b315
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/LICENSE.md +22 -0
- package/dist/@types/assets.d.js +2 -0
- package/dist/@types/assets.d.js.map +1 -0
- package/dist/auth/login.d.ts +17 -0
- package/dist/auth/login.d.ts.map +1 -0
- package/dist/auth/login.js +50 -0
- package/dist/auth/login.js.map +1 -0
- package/dist/auth/logout.d.ts +9 -0
- package/dist/auth/logout.d.ts.map +1 -0
- package/dist/auth/logout.js +51 -0
- package/dist/auth/logout.js.map +1 -0
- package/dist/auth/refresh.d.ts +8 -0
- package/dist/auth/refresh.d.ts.map +1 -0
- package/dist/auth/refresh.js +53 -0
- package/dist/auth/refresh.js.map +1 -0
- package/dist/auth/switchLanguage.d.ts +6 -0
- package/dist/auth/switchLanguage.d.ts.map +1 -0
- package/dist/auth/switchLanguage.js +11 -0
- package/dist/auth/switchLanguage.js.map +1 -0
- package/dist/elements/DocumentHeaderClient/index.d.ts +16 -0
- package/dist/elements/DocumentHeaderClient/index.d.ts.map +1 -0
- package/dist/elements/DocumentHeaderClient/index.js +116 -0
- package/dist/elements/DocumentHeaderClient/index.js.map +1 -0
- package/dist/elements/RenderComponent/index.d.ts +10 -0
- package/dist/elements/RenderComponent/index.d.ts.map +1 -0
- package/dist/elements/RenderComponent/index.js +12 -0
- package/dist/elements/RenderComponent/index.js.map +1 -0
- package/dist/elements/RouterAdapter/index.d.ts +3 -0
- package/dist/elements/RouterAdapter/index.d.ts.map +1 -0
- package/dist/elements/RouterAdapter/index.js +118 -0
- package/dist/elements/RouterAdapter/index.js.map +1 -0
- package/dist/exports/client.d.ts +4 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +6 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/layouts.d.ts +5 -0
- package/dist/exports/layouts.d.ts.map +1 -0
- package/dist/exports/layouts.js +4 -0
- package/dist/exports/layouts.js.map +1 -0
- package/dist/exports/rsc.browser.d.ts +12 -0
- package/dist/exports/rsc.browser.d.ts.map +1 -0
- package/dist/exports/rsc.browser.js +12 -0
- package/dist/exports/rsc.browser.js.map +1 -0
- package/dist/exports/rsc.d.ts +5 -0
- package/dist/exports/rsc.d.ts.map +1 -0
- package/dist/exports/rsc.js +6 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/exports/server.d.ts +16 -0
- package/dist/exports/server.d.ts.map +1 -0
- package/dist/exports/server.js +17 -0
- package/dist/exports/server.js.map +1 -0
- package/dist/exports/vite.d.ts +3 -0
- package/dist/exports/vite.d.ts.map +1 -0
- package/dist/exports/vite.js +3 -0
- package/dist/exports/vite.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/Root/getLayoutData.d.ts +12 -0
- package/dist/layouts/Root/getLayoutData.d.ts.map +1 -0
- package/dist/layouts/Root/getLayoutData.js +55 -0
- package/dist/layouts/Root/getLayoutData.js.map +1 -0
- package/dist/layouts/Root/index.d.ts +25 -0
- package/dist/layouts/Root/index.d.ts.map +1 -0
- package/dist/layouts/Root/index.js +51 -0
- package/dist/layouts/Root/index.js.map +1 -0
- package/dist/node/cssLoader.d.mts +3 -0
- package/dist/node/cssLoader.d.mts.map +1 -0
- package/dist/node/cssLoader.js +70 -0
- package/dist/node/cssLoader.js.map +1 -0
- package/dist/node/cssLoader.mjs +75 -0
- package/dist/node/registerCssLoader.d.mts +2 -0
- package/dist/node/registerCssLoader.d.mts.map +1 -0
- package/dist/node/registerCssLoader.js +10 -0
- package/dist/node/registerCssLoader.js.map +1 -0
- package/dist/node/registerCssLoader.mjs +10 -0
- package/dist/rsc/CollectionCards.d.ts +4 -0
- package/dist/rsc/CollectionCards.d.ts.map +1 -0
- package/dist/rsc/CollectionCards.js +12 -0
- package/dist/rsc/CollectionCards.js.map +1 -0
- package/dist/rsc/HierarchyTypeFieldServer.d.ts +9 -0
- package/dist/rsc/HierarchyTypeFieldServer.d.ts.map +1 -0
- package/dist/rsc/HierarchyTypeFieldServer.js +35 -0
- package/dist/rsc/HierarchyTypeFieldServer.js.map +1 -0
- package/dist/rsc/renderOnDemand.d.ts +15 -0
- package/dist/rsc/renderOnDemand.d.ts.map +1 -0
- package/dist/rsc/renderOnDemand.js +25 -0
- package/dist/rsc/renderOnDemand.js.map +1 -0
- package/dist/rsc/renderPayloadRSC.d.ts +6 -0
- package/dist/rsc/renderPayloadRSC.d.ts.map +1 -0
- package/dist/rsc/renderPayloadRSC.js +6 -0
- package/dist/rsc/renderPayloadRSC.js.map +1 -0
- package/dist/utilities/devReloadStrategy.d.ts +10 -0
- package/dist/utilities/devReloadStrategy.d.ts.map +1 -0
- package/dist/utilities/devReloadStrategy.js +27 -0
- package/dist/utilities/devReloadStrategy.js.map +1 -0
- package/dist/utilities/getExistingAuthToken.d.ts +7 -0
- package/dist/utilities/getExistingAuthToken.d.ts.map +1 -0
- package/dist/utilities/getExistingAuthToken.js +18 -0
- package/dist/utilities/getExistingAuthToken.js.map +1 -0
- package/dist/utilities/getPreferences.d.ts +10 -0
- package/dist/utilities/getPreferences.d.ts.map +1 -0
- package/dist/utilities/getPreferences.js +33 -0
- package/dist/utilities/getPreferences.js.map +1 -0
- package/dist/utilities/getRequestI18n.server.d.ts +12 -0
- package/dist/utilities/getRequestI18n.server.d.ts.map +1 -0
- package/dist/utilities/getRequestI18n.server.js +25 -0
- package/dist/utilities/getRequestI18n.server.js.map +1 -0
- package/dist/utilities/getRequestLocale.d.ts +7 -0
- package/dist/utilities/getRequestLocale.d.ts.map +1 -0
- package/dist/utilities/getRequestLocale.js +20 -0
- package/dist/utilities/getRequestLocale.js.map +1 -0
- package/dist/utilities/getRequestTheme.d.ts +10 -0
- package/dist/utilities/getRequestTheme.d.ts.map +1 -0
- package/dist/utilities/getRequestTheme.js +25 -0
- package/dist/utilities/getRequestTheme.js.map +1 -0
- package/dist/utilities/graphqlHandler.server.d.ts +12 -0
- package/dist/utilities/graphqlHandler.server.d.ts.map +1 -0
- package/dist/utilities/graphqlHandler.server.js +129 -0
- package/dist/utilities/graphqlHandler.server.js.map +1 -0
- package/dist/utilities/handleServerFunctions.d.ts +20 -0
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -0
- package/dist/utilities/handleServerFunctions.js +60 -0
- package/dist/utilities/handleServerFunctions.js.map +1 -0
- package/dist/utilities/importMap.server.d.ts +9 -0
- package/dist/utilities/importMap.server.d.ts.map +1 -0
- package/dist/utilities/importMap.server.js +12 -0
- package/dist/utilities/importMap.server.js.map +1 -0
- package/dist/utilities/initReq.server.d.ts +19 -0
- package/dist/utilities/initReq.server.d.ts.map +1 -0
- package/dist/utilities/initReq.server.js +87 -0
- package/dist/utilities/initReq.server.js.map +1 -0
- package/dist/utilities/meta.d.ts +70 -0
- package/dist/utilities/meta.d.ts.map +1 -0
- package/dist/utilities/meta.js +142 -0
- package/dist/utilities/meta.js.map +1 -0
- package/dist/utilities/serializeForRsc.d.ts +26 -0
- package/dist/utilities/serializeForRsc.d.ts.map +1 -0
- package/dist/utilities/serializeForRsc.js +105 -0
- package/dist/utilities/serializeForRsc.js.map +1 -0
- package/dist/utilities/serverAdapter.server.d.ts +36 -0
- package/dist/utilities/serverAdapter.server.d.ts.map +1 -0
- package/dist/utilities/serverAdapter.server.js +130 -0
- package/dist/utilities/serverAdapter.server.js.map +1 -0
- package/dist/utilities/serverFunctionHandlers.d.ts +18 -0
- package/dist/utilities/serverFunctionHandlers.d.ts.map +1 -0
- package/dist/utilities/serverFunctionHandlers.js +17 -0
- package/dist/utilities/serverFunctionHandlers.js.map +1 -0
- package/dist/utilities/setPayloadAuthCookie.d.ts +9 -0
- package/dist/utilities/setPayloadAuthCookie.d.ts.map +1 -0
- package/dist/utilities/setPayloadAuthCookie.js +31 -0
- package/dist/utilities/setPayloadAuthCookie.js.map +1 -0
- package/dist/utilities/toSerializable.d.ts +2 -0
- package/dist/utilities/toSerializable.d.ts.map +1 -0
- package/dist/utilities/toSerializable.js +111 -0
- package/dist/utilities/toSerializable.js.map +1 -0
- package/dist/vite/constants.d.ts +37 -0
- package/dist/vite/constants.d.ts.map +1 -0
- package/dist/vite/constants.js +129 -0
- package/dist/vite/constants.js.map +1 -0
- package/dist/vite/importProtection.d.ts +14 -0
- package/dist/vite/importProtection.d.ts.map +1 -0
- package/dist/vite/importProtection.js +54 -0
- package/dist/vite/importProtection.js.map +1 -0
- package/dist/vite/plugin.d.ts +38 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +182 -0
- package/dist/vite/plugin.js.map +1 -0
- package/dist/vite/plugins/clientModuleResolution.d.ts +14 -0
- package/dist/vite/plugins/clientModuleResolution.d.ts.map +1 -0
- package/dist/vite/plugins/clientModuleResolution.js +98 -0
- package/dist/vite/plugins/clientModuleResolution.js.map +1 -0
- package/dist/vite/plugins/devTransforms.d.ts +8 -0
- package/dist/vite/plugins/devTransforms.d.ts.map +1 -0
- package/dist/vite/plugins/devTransforms.js +56 -0
- package/dist/vite/plugins/devTransforms.js.map +1 -0
- package/dist/vite/plugins/reactDomServerInRsc.d.ts +27 -0
- package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +1 -0
- package/dist/vite/plugins/reactDomServerInRsc.js +90 -0
- package/dist/vite/plugins/reactDomServerInRsc.js.map +1 -0
- package/dist/vite/plugins/stripDistStyleImports.d.ts +21 -0
- package/dist/vite/plugins/stripDistStyleImports.d.ts.map +1 -0
- package/dist/vite/plugins/stripDistStyleImports.js +89 -0
- package/dist/vite/plugins/stripDistStyleImports.js.map +1 -0
- package/dist/vite/plugins/wrapCjsForClient.d.ts +15 -0
- package/dist/vite/plugins/wrapCjsForClient.d.ts.map +1 -0
- package/dist/vite/plugins/wrapCjsForClient.js +106 -0
- package/dist/vite/plugins/wrapCjsForClient.js.map +1 -0
- package/package.json +106 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { builtinModules } from 'node:module';
|
|
2
|
+
/**
|
|
3
|
+
* Specifiers that must never appear in the client module graph. These are the
|
|
4
|
+
* server-only Payload entry points plus Node.js built-ins and a handful of
|
|
5
|
+
* Node-only npm packages that Payload pulls in transitively.
|
|
6
|
+
*/ export const serverOnlyClientSpecifiers = [
|
|
7
|
+
/^node:/,
|
|
8
|
+
new RegExp(`^(${builtinModules.join('|')})(\\/|$)`),
|
|
9
|
+
'@payload-config',
|
|
10
|
+
/^@payloadcms\/next\/rsc/,
|
|
11
|
+
/^@payloadcms\/richtext-lexical\/rsc/,
|
|
12
|
+
/^@payloadcms\/richtext-slate\/rsc/,
|
|
13
|
+
'@payloadcms/ui/server',
|
|
14
|
+
/^@payloadcms\/tanstack-start\/(layouts|rsc|server|views\/server)/,
|
|
15
|
+
'sharp',
|
|
16
|
+
'busboy',
|
|
17
|
+
'croner',
|
|
18
|
+
'pino',
|
|
19
|
+
'pino-pretty',
|
|
20
|
+
'prompts',
|
|
21
|
+
'ws',
|
|
22
|
+
'undici',
|
|
23
|
+
'get-tsconfig',
|
|
24
|
+
/^file-type/,
|
|
25
|
+
/^react-dom\/server/
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Allowlist callback for the `tanstackStart` plugin's import-protection. These
|
|
29
|
+
* are the legitimate cross-environment imports in our monorepo that we want
|
|
30
|
+
* to permit even when they appear to cross a server/client boundary.
|
|
31
|
+
*/ export function onImportProtectionViolation(violation) {
|
|
32
|
+
const info = violation;
|
|
33
|
+
const allowedClientFileImporters = /\/richtext-lexical\/.*\/exports\/client\/|\/tanstack-start\/.*\/views\/AdminView|\/ui\//;
|
|
34
|
+
if (info.envType === 'server' && info.resolved?.includes('.client.') && allowedClientFileImporters.test(info.importer)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (info.importer.includes('/richtext-lexical/') && info.importer.includes('/field/Diff/')) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (info.importer.includes('/packages/payload/') || info.importer.includes('/payload/dist/')) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (info.importer.includes('@payloadcms/ui') && (info.importer.includes('/exports/rsc/') || info.importer.includes('/rsc/index'))) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (info.envType === 'server' && info.importer.includes('vite-rsc/client-references')) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export const defaultImportProtectionIgnoreImporters = [
|
|
51
|
+
/^src\/importMap\.js(?:\?.*)?$/
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=importProtection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vite/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|views\\/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 =\n /\\/richtext-lexical\\/.*\\/exports\\/client\\/|\\/tanstack-start\\/.*\\/views\\/AdminView|\\/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,6BACJ;IAEF,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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PluginOption, UserConfigFnObject } from 'vite';
|
|
2
|
+
export interface PayloadPluginOptions {
|
|
3
|
+
/** Additional resolve aliases */
|
|
4
|
+
additionalAliases?: Array<{
|
|
5
|
+
find: RegExp | string;
|
|
6
|
+
replacement: string;
|
|
7
|
+
}>;
|
|
8
|
+
/** Additional import protection ignoreImporters patterns */
|
|
9
|
+
additionalIgnoreImporters?: RegExp[];
|
|
10
|
+
/** Extra optimizeDeps.include entries */
|
|
11
|
+
additionalOptimizeDepsInclude?: string[];
|
|
12
|
+
/** Extra ssr.external entries */
|
|
13
|
+
additionalSsrExternal?: string[];
|
|
14
|
+
/** Path to the user's payload.config.ts (required) */
|
|
15
|
+
payloadConfigPath: string;
|
|
16
|
+
/** Extra Vite plugins to include */
|
|
17
|
+
plugins?: PluginOption[];
|
|
18
|
+
/** @vitejs/plugin-react instance — must be passed by consumer to ensure correct resolution */
|
|
19
|
+
reactPlugin: PluginOption;
|
|
20
|
+
/** TanStack router routes directory relative to srcDirectory. Defaults to 'app' */
|
|
21
|
+
routesDirectory?: string;
|
|
22
|
+
/** @vitejs/plugin-rsc instance — required for RSC support, must be passed by consumer */
|
|
23
|
+
rscPlugin: PluginOption;
|
|
24
|
+
/** TanStack source directory. Defaults to 'src' */
|
|
25
|
+
srcDirectory?: string;
|
|
26
|
+
/** tanstackStart from '@tanstack/react-start/plugin/vite' — must be passed by consumer to ensure correct resolution */
|
|
27
|
+
tanstackStart: typeof import('@tanstack/react-start/plugin/vite').tanstackStart;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Vite plugin for Payload + TanStack Start. The Vite-side counterpart to
|
|
31
|
+
* `withPayload` for Next.js: it configures the Vite environment so the Payload
|
|
32
|
+
* admin can run, then composes the TanStack Start plugin with two small
|
|
33
|
+
* Payload-specific workarounds (dev HMR injection, SSR style stripping). Each
|
|
34
|
+
* remaining workaround lives in its own file under `./plugins/` so it can be
|
|
35
|
+
* deleted individually once the corresponding upstream fix lands.
|
|
36
|
+
*/
|
|
37
|
+
export declare function payloadPlugin(options: PayloadPluginOptions): UserConfigFnObject;
|
|
38
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/vite/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAsB5D,MAAM,WAAW,oBAAoB;IACnC,iCAAiC;IACjC,iBAAiB,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACzE,4DAA4D;IAC5D,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;IACpC,yCAAyC;IACzC,6BAA6B,CAAC,EAAE,MAAM,EAAE,CAAA;IACxC,iCAAiC;IACjC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAA;IAChC,sDAAsD;IACtD,iBAAiB,EAAE,MAAM,CAAA;IACzB,oCAAoC;IACpC,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB,8FAA8F;IAC9F,WAAW,EAAE,YAAY,CAAA;IACzB,mFAAmF;IACnF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,yFAAyF;IACzF,SAAS,EAAE,YAAY,CAAA;IACvB,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,uHAAuH;IACvH,aAAa,EAAE,cAAc,mCAAmC,EAAE,aAAa,CAAA;CAChF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,kBAAkB,CAkI/E"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults, payloadNoExternalPatterns, payloadRscNoExternalPatterns, ssrExternalPackages } from './constants.js';
|
|
3
|
+
import { defaultImportProtectionIgnoreImporters, onImportProtectionViolation, serverOnlyClientSpecifiers } from './importProtection.js';
|
|
4
|
+
import { clientModuleResolution } from './plugins/clientModuleResolution.js';
|
|
5
|
+
import { payloadDevTransforms } from './plugins/devTransforms.js';
|
|
6
|
+
import { reactDomServerInRsc } from './plugins/reactDomServerInRsc.js';
|
|
7
|
+
import { ssrStripDistStyleImports } from './plugins/stripDistStyleImports.js';
|
|
8
|
+
import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
|
|
9
|
+
/**
|
|
10
|
+
* Vite plugin for Payload + TanStack Start. The Vite-side counterpart to
|
|
11
|
+
* `withPayload` for Next.js: it configures the Vite environment so the Payload
|
|
12
|
+
* admin can run, then composes the TanStack Start plugin with two small
|
|
13
|
+
* Payload-specific workarounds (dev HMR injection, SSR style stripping). Each
|
|
14
|
+
* remaining workaround lives in its own file under `./plugins/` so it can be
|
|
15
|
+
* deleted individually once the corresponding upstream fix lands.
|
|
16
|
+
*/ export function payloadPlugin(options) {
|
|
17
|
+
const { additionalAliases = [], additionalIgnoreImporters = [], additionalOptimizeDepsInclude = [], additionalSsrExternal = [], payloadConfigPath, plugins: extraPlugins = [], reactPlugin, routesDirectory = 'app', rscPlugin, srcDirectory = 'src', tanstackStart } = options;
|
|
18
|
+
process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED = 'true';
|
|
19
|
+
return (_env)=>({
|
|
20
|
+
css: {
|
|
21
|
+
preprocessorOptions: {
|
|
22
|
+
scss: {
|
|
23
|
+
silenceDeprecations: [
|
|
24
|
+
'import',
|
|
25
|
+
'global-builtin'
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
define: {
|
|
31
|
+
global: 'globalThis',
|
|
32
|
+
'process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED': JSON.stringify('true')
|
|
33
|
+
},
|
|
34
|
+
environments: {
|
|
35
|
+
rsc: {
|
|
36
|
+
resolve: {
|
|
37
|
+
noExternal: payloadRscNoExternalPatterns
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
ssr: {
|
|
41
|
+
resolve: {
|
|
42
|
+
noExternal: payloadNoExternalPatterns
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
optimizeDeps: {
|
|
47
|
+
exclude: optimizeDepsExcludeDefaults,
|
|
48
|
+
include: [
|
|
49
|
+
...optimizeDepsIncludeDefaults,
|
|
50
|
+
...additionalOptimizeDepsInclude
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
plugins: [
|
|
54
|
+
clientModuleResolution(),
|
|
55
|
+
wrapCjsForClient(),
|
|
56
|
+
ssrStripDistStyleImports(),
|
|
57
|
+
reactDomServerInRsc(),
|
|
58
|
+
payloadDevTransforms(),
|
|
59
|
+
rscPlugin,
|
|
60
|
+
tanstackStart({
|
|
61
|
+
importProtection: {
|
|
62
|
+
client: {
|
|
63
|
+
excludeFiles: [],
|
|
64
|
+
specifiers: serverOnlyClientSpecifiers
|
|
65
|
+
},
|
|
66
|
+
ignoreImporters: [
|
|
67
|
+
...defaultImportProtectionIgnoreImporters,
|
|
68
|
+
...additionalIgnoreImporters
|
|
69
|
+
],
|
|
70
|
+
include: [
|
|
71
|
+
'**/*'
|
|
72
|
+
],
|
|
73
|
+
mockAccess: 'warn',
|
|
74
|
+
onViolation: onImportProtectionViolation,
|
|
75
|
+
// Disable TanStack Start's default `**/*.client.*` file-based denial in
|
|
76
|
+
// the SSR environment. Payload uses the `.client.tsx` filename suffix
|
|
77
|
+
// for React Client Components (with a `'use client'` directive) that
|
|
78
|
+
// MUST be server-rendered to HTML during SSR. The default rule would
|
|
79
|
+
// otherwise replace those files with an `import-protection mock` Proxy
|
|
80
|
+
// during SSR, which crashes React (TypeError: Cannot convert object to
|
|
81
|
+
// primitive value) the moment React tries to format a warning that
|
|
82
|
+
// mentions one of these components.
|
|
83
|
+
server: {
|
|
84
|
+
files: []
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
// Disable TanStack Router's automatic per-route code-splitting.
|
|
88
|
+
//
|
|
89
|
+
// With splitting enabled each route's `component` is fetched lazily
|
|
90
|
+
// via `?tsr-split=component` after the initial SSR HTML is streamed.
|
|
91
|
+
// Until that lazy chunk lands the rendered admin tree has no client
|
|
92
|
+
// React attached, so any button clicks (e.g. the
|
|
93
|
+
// `#toggle-list-filters` chevron in `<ListControls />`) hit a static
|
|
94
|
+
// DOM, the click is dropped, and once the chunk finally loads the
|
|
95
|
+
// component re-mounts with its initial `useState` instead of the
|
|
96
|
+
// toggled value. That single behaviour was the root cause of the
|
|
97
|
+
// "page renders but nothing is interactive" tanstack-start E2E
|
|
98
|
+
// failures (`#list-controls-where`, `[data-lexical-editor]`, etc.) -
|
|
99
|
+
// playwright traces show "Download the React DevTools" landing
|
|
100
|
+
// *after* the playwright click, confirming late hydration.
|
|
101
|
+
//
|
|
102
|
+
// We pass BOTH knobs because `tanstackStart`'s schema silently
|
|
103
|
+
// strips the user-supplied `autoCodeSplitting` (its `tsrConfig`
|
|
104
|
+
// does `configSchema.omit({ autoCodeSplitting: true, target: true
|
|
105
|
+
// })`) and then leaves the value `undefined` — which is fine for
|
|
106
|
+
// the conditional inside `unpluginRouterComposedFactory`, but the
|
|
107
|
+
// TanStack Start vite plugin *unconditionally* installs the router
|
|
108
|
+
// code-splitter via `tanStackRouterCodeSplitter(...)` regardless.
|
|
109
|
+
// The only knob that survives all of that and is honoured by the
|
|
110
|
+
// splitter is `router.codeSplittingOptions.defaultBehavior` — set
|
|
111
|
+
// to an empty array, the splitter still walks each `createFileRoute`
|
|
112
|
+
// file but produces no virtual `?tsr-split=...` modules, so every
|
|
113
|
+
// route component ships in the initial bundle and hydration starts
|
|
114
|
+
// immediately on first paint. We keep `autoCodeSplitting: false` as
|
|
115
|
+
// a belt-and-braces signal in case the start plugin ever stops
|
|
116
|
+
// dropping it.
|
|
117
|
+
//
|
|
118
|
+
// Eager-loading routes ships a slightly larger initial bundle but
|
|
119
|
+
// makes the admin actually interactive on first paint.
|
|
120
|
+
router: {
|
|
121
|
+
autoCodeSplitting: false,
|
|
122
|
+
codeSplittingOptions: {
|
|
123
|
+
defaultBehavior: []
|
|
124
|
+
},
|
|
125
|
+
// Exclude only generated importMap files. Admin form saves are
|
|
126
|
+
// dispatched via `runPayloadServerFn` (a TanStack Start
|
|
127
|
+
// `createServerFn`) rather than a hand-rolled route, so there is
|
|
128
|
+
// no longer an `api.server-function.ts` to special-case here.
|
|
129
|
+
routeFileIgnorePattern: 'importMap\\.(?:js|server\\.ts)$',
|
|
130
|
+
routesDirectory
|
|
131
|
+
},
|
|
132
|
+
rsc: {
|
|
133
|
+
enabled: true
|
|
134
|
+
},
|
|
135
|
+
srcDirectory
|
|
136
|
+
}),
|
|
137
|
+
reactPlugin,
|
|
138
|
+
...extraPlugins
|
|
139
|
+
],
|
|
140
|
+
resolve: {
|
|
141
|
+
alias: [
|
|
142
|
+
{
|
|
143
|
+
find: '@payload-config',
|
|
144
|
+
replacement: path.resolve(payloadConfigPath)
|
|
145
|
+
},
|
|
146
|
+
...additionalAliases
|
|
147
|
+
],
|
|
148
|
+
dedupe: [
|
|
149
|
+
'react',
|
|
150
|
+
'react-dom',
|
|
151
|
+
'scheduler',
|
|
152
|
+
'@payloadcms/ui'
|
|
153
|
+
],
|
|
154
|
+
extensions: [
|
|
155
|
+
'.mjs',
|
|
156
|
+
'.js',
|
|
157
|
+
'.mts',
|
|
158
|
+
'.ts',
|
|
159
|
+
'.jsx',
|
|
160
|
+
'.tsx',
|
|
161
|
+
'.json'
|
|
162
|
+
],
|
|
163
|
+
tsconfigPaths: true
|
|
164
|
+
},
|
|
165
|
+
server: {
|
|
166
|
+
warmup: {
|
|
167
|
+
clientFiles: [
|
|
168
|
+
'./src/importMap.js'
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
ssr: {
|
|
173
|
+
external: [
|
|
174
|
+
...ssrExternalPackages,
|
|
175
|
+
...additionalSsrExternal
|
|
176
|
+
],
|
|
177
|
+
noExternal: payloadNoExternalPatterns
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vite/plugin.ts"],"sourcesContent":["import type { PluginOption, UserConfigFnObject } from 'vite'\n\nimport path from 'node:path'\n\nimport {\n optimizeDepsExcludeDefaults,\n optimizeDepsIncludeDefaults,\n payloadNoExternalPatterns,\n payloadRscNoExternalPatterns,\n ssrExternalPackages,\n} from './constants.js'\nimport {\n defaultImportProtectionIgnoreImporters,\n onImportProtectionViolation,\n serverOnlyClientSpecifiers,\n} from './importProtection.js'\nimport { clientModuleResolution } from './plugins/clientModuleResolution.js'\nimport { payloadDevTransforms } from './plugins/devTransforms.js'\nimport { reactDomServerInRsc } from './plugins/reactDomServerInRsc.js'\nimport { ssrStripDistStyleImports } from './plugins/stripDistStyleImports.js'\nimport { wrapCjsForClient } from './plugins/wrapCjsForClient.js'\n\nexport interface PayloadPluginOptions {\n /** Additional resolve aliases */\n additionalAliases?: Array<{ find: RegExp | string; replacement: string }>\n /** Additional import protection ignoreImporters patterns */\n additionalIgnoreImporters?: RegExp[]\n /** Extra optimizeDeps.include entries */\n additionalOptimizeDepsInclude?: string[]\n /** Extra ssr.external entries */\n additionalSsrExternal?: string[]\n /** Path to the user's payload.config.ts (required) */\n payloadConfigPath: string\n /** Extra Vite plugins to include */\n plugins?: PluginOption[]\n /** @vitejs/plugin-react instance — must be passed by consumer to ensure correct resolution */\n reactPlugin: PluginOption\n /** TanStack router routes directory relative to srcDirectory. Defaults to 'app' */\n routesDirectory?: string\n /** @vitejs/plugin-rsc instance — required for RSC support, must be passed by consumer */\n rscPlugin: PluginOption\n /** TanStack source directory. Defaults to 'src' */\n srcDirectory?: string\n /** tanstackStart from '@tanstack/react-start/plugin/vite' — must be passed by consumer to ensure correct resolution */\n tanstackStart: typeof import('@tanstack/react-start/plugin/vite').tanstackStart\n}\n\n/**\n * Vite plugin for Payload + TanStack Start. The Vite-side counterpart to\n * `withPayload` for Next.js: it configures the Vite environment so the Payload\n * admin can run, then composes the TanStack Start plugin with two small\n * Payload-specific workarounds (dev HMR injection, SSR style stripping). Each\n * remaining workaround lives in its own file under `./plugins/` so it can be\n * deleted individually once the corresponding upstream fix lands.\n */\nexport function payloadPlugin(options: PayloadPluginOptions): UserConfigFnObject {\n const {\n additionalAliases = [],\n additionalIgnoreImporters = [],\n additionalOptimizeDepsInclude = [],\n additionalSsrExternal = [],\n payloadConfigPath,\n plugins: extraPlugins = [],\n reactPlugin,\n routesDirectory = 'app',\n rscPlugin,\n srcDirectory = 'src',\n tanstackStart,\n } = options\n\n process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED = 'true'\n\n return (_env) => ({\n css: {\n preprocessorOptions: {\n scss: {\n silenceDeprecations: ['import', 'global-builtin'],\n } as any,\n },\n },\n define: {\n global: 'globalThis',\n 'process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED': JSON.stringify('true'),\n },\n environments: {\n rsc: { resolve: { noExternal: payloadRscNoExternalPatterns } },\n ssr: { resolve: { noExternal: payloadNoExternalPatterns } },\n } as any,\n optimizeDeps: {\n exclude: optimizeDepsExcludeDefaults,\n include: [...optimizeDepsIncludeDefaults, ...additionalOptimizeDepsInclude],\n },\n plugins: [\n clientModuleResolution(),\n wrapCjsForClient(),\n ssrStripDistStyleImports(),\n reactDomServerInRsc(),\n payloadDevTransforms(),\n rscPlugin,\n tanstackStart({\n importProtection: {\n client: { excludeFiles: [], specifiers: serverOnlyClientSpecifiers },\n ignoreImporters: [\n ...defaultImportProtectionIgnoreImporters,\n ...additionalIgnoreImporters,\n ],\n include: ['**/*'],\n mockAccess: 'warn',\n onViolation: onImportProtectionViolation,\n // Disable TanStack Start's default `**/*.client.*` file-based denial in\n // the SSR environment. Payload uses the `.client.tsx` filename suffix\n // for React Client Components (with a `'use client'` directive) that\n // MUST be server-rendered to HTML during SSR. The default rule would\n // otherwise replace those files with an `import-protection mock` Proxy\n // during SSR, which crashes React (TypeError: Cannot convert object to\n // primitive value) the moment React tries to format a warning that\n // mentions one of these components.\n server: { files: [] },\n },\n // Disable TanStack Router's automatic per-route code-splitting.\n //\n // With splitting enabled each route's `component` is fetched lazily\n // via `?tsr-split=component` after the initial SSR HTML is streamed.\n // Until that lazy chunk lands the rendered admin tree has no client\n // React attached, so any button clicks (e.g. the\n // `#toggle-list-filters` chevron in `<ListControls />`) hit a static\n // DOM, the click is dropped, and once the chunk finally loads the\n // component re-mounts with its initial `useState` instead of the\n // toggled value. That single behaviour was the root cause of the\n // \"page renders but nothing is interactive\" tanstack-start E2E\n // failures (`#list-controls-where`, `[data-lexical-editor]`, etc.) -\n // playwright traces show \"Download the React DevTools\" landing\n // *after* the playwright click, confirming late hydration.\n //\n // We pass BOTH knobs because `tanstackStart`'s schema silently\n // strips the user-supplied `autoCodeSplitting` (its `tsrConfig`\n // does `configSchema.omit({ autoCodeSplitting: true, target: true\n // })`) and then leaves the value `undefined` — which is fine for\n // the conditional inside `unpluginRouterComposedFactory`, but the\n // TanStack Start vite plugin *unconditionally* installs the router\n // code-splitter via `tanStackRouterCodeSplitter(...)` regardless.\n // The only knob that survives all of that and is honoured by the\n // splitter is `router.codeSplittingOptions.defaultBehavior` — set\n // to an empty array, the splitter still walks each `createFileRoute`\n // file but produces no virtual `?tsr-split=...` modules, so every\n // route component ships in the initial bundle and hydration starts\n // immediately on first paint. We keep `autoCodeSplitting: false` as\n // a belt-and-braces signal in case the start plugin ever stops\n // dropping it.\n //\n // Eager-loading routes ships a slightly larger initial bundle but\n // makes the admin actually interactive on first paint.\n router: {\n autoCodeSplitting: false,\n codeSplittingOptions: { defaultBehavior: [] },\n // Exclude only generated importMap files. Admin form saves are\n // dispatched via `runPayloadServerFn` (a TanStack Start\n // `createServerFn`) rather than a hand-rolled route, so there is\n // no longer an `api.server-function.ts` to special-case here.\n routeFileIgnorePattern: 'importMap\\\\.(?:js|server\\\\.ts)$',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }),\n reactPlugin,\n ...extraPlugins,\n ],\n resolve: {\n alias: [\n { find: '@payload-config', replacement: path.resolve(payloadConfigPath) },\n ...additionalAliases,\n ],\n dedupe: ['react', 'react-dom', 'scheduler', '@payloadcms/ui'],\n extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],\n tsconfigPaths: true,\n } as any,\n server: {\n warmup: { clientFiles: ['./src/importMap.js'] },\n },\n ssr: {\n external: [...ssrExternalPackages, ...additionalSsrExternal],\n noExternal: payloadNoExternalPatterns,\n },\n })\n}\n"],"names":["path","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadNoExternalPatterns","payloadRscNoExternalPatterns","ssrExternalPackages","defaultImportProtectionIgnoreImporters","onImportProtectionViolation","serverOnlyClientSpecifiers","clientModuleResolution","payloadDevTransforms","reactDomServerInRsc","ssrStripDistStyleImports","wrapCjsForClient","payloadPlugin","options","additionalAliases","additionalIgnoreImporters","additionalOptimizeDepsInclude","additionalSsrExternal","payloadConfigPath","plugins","extraPlugins","reactPlugin","routesDirectory","rscPlugin","srcDirectory","tanstackStart","process","env","PAYLOAD_FRAMEWORK_RSC_ENABLED","_env","css","preprocessorOptions","scss","silenceDeprecations","define","global","JSON","stringify","environments","rsc","resolve","noExternal","ssr","optimizeDeps","exclude","include","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","files","router","autoCodeSplitting","codeSplittingOptions","defaultBehavior","routeFileIgnorePattern","enabled","alias","find","replacement","dedupe","extensions","tsconfigPaths","warmup","clientFiles","external"],"mappings":"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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PluginOption } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Client-side module resolution:
|
|
4
|
+
* 1. Stubs RSC modules (`@payloadcms/.../rsc`) with no-op components so the
|
|
5
|
+
* Vite optimizer never tries to bundle their server implementations.
|
|
6
|
+
* 2. Redirects bare `payload` imports made from user code (outside of
|
|
7
|
+
* `node_modules` and our own packages) to `payload/shared`. The main
|
|
8
|
+
* `payload` entry has top-level side effects requiring Node.js APIs.
|
|
9
|
+
* 3. Resolves `/client` subpath exports for `@payloadcms/plugin-*` and
|
|
10
|
+
* `@payloadcms/storage-*` packages when normal Vite resolution fails in
|
|
11
|
+
* monorepo dev (no `dist/` built yet).
|
|
12
|
+
*/
|
|
13
|
+
export declare function clientModuleResolution(): PluginOption;
|
|
14
|
+
//# sourceMappingURL=clientModuleResolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientModuleResolution.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/clientModuleResolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAKxC;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CA+ErD"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Client-side module resolution:
|
|
5
|
+
* 1. Stubs RSC modules (`@payloadcms/.../rsc`) with no-op components so the
|
|
6
|
+
* Vite optimizer never tries to bundle their server implementations.
|
|
7
|
+
* 2. Redirects bare `payload` imports made from user code (outside of
|
|
8
|
+
* `node_modules` and our own packages) to `payload/shared`. The main
|
|
9
|
+
* `payload` entry has top-level side effects requiring Node.js APIs.
|
|
10
|
+
* 3. Resolves `/client` subpath exports for `@payloadcms/plugin-*` and
|
|
11
|
+
* `@payloadcms/storage-*` packages when normal Vite resolution fails in
|
|
12
|
+
* monorepo dev (no `dist/` built yet).
|
|
13
|
+
*/ export function clientModuleResolution() {
|
|
14
|
+
const stubPrefix = '\0payload:server-stub:';
|
|
15
|
+
const serverOnlyPatterns = [
|
|
16
|
+
/^@payloadcms\/richtext-lexical\/rsc$/,
|
|
17
|
+
/^@payloadcms\/richtext-slate\/rsc$/,
|
|
18
|
+
/^@payloadcms\/next\/rsc$/,
|
|
19
|
+
/^@payloadcms\/tanstack-start\/rsc$/
|
|
20
|
+
];
|
|
21
|
+
const serverOnlyExports = {
|
|
22
|
+
'@payloadcms/next/rsc': [
|
|
23
|
+
'CollectionCards',
|
|
24
|
+
'HierarchyTypeFieldServer'
|
|
25
|
+
],
|
|
26
|
+
'@payloadcms/richtext-lexical/rsc': [
|
|
27
|
+
'RscEntryLexicalCell',
|
|
28
|
+
'RscEntryLexicalField',
|
|
29
|
+
'LexicalDiffComponent'
|
|
30
|
+
],
|
|
31
|
+
'@payloadcms/tanstack-start/rsc': [
|
|
32
|
+
'CollectionCards',
|
|
33
|
+
'HierarchyTypeFieldServer',
|
|
34
|
+
'renderPayloadComponentOnServer'
|
|
35
|
+
]
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
name: 'payload:client-module-resolution',
|
|
39
|
+
enforce: 'pre',
|
|
40
|
+
load (id) {
|
|
41
|
+
if (!id.startsWith(stubPrefix)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const specifier = id.slice(stubPrefix.length);
|
|
45
|
+
const exports = serverOnlyExports[specifier];
|
|
46
|
+
if (exports) {
|
|
47
|
+
return exports.map((name)=>`export const ${name} = () => null;`).join('\n');
|
|
48
|
+
}
|
|
49
|
+
return `export default null;`;
|
|
50
|
+
},
|
|
51
|
+
async resolveId (id, importer, options) {
|
|
52
|
+
if (options?.ssr) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (serverOnlyPatterns.some((p)=>p.test(id))) {
|
|
56
|
+
return stubPrefix + id;
|
|
57
|
+
}
|
|
58
|
+
if (id === 'payload' && importer && !importer.includes('/node_modules/')) {
|
|
59
|
+
const isPayloadPackage = /\/packages\/(?:payload|ui|richtext-|tanstack-start|next)\//.test(importer);
|
|
60
|
+
if (!isPayloadPackage) {
|
|
61
|
+
return this.resolve('payload/shared', importer, {
|
|
62
|
+
...options,
|
|
63
|
+
skipSelf: true
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (/^@payloadcms\/(?:plugin|storage)-[^/]+\/client$/.test(id)) {
|
|
68
|
+
const resolved = await this.resolve(id, importer, {
|
|
69
|
+
...options,
|
|
70
|
+
skipSelf: true
|
|
71
|
+
});
|
|
72
|
+
if (resolved) {
|
|
73
|
+
return resolved;
|
|
74
|
+
}
|
|
75
|
+
const pkgName = id.replace(/\/client$/, '');
|
|
76
|
+
const pkgResolved = await this.resolve(pkgName, importer, {
|
|
77
|
+
...options,
|
|
78
|
+
skipSelf: true
|
|
79
|
+
});
|
|
80
|
+
if (pkgResolved) {
|
|
81
|
+
const pkgDir = path.dirname(pkgResolved.id);
|
|
82
|
+
const candidates = [
|
|
83
|
+
path.resolve(pkgDir, 'src', 'exports', 'client.ts'),
|
|
84
|
+
path.resolve(pkgDir, 'src', 'exports', 'client.js'),
|
|
85
|
+
path.resolve(pkgDir, 'dist', 'exports', 'client.js')
|
|
86
|
+
];
|
|
87
|
+
for (const candidate of candidates){
|
|
88
|
+
if (fs.existsSync(candidate)) {
|
|
89
|
+
return candidate;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=clientModuleResolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/plugins/clientModuleResolution.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\nimport fs from 'node:fs'\nimport path from 'node:path'\n\n/**\n * Client-side module resolution:\n * 1. Stubs RSC modules (`@payloadcms/.../rsc`) with no-op components so the\n * Vite optimizer never tries to bundle their server implementations.\n * 2. Redirects bare `payload` imports made from user code (outside of\n * `node_modules` and our own packages) to `payload/shared`. The main\n * `payload` entry has top-level side effects requiring Node.js APIs.\n * 3. Resolves `/client` subpath exports for `@payloadcms/plugin-*` and\n * `@payloadcms/storage-*` packages when normal Vite resolution fails in\n * monorepo dev (no `dist/` built yet).\n */\nexport function clientModuleResolution(): PluginOption {\n const stubPrefix = '\\0payload:server-stub:'\n\n const serverOnlyPatterns: RegExp[] = [\n /^@payloadcms\\/richtext-lexical\\/rsc$/,\n /^@payloadcms\\/richtext-slate\\/rsc$/,\n /^@payloadcms\\/next\\/rsc$/,\n /^@payloadcms\\/tanstack-start\\/rsc$/,\n ]\n\n const serverOnlyExports: Record<string, string[]> = {\n '@payloadcms/next/rsc': ['CollectionCards', 'HierarchyTypeFieldServer'],\n '@payloadcms/richtext-lexical/rsc': [\n 'RscEntryLexicalCell',\n 'RscEntryLexicalField',\n 'LexicalDiffComponent',\n ],\n '@payloadcms/tanstack-start/rsc': [\n 'CollectionCards',\n 'HierarchyTypeFieldServer',\n 'renderPayloadComponentOnServer',\n ],\n }\n\n return {\n name: 'payload:client-module-resolution',\n enforce: 'pre',\n load(id) {\n if (!id.startsWith(stubPrefix)) {\n return\n }\n const specifier = id.slice(stubPrefix.length)\n const exports = serverOnlyExports[specifier]\n if (exports) {\n return exports.map((name) => `export const ${name} = () => null;`).join('\\n')\n }\n return `export default null;`\n },\n async resolveId(id, importer, options) {\n if (options?.ssr) {\n return\n }\n\n if (serverOnlyPatterns.some((p) => p.test(id))) {\n return stubPrefix + id\n }\n\n if (id === 'payload' && importer && !importer.includes('/node_modules/')) {\n const isPayloadPackage = /\\/packages\\/(?:payload|ui|richtext-|tanstack-start|next)\\//.test(\n importer,\n )\n if (!isPayloadPackage) {\n return this.resolve('payload/shared', importer, { ...options, skipSelf: true })\n }\n }\n\n if (/^@payloadcms\\/(?:plugin|storage)-[^/]+\\/client$/.test(id)) {\n const resolved = await this.resolve(id, importer, { ...options, skipSelf: true })\n if (resolved) {\n return resolved\n }\n const pkgName = id.replace(/\\/client$/, '')\n const pkgResolved = await this.resolve(pkgName, importer, { ...options, skipSelf: true })\n if (pkgResolved) {\n const pkgDir = path.dirname(pkgResolved.id)\n const candidates = [\n path.resolve(pkgDir, 'src', 'exports', 'client.ts'),\n path.resolve(pkgDir, 'src', 'exports', 'client.js'),\n path.resolve(pkgDir, 'dist', 'exports', 'client.js'),\n ]\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n return candidate\n }\n }\n }\n }\n },\n }\n}\n"],"names":["fs","path","clientModuleResolution","stubPrefix","serverOnlyPatterns","serverOnlyExports","name","enforce","load","id","startsWith","specifier","slice","length","exports","map","join","resolveId","importer","options","ssr","some","p","test","includes","isPayloadPackage","resolve","skipSelf","resolved","pkgName","replace","pkgResolved","pkgDir","dirname","candidates","candidate","existsSync"],"mappings":"AAEA,OAAOA,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B;;;;;;;;;;CAUC,GACD,OAAO,SAASC;IACd,MAAMC,aAAa;IAEnB,MAAMC,qBAA+B;QACnC;QACA;QACA;QACA;KACD;IAED,MAAMC,oBAA8C;QAClD,wBAAwB;YAAC;YAAmB;SAA2B;QACvE,oCAAoC;YAClC;YACA;YACA;SACD;QACD,kCAAkC;YAChC;YACA;YACA;SACD;IACH;IAEA,OAAO;QACLC,MAAM;QACNC,SAAS;QACTC,MAAKC,EAAE;YACL,IAAI,CAACA,GAAGC,UAAU,CAACP,aAAa;gBAC9B;YACF;YACA,MAAMQ,YAAYF,GAAGG,KAAK,CAACT,WAAWU,MAAM;YAC5C,MAAMC,UAAUT,iBAAiB,CAACM,UAAU;YAC5C,IAAIG,SAAS;gBACX,OAAOA,QAAQC,GAAG,CAAC,CAACT,OAAS,CAAC,aAAa,EAAEA,KAAK,cAAc,CAAC,EAAEU,IAAI,CAAC;YAC1E;YACA,OAAO,CAAC,oBAAoB,CAAC;QAC/B;QACA,MAAMC,WAAUR,EAAE,EAAES,QAAQ,EAAEC,OAAO;YACnC,IAAIA,SAASC,KAAK;gBAChB;YACF;YAEA,IAAIhB,mBAAmBiB,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,CAACd,MAAM;gBAC9C,OAAON,aAAaM;YACtB;YAEA,IAAIA,OAAO,aAAaS,YAAY,CAACA,SAASM,QAAQ,CAAC,mBAAmB;gBACxE,MAAMC,mBAAmB,6DAA6DF,IAAI,CACxFL;gBAEF,IAAI,CAACO,kBAAkB;oBACrB,OAAO,IAAI,CAACC,OAAO,CAAC,kBAAkBR,UAAU;wBAAE,GAAGC,OAAO;wBAAEQ,UAAU;oBAAK;gBAC/E;YACF;YAEA,IAAI,kDAAkDJ,IAAI,CAACd,KAAK;gBAC9D,MAAMmB,WAAW,MAAM,IAAI,CAACF,OAAO,CAACjB,IAAIS,UAAU;oBAAE,GAAGC,OAAO;oBAAEQ,UAAU;gBAAK;gBAC/E,IAAIC,UAAU;oBACZ,OAAOA;gBACT;gBACA,MAAMC,UAAUpB,GAAGqB,OAAO,CAAC,aAAa;gBACxC,MAAMC,cAAc,MAAM,IAAI,CAACL,OAAO,CAACG,SAASX,UAAU;oBAAE,GAAGC,OAAO;oBAAEQ,UAAU;gBAAK;gBACvF,IAAII,aAAa;oBACf,MAAMC,SAAS/B,KAAKgC,OAAO,CAACF,YAAYtB,EAAE;oBAC1C,MAAMyB,aAAa;wBACjBjC,KAAKyB,OAAO,CAACM,QAAQ,OAAO,WAAW;wBACvC/B,KAAKyB,OAAO,CAACM,QAAQ,OAAO,WAAW;wBACvC/B,KAAKyB,OAAO,CAACM,QAAQ,QAAQ,WAAW;qBACzC;oBACD,KAAK,MAAMG,aAAaD,WAAY;wBAClC,IAAIlC,GAAGoC,UAAU,CAACD,YAAY;4BAC5B,OAAOA;wBACT;oBACF;gBACF;YACF;QACF;IACF;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PluginOption } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Dev-time transforms:
|
|
4
|
+
* - Replaces `process.cwd()` with `"/"` in client code (non-SSR, non-prebundled)
|
|
5
|
+
* - Injects Vite HMR + React Refresh preamble into SSR-rendered HTML (dev only)
|
|
6
|
+
*/
|
|
7
|
+
export declare function payloadDevTransforms(): PluginOption;
|
|
8
|
+
//# sourceMappingURL=devTransforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devTransforms.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/devTransforms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,CA2DnD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-time transforms:
|
|
3
|
+
* - Replaces `process.cwd()` with `"/"` in client code (non-SSR, non-prebundled)
|
|
4
|
+
* - Injects Vite HMR + React Refresh preamble into SSR-rendered HTML (dev only)
|
|
5
|
+
*/ export function payloadDevTransforms() {
|
|
6
|
+
const devScripts = `<script type="module" src="/@vite/client"></script>
|
|
7
|
+
<script type="module">
|
|
8
|
+
import RefreshRuntime from "/@react-refresh"
|
|
9
|
+
RefreshRuntime.injectIntoGlobalHook(window)
|
|
10
|
+
window.$RefreshReg$ = () => {}
|
|
11
|
+
window.$RefreshSig$ = () => (type) => type
|
|
12
|
+
window.__vite_plugin_react_preamble_installed__ = true
|
|
13
|
+
</script>`;
|
|
14
|
+
return {
|
|
15
|
+
name: 'payload:dev-transforms',
|
|
16
|
+
configureServer (server) {
|
|
17
|
+
server.middlewares.use((_req, res, next)=>{
|
|
18
|
+
let injected = false;
|
|
19
|
+
const origWrite = res.write;
|
|
20
|
+
const origEnd = res.end;
|
|
21
|
+
function tryInject(chunk) {
|
|
22
|
+
if (injected || chunk == null) {
|
|
23
|
+
return chunk;
|
|
24
|
+
}
|
|
25
|
+
const ct = res.getHeader('content-type');
|
|
26
|
+
if (typeof ct !== 'string' || !ct.includes('text/html')) {
|
|
27
|
+
return chunk;
|
|
28
|
+
}
|
|
29
|
+
const str = typeof chunk === 'string' ? chunk : Buffer.isBuffer(chunk) ? chunk.toString() : chunk instanceof Uint8Array ? Buffer.from(chunk).toString() : null;
|
|
30
|
+
if (str && str.includes('<head>')) {
|
|
31
|
+
injected = true;
|
|
32
|
+
return str.replace('<head>', `<head>${devScripts}`);
|
|
33
|
+
}
|
|
34
|
+
return chunk;
|
|
35
|
+
}
|
|
36
|
+
res.write = function(chunk, encodingOrCb, cb) {
|
|
37
|
+
return origWrite.call(this, tryInject(chunk), encodingOrCb, cb);
|
|
38
|
+
};
|
|
39
|
+
res.end = function(chunk, encodingOrCb, cb) {
|
|
40
|
+
return origEnd.call(this, tryInject(chunk), encodingOrCb, cb);
|
|
41
|
+
};
|
|
42
|
+
next();
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
transform (code, id, options) {
|
|
46
|
+
if (options?.ssr) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (code.includes('process.cwd') && !id.includes('node_modules/.vite')) {
|
|
50
|
+
return code.replace(/process\.cwd\(\)/g, '"/"');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=devTransforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/plugins/devTransforms.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\n/**\n * Dev-time transforms:\n * - Replaces `process.cwd()` with `\"/\"` in client code (non-SSR, non-prebundled)\n * - Injects Vite HMR + React Refresh preamble into SSR-rendered HTML (dev only)\n */\nexport function payloadDevTransforms(): PluginOption {\n const devScripts = `<script type=\"module\" src=\"/@vite/client\"></script>\n<script type=\"module\">\nimport RefreshRuntime from \"/@react-refresh\"\nRefreshRuntime.injectIntoGlobalHook(window)\nwindow.$RefreshReg$ = () => {}\nwindow.$RefreshSig$ = () => (type) => type\nwindow.__vite_plugin_react_preamble_installed__ = true\n</script>`\n\n return {\n name: 'payload:dev-transforms',\n configureServer(server) {\n server.middlewares.use((_req, res, next) => {\n let injected = false\n const origWrite = res.write\n const origEnd = res.end\n\n function tryInject(chunk: any): any {\n if (injected || chunk == null) {\n return chunk\n }\n const ct = res.getHeader('content-type')\n if (typeof ct !== 'string' || !ct.includes('text/html')) {\n return chunk\n }\n const str =\n typeof chunk === 'string'\n ? chunk\n : Buffer.isBuffer(chunk)\n ? chunk.toString()\n : chunk instanceof Uint8Array\n ? Buffer.from(chunk).toString()\n : null\n if (str && str.includes('<head>')) {\n injected = true\n return str.replace('<head>', `<head>${devScripts}`)\n }\n return chunk\n }\n\n res.write = function (this: any, chunk: any, encodingOrCb?: any, cb?: any) {\n return origWrite.call(this, tryInject(chunk), encodingOrCb, cb)\n } as typeof res.write\n res.end = function (this: any, chunk?: any, encodingOrCb?: any, cb?: any) {\n return origEnd.call(this, tryInject(chunk), encodingOrCb, cb)\n } as typeof res.end\n next()\n })\n },\n transform(code, id, options) {\n if (options?.ssr) {\n return\n }\n if (code.includes('process.cwd') && !id.includes('node_modules/.vite')) {\n return code.replace(/process\\.cwd\\(\\)/g, '\"/\"')\n }\n },\n }\n}\n"],"names":["payloadDevTransforms","devScripts","name","configureServer","server","middlewares","use","_req","res","next","injected","origWrite","write","origEnd","end","tryInject","chunk","ct","getHeader","includes","str","Buffer","isBuffer","toString","Uint8Array","from","replace","encodingOrCb","cb","call","transform","code","id","options","ssr"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,SAASA;IACd,MAAMC,aAAa,CAAC;;;;;;;SAOb,CAAC;IAER,OAAO;QACLC,MAAM;QACNC,iBAAgBC,MAAM;YACpBA,OAAOC,WAAW,CAACC,GAAG,CAAC,CAACC,MAAMC,KAAKC;gBACjC,IAAIC,WAAW;gBACf,MAAMC,YAAYH,IAAII,KAAK;gBAC3B,MAAMC,UAAUL,IAAIM,GAAG;gBAEvB,SAASC,UAAUC,KAAU;oBAC3B,IAAIN,YAAYM,SAAS,MAAM;wBAC7B,OAAOA;oBACT;oBACA,MAAMC,KAAKT,IAAIU,SAAS,CAAC;oBACzB,IAAI,OAAOD,OAAO,YAAY,CAACA,GAAGE,QAAQ,CAAC,cAAc;wBACvD,OAAOH;oBACT;oBACA,MAAMI,MACJ,OAAOJ,UAAU,WACbA,QACAK,OAAOC,QAAQ,CAACN,SACdA,MAAMO,QAAQ,KACdP,iBAAiBQ,aACfH,OAAOI,IAAI,CAACT,OAAOO,QAAQ,KAC3B;oBACV,IAAIH,OAAOA,IAAID,QAAQ,CAAC,WAAW;wBACjCT,WAAW;wBACX,OAAOU,IAAIM,OAAO,CAAC,UAAU,CAAC,MAAM,EAAEzB,YAAY;oBACpD;oBACA,OAAOe;gBACT;gBAEAR,IAAII,KAAK,GAAG,SAAqBI,KAAU,EAAEW,YAAkB,EAAEC,EAAQ;oBACvE,OAAOjB,UAAUkB,IAAI,CAAC,IAAI,EAAEd,UAAUC,QAAQW,cAAcC;gBAC9D;gBACApB,IAAIM,GAAG,GAAG,SAAqBE,KAAW,EAAEW,YAAkB,EAAEC,EAAQ;oBACtE,OAAOf,QAAQgB,IAAI,CAAC,IAAI,EAAEd,UAAUC,QAAQW,cAAcC;gBAC5D;gBACAnB;YACF;QACF;QACAqB,WAAUC,IAAI,EAAEC,EAAE,EAAEC,OAAO;YACzB,IAAIA,SAASC,KAAK;gBAChB;YACF;YACA,IAAIH,KAAKZ,QAAQ,CAAC,kBAAkB,CAACa,GAAGb,QAAQ,CAAC,uBAAuB;gBACtE,OAAOY,KAAKL,OAAO,CAAC,qBAAqB;YAC3C;QACF;IACF;AACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PluginOption } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Provides a working `react-dom/server` inside the RSC environment.
|
|
4
|
+
*
|
|
5
|
+
* Payload's version-diff converters (`@payloadcms/richtext-lexical`'s
|
|
6
|
+
* `field/Diff/converters/*` and `@payloadcms/ui`'s `Version/RenderFieldsToDiff`)
|
|
7
|
+
* call `renderToStaticMarkup` while rendering a Server Component. In the RSC
|
|
8
|
+
* environment Vite activates the `react-server` export condition, under which
|
|
9
|
+
* every `react-dom/server*` subpath resolves to `server.react-server.js` — a
|
|
10
|
+
* stub that throws `react-dom/server is not supported in React Server
|
|
11
|
+
* Components`. Force-resolving past the condition isn't enough either: the
|
|
12
|
+
* static renderer reads the *client* React internals
|
|
13
|
+
* (`__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE`), which
|
|
14
|
+
* the `react-server` build of `react` doesn't expose.
|
|
15
|
+
*
|
|
16
|
+
* So we pre-bundle a self-contained `react-dom/server` with client React
|
|
17
|
+
* inlined (esbuild, deliberately WITHOUT the `react-server` condition) and
|
|
18
|
+
* redirect `react-dom/server` to it in the RSC graph only. The bundle is fully
|
|
19
|
+
* self-contained, so the RSC environment's `react-server` condition can't
|
|
20
|
+
* reach into it. JSX elements created by the RSC-graph React stay renderable
|
|
21
|
+
* because React identifies elements via a process-global `Symbol.for(...)`.
|
|
22
|
+
*
|
|
23
|
+
* Delete this once `react-dom/server` (or an equivalent static renderer) is
|
|
24
|
+
* usable from the `react-server` condition without a separate bundle.
|
|
25
|
+
*/
|
|
26
|
+
export declare function reactDomServerInRsc(): PluginOption;
|
|
27
|
+
//# sourceMappingURL=reactDomServerInRsc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactDomServerInRsc.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/reactDomServerInRsc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAQxC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,CAyDlD"}
|