@payloadcms/tanstack-start 4.0.0-internal.688c4d0 → 4.0.0-internal.811e0a4
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 +1 -1
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +3 -0
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/layouts.d.ts +1 -0
- package/dist/exports/layouts.d.ts.map +1 -1
- package/dist/exports/layouts.js +1 -0
- package/dist/exports/layouts.js.map +1 -1
- package/dist/exports/server.d.ts +2 -1
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +2 -1
- package/dist/exports/server.js.map +1 -1
- package/dist/exports/vite.d.ts +12 -2
- package/dist/exports/vite.d.ts.map +1 -1
- package/dist/exports/vite.js +8 -1
- package/dist/exports/vite.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/layouts/Root/getLayoutData.js.map +1 -1
- package/dist/layouts/Root/index.d.ts +2 -2
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/layouts/Root/withPayloadRoot.d.ts +1 -1
- package/dist/layouts/Root/withPayloadRoot.js +1 -1
- package/dist/layouts/Root/withPayloadRoot.js.map +1 -1
- package/dist/routes/adminRoutes.d.ts +111 -0
- package/dist/routes/adminRoutes.d.ts.map +1 -0
- package/dist/routes/adminRoutes.js +108 -0
- package/dist/routes/adminRoutes.js.map +1 -0
- package/dist/routes/apiRoute.d.ts +29 -0
- package/dist/routes/apiRoute.d.ts.map +1 -0
- package/dist/routes/apiRoute.js +38 -0
- package/dist/routes/apiRoute.js.map +1 -0
- package/dist/routes/layoutRoute.d.ts +26 -0
- package/dist/routes/layoutRoute.d.ts.map +1 -0
- package/dist/routes/layoutRoute.js +57 -0
- package/dist/routes/layoutRoute.js.map +1 -0
- package/dist/utilities/handleAPIRoute.d.ts +11 -0
- package/dist/utilities/handleAPIRoute.d.ts.map +1 -0
- package/dist/utilities/handleAPIRoute.js +17 -0
- package/dist/utilities/handleAPIRoute.js.map +1 -0
- package/dist/utilities/importMap.server.d.ts +4 -5
- package/dist/utilities/importMap.server.d.ts.map +1 -1
- package/dist/utilities/importMap.server.js +5 -6
- package/dist/utilities/importMap.server.js.map +1 -1
- package/dist/utilities/loadAdminPage.d.ts +54 -0
- package/dist/utilities/loadAdminPage.d.ts.map +1 -0
- package/dist/utilities/loadAdminPage.js +230 -0
- package/dist/utilities/loadAdminPage.js.map +1 -0
- package/dist/utilities/loadLayoutData.d.ts +15 -0
- package/dist/utilities/loadLayoutData.d.ts.map +1 -0
- package/dist/utilities/loadLayoutData.js +23 -0
- package/dist/utilities/loadLayoutData.js.map +1 -0
- package/dist/utilities/serverFunctionClient.d.ts +29 -0
- package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
- package/dist/utilities/serverFunctionClient.js +109 -0
- package/dist/utilities/serverFunctionClient.js.map +1 -0
- package/dist/vite/config/external.d.ts +11 -0
- package/dist/vite/config/external.d.ts.map +1 -0
- package/dist/vite/config/external.js +48 -0
- package/dist/vite/config/external.js.map +1 -0
- package/dist/vite/config/optimizeDeps.d.ts +25 -0
- package/dist/vite/config/optimizeDeps.d.ts.map +1 -0
- package/dist/vite/{constants.js → config/optimizeDeps.js} +23 -57
- package/dist/vite/config/optimizeDeps.js.map +1 -0
- package/dist/vite/config/scss.d.ts +14 -0
- package/dist/vite/config/scss.d.ts.map +1 -0
- package/dist/vite/config/scss.js +28 -0
- package/dist/vite/config/scss.js.map +1 -0
- package/dist/vite/index.d.ts +55 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/{plugin.js → index.js} +104 -46
- package/dist/vite/index.js.map +1 -0
- package/dist/vite/workarounds/clientModuleResolution.d.ts.map +1 -0
- package/dist/vite/workarounds/clientModuleResolution.js.map +1 -0
- package/dist/vite/workarounds/devTransforms.d.ts.map +1 -0
- package/dist/vite/workarounds/devTransforms.js.map +1 -0
- package/dist/vite/workarounds/reactDomServerInRsc.d.ts.map +1 -0
- package/dist/vite/workarounds/reactDomServerInRsc.js.map +1 -0
- package/dist/vite/workarounds/stripDistStyleImports.d.ts.map +1 -0
- package/dist/vite/{plugins → workarounds}/stripDistStyleImports.js +37 -4
- package/dist/vite/workarounds/stripDistStyleImports.js.map +1 -0
- package/dist/vite/workarounds/stubPrettierInClient.d.ts +21 -0
- package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +1 -0
- package/dist/vite/workarounds/stubPrettierInClient.js +39 -0
- package/dist/vite/workarounds/stubPrettierInClient.js.map +1 -0
- package/dist/vite/workarounds/wrapCjsForClient.d.ts.map +1 -0
- package/dist/vite/workarounds/wrapCjsForClient.js.map +1 -0
- package/package.json +10 -12
- package/dist/@types/assets.d.js +0 -2
- package/dist/@types/assets.d.js.map +0 -1
- package/dist/auth/switchLanguage.d.ts +0 -6
- package/dist/auth/switchLanguage.d.ts.map +0 -1
- package/dist/auth/switchLanguage.js +0 -11
- package/dist/auth/switchLanguage.js.map +0 -1
- package/dist/vite/constants.d.ts +0 -37
- package/dist/vite/constants.d.ts.map +0 -1
- package/dist/vite/constants.js.map +0 -1
- package/dist/vite/plugin.d.ts +0 -38
- package/dist/vite/plugin.d.ts.map +0 -1
- package/dist/vite/plugin.js.map +0 -1
- package/dist/vite/plugins/clientModuleResolution.d.ts.map +0 -1
- package/dist/vite/plugins/clientModuleResolution.js.map +0 -1
- package/dist/vite/plugins/devTransforms.d.ts.map +0 -1
- package/dist/vite/plugins/devTransforms.js.map +0 -1
- package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +0 -1
- package/dist/vite/plugins/reactDomServerInRsc.js.map +0 -1
- package/dist/vite/plugins/stripDistStyleImports.d.ts.map +0 -1
- package/dist/vite/plugins/stripDistStyleImports.js.map +0 -1
- package/dist/vite/plugins/wrapCjsForClient.d.ts.map +0 -1
- package/dist/vite/plugins/wrapCjsForClient.js.map +0 -1
- /package/dist/vite/{plugins → workarounds}/clientModuleResolution.d.ts +0 -0
- /package/dist/vite/{plugins → workarounds}/clientModuleResolution.js +0 -0
- /package/dist/vite/{plugins → workarounds}/devTransforms.d.ts +0 -0
- /package/dist/vite/{plugins → workarounds}/devTransforms.js +0 -0
- /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.d.ts +0 -0
- /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.js +0 -0
- /package/dist/vite/{plugins → workarounds}/stripDistStyleImports.d.ts +0 -0
- /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.d.ts +0 -0
- /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.js +0 -0
|
@@ -1,25 +1,74 @@
|
|
|
1
|
+
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
2
|
+
import viteReact from '@vitejs/plugin-react';
|
|
3
|
+
import rsc from '@vitejs/plugin-rsc';
|
|
1
4
|
import path from 'node:path';
|
|
2
|
-
import {
|
|
5
|
+
import { createLogger, mergeConfig } from 'vite';
|
|
6
|
+
import { payloadNoExternalPatterns, ssrExternalPackages } from './config/external.js';
|
|
7
|
+
import { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js';
|
|
8
|
+
import { payloadScssImporters } from './config/scss.js';
|
|
3
9
|
import { defaultImportProtectionIgnoreImporters, onImportProtectionViolation, serverOnlyClientSpecifiers } from './importProtection.js';
|
|
4
|
-
import { clientModuleResolution } from './
|
|
5
|
-
import { payloadDevTransforms } from './
|
|
6
|
-
import { reactDomServerInRsc } from './
|
|
7
|
-
import { ssrStripDistStyleImports } from './
|
|
8
|
-
import {
|
|
10
|
+
import { clientModuleResolution } from './workarounds/clientModuleResolution.js';
|
|
11
|
+
import { payloadDevTransforms } from './workarounds/devTransforms.js';
|
|
12
|
+
import { reactDomServerInRsc } from './workarounds/reactDomServerInRsc.js';
|
|
13
|
+
import { ssrStripDistStyleImports } from './workarounds/stripDistStyleImports.js';
|
|
14
|
+
import { stubPrettierInClient } from './workarounds/stubPrettierInClient.js';
|
|
15
|
+
import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
9
16
|
/**
|
|
10
|
-
* Vite
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
* Vite dependency warnings Payload consumers can't act on: third-party packages
|
|
18
|
+
* ship sourcemaps whose original sources aren't published, so Vite warns on
|
|
19
|
+
* every one. Suppressed by default (see `silenceDependencyWarnings`).
|
|
20
|
+
*/ const suppressibleWarningPatterns = [
|
|
21
|
+
'points to missing source files',
|
|
22
|
+
'Sourcemap for'
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Wraps a Vite logger so warnings matching {@link suppressibleWarningPatterns}
|
|
26
|
+
* are dropped. Mutates and returns the given logger (or a fresh default one).
|
|
27
|
+
*/ function withQuietedDependencyWarnings(existing) {
|
|
28
|
+
const logger = existing ?? createLogger();
|
|
29
|
+
const shouldSuppress = (msg)=>typeof msg === 'string' && suppressibleWarningPatterns.some((pattern)=>msg.includes(pattern));
|
|
30
|
+
const baseWarn = logger.warn.bind(logger);
|
|
31
|
+
const baseWarnOnce = logger.warnOnce.bind(logger);
|
|
32
|
+
logger.warn = (msg, options)=>{
|
|
33
|
+
if (!shouldSuppress(msg)) {
|
|
34
|
+
baseWarn(msg, options);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
logger.warnOnce = (msg, options)=>{
|
|
38
|
+
if (!shouldSuppress(msg)) {
|
|
39
|
+
baseWarnOnce(msg, options);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return logger;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Vite config helper for Payload + TanStack Start. The Vite-side counterpart to
|
|
46
|
+
* `withPayload` for Next.js: it owns the whole Vite setup needed to run the
|
|
47
|
+
* Payload admin — the RSC, React, and TanStack Start plugins plus a small set of
|
|
48
|
+
* Payload-specific workarounds — so a consumer's `vite.config.ts` collapses to:
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { withPayload } from '@payloadcms/tanstack-start/vite'
|
|
52
|
+
*
|
|
53
|
+
* export default withPayload({ payloadConfigPath: './src/payload.config.ts' })
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* The React (`@vitejs/plugin-react`), RSC (`@vitejs/plugin-rsc`), and TanStack
|
|
57
|
+
* Start plugins are instantiated internally with the settings the admin
|
|
58
|
+
* requires — consumers no longer pass them in. Each remaining Payload
|
|
59
|
+
* workaround lives in its own file under `./workarounds/` so it can be deleted
|
|
60
|
+
* individually once the corresponding upstream fix lands.
|
|
61
|
+
*/ export function withPayload(options) {
|
|
62
|
+
const { additionalIgnoreImporters = [], payloadConfigPath, routesDirectory = 'app', silenceDependencyWarnings = true, srcDirectory = 'src', vite } = options;
|
|
63
|
+
return (_env)=>{
|
|
64
|
+
const base = {
|
|
65
|
+
build: {
|
|
66
|
+
cssMinify: 'esbuild'
|
|
67
|
+
},
|
|
20
68
|
css: {
|
|
21
69
|
preprocessorOptions: {
|
|
22
70
|
scss: {
|
|
71
|
+
importers: payloadScssImporters,
|
|
23
72
|
silenceDeprecations: [
|
|
24
73
|
'import',
|
|
25
74
|
'global-builtin'
|
|
@@ -28,16 +77,25 @@ import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
|
|
|
28
77
|
}
|
|
29
78
|
},
|
|
30
79
|
define: {
|
|
31
|
-
global: 'globalThis'
|
|
32
|
-
'process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED': JSON.stringify('true')
|
|
80
|
+
global: 'globalThis'
|
|
33
81
|
},
|
|
34
82
|
environments: {
|
|
35
83
|
rsc: {
|
|
84
|
+
build: {
|
|
85
|
+
rollupOptions: {
|
|
86
|
+
external: ssrExternalPackages
|
|
87
|
+
}
|
|
88
|
+
},
|
|
36
89
|
resolve: {
|
|
37
|
-
noExternal:
|
|
90
|
+
noExternal: payloadNoExternalPatterns
|
|
38
91
|
}
|
|
39
92
|
},
|
|
40
93
|
ssr: {
|
|
94
|
+
build: {
|
|
95
|
+
rollupOptions: {
|
|
96
|
+
external: ssrExternalPackages
|
|
97
|
+
}
|
|
98
|
+
},
|
|
41
99
|
resolve: {
|
|
42
100
|
noExternal: payloadNoExternalPatterns
|
|
43
101
|
}
|
|
@@ -45,18 +103,18 @@ import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
|
|
|
45
103
|
},
|
|
46
104
|
optimizeDeps: {
|
|
47
105
|
exclude: optimizeDepsExcludeDefaults,
|
|
48
|
-
include:
|
|
49
|
-
...optimizeDepsIncludeDefaults,
|
|
50
|
-
...additionalOptimizeDepsInclude
|
|
51
|
-
]
|
|
106
|
+
include: optimizeDepsIncludeDefaults
|
|
52
107
|
},
|
|
53
108
|
plugins: [
|
|
54
109
|
clientModuleResolution(),
|
|
55
110
|
wrapCjsForClient(),
|
|
56
111
|
ssrStripDistStyleImports(),
|
|
57
112
|
reactDomServerInRsc(),
|
|
113
|
+
stubPrettierInClient(),
|
|
58
114
|
payloadDevTransforms(),
|
|
59
|
-
|
|
115
|
+
rsc({
|
|
116
|
+
serverHandler: false
|
|
117
|
+
}),
|
|
60
118
|
tanstackStart({
|
|
61
119
|
importProtection: {
|
|
62
120
|
client: {
|
|
@@ -122,11 +180,14 @@ import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
|
|
|
122
180
|
codeSplittingOptions: {
|
|
123
181
|
defaultBehavior: []
|
|
124
182
|
},
|
|
125
|
-
// Exclude
|
|
126
|
-
//
|
|
127
|
-
// `
|
|
128
|
-
// no longer an `api.server-function.ts`
|
|
129
|
-
|
|
183
|
+
// Exclude generated importMap files and colocated server-function
|
|
184
|
+
// modules (`*.functions.ts`). Admin form saves are dispatched via
|
|
185
|
+
// `runPayloadServerFn` (a TanStack Start `createServerFn`) rather than
|
|
186
|
+
// a hand-rolled route, so there is no longer an `api.server-function.ts`
|
|
187
|
+
// to special-case here. The `*.functions.ts` shims live next to the
|
|
188
|
+
// routes that use them (e.g. `app/_payload/*.functions.ts`); they
|
|
189
|
+
// define `createServerFn`s, not routes, so they must not be scanned.
|
|
190
|
+
routeFileIgnorePattern: 'importMap\\.(?:js|server\\.ts)$|\\.functions\\.',
|
|
130
191
|
routesDirectory
|
|
131
192
|
},
|
|
132
193
|
rsc: {
|
|
@@ -134,16 +195,17 @@ import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
|
|
|
134
195
|
},
|
|
135
196
|
srcDirectory
|
|
136
197
|
}),
|
|
137
|
-
|
|
138
|
-
|
|
198
|
+
viteReact({
|
|
199
|
+
exclude: [],
|
|
200
|
+
include: /\.[jt]sx?$/
|
|
201
|
+
})
|
|
139
202
|
],
|
|
140
203
|
resolve: {
|
|
141
204
|
alias: [
|
|
142
205
|
{
|
|
143
206
|
find: '@payload-config',
|
|
144
207
|
replacement: path.resolve(payloadConfigPath)
|
|
145
|
-
}
|
|
146
|
-
...additionalAliases
|
|
208
|
+
}
|
|
147
209
|
],
|
|
148
210
|
dedupe: [
|
|
149
211
|
'react',
|
|
@@ -163,21 +225,17 @@ import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
|
|
|
163
225
|
],
|
|
164
226
|
tsconfigPaths: true
|
|
165
227
|
},
|
|
166
|
-
server: {
|
|
167
|
-
warmup: {
|
|
168
|
-
clientFiles: [
|
|
169
|
-
'./src/importMap.js'
|
|
170
|
-
]
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
228
|
ssr: {
|
|
174
|
-
external:
|
|
175
|
-
...ssrExternalPackages,
|
|
176
|
-
...additionalSsrExternal
|
|
177
|
-
],
|
|
229
|
+
external: ssrExternalPackages,
|
|
178
230
|
noExternal: payloadNoExternalPatterns
|
|
179
231
|
}
|
|
180
|
-
}
|
|
232
|
+
};
|
|
233
|
+
const merged = vite ? mergeConfig(base, vite) : base;
|
|
234
|
+
if (silenceDependencyWarnings) {
|
|
235
|
+
merged.customLogger = withQuietedDependencyWarnings(merged.customLogger);
|
|
236
|
+
}
|
|
237
|
+
return merged;
|
|
238
|
+
};
|
|
181
239
|
}
|
|
182
240
|
|
|
183
|
-
//# sourceMappingURL=
|
|
241
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vite/index.ts"],"sourcesContent":["import type { Logger, UserConfig, UserConfigFnObject } from 'vite'\n\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 { payloadNoExternalPatterns, ssrExternalPackages } 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\nexport type WithPayloadOptions = {\n /**\n * Additional import-protection `ignoreImporters` patterns. This is a\n * Payload-specific knob on the TanStack Start plugin, so it cannot be\n * expressed through `vite` — pass it here.\n */\n additionalIgnoreImporters?: RegExp[]\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 /**\n * Silence Vite warnings about third-party dependency sourcemaps pointing to\n * missing source files — noise Payload consumers can't act on. Defaults to\n * `true`; set `false` to see them. Composes with a `vite.customLogger`.\n */\n silenceDependencyWarnings?: boolean\n /** TanStack source directory. Defaults to `'src'` */\n srcDirectory?: string\n /**\n * Extra Vite config merged on top of the Payload defaults via Vite's own\n * `mergeConfig`. Objects are deep-merged and arrays are appended, so this is\n * the single hook for everything a consumer used to reach through separate\n * options: extra `plugins`, `resolve.alias` entries, `optimizeDeps.include`,\n * `ssr.external`, `server`, `build`, and so on.\n *\n * @example\n * withPayload({\n * payloadConfigPath: './src/payload.config.ts',\n * vite: { server: { port: 4000 } },\n * })\n */\n vite?: UserConfig\n}\n\n/**\n * Vite config helper for Payload + TanStack Start. The Vite-side counterpart to\n * `withPayload` for Next.js: it owns the whole Vite setup needed to run the\n * Payload admin — the RSC, React, and TanStack Start plugins plus a small set of\n * Payload-specific workarounds — so a consumer's `vite.config.ts` collapses to:\n *\n * ```ts\n * import { withPayload } from '@payloadcms/tanstack-start/vite'\n *\n * export default withPayload({ payloadConfigPath: './src/payload.config.ts' })\n * ```\n *\n * The React (`@vitejs/plugin-react`), RSC (`@vitejs/plugin-rsc`), and TanStack\n * Start plugins are instantiated internally with the settings the admin\n * requires — consumers no longer pass them in. Each remaining Payload\n * workaround lives in its own file under `./workarounds/` so it can be deleted\n * individually once the corresponding upstream fix lands.\n */\nexport function withPayload(options: WithPayloadOptions): UserConfigFnObject {\n const {\n additionalIgnoreImporters = [],\n payloadConfigPath,\n routesDirectory = 'app',\n silenceDependencyWarnings = true,\n srcDirectory = 'src',\n vite,\n } = options\n\n return (_env) => {\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: ssrExternalPackages } },\n resolve: { noExternal: payloadNoExternalPatterns },\n },\n ssr: {\n build: { rollupOptions: { external: ssrExternalPackages } },\n resolve: { noExternal: payloadNoExternalPatterns },\n },\n } as any,\n optimizeDeps: {\n exclude: optimizeDepsExcludeDefaults,\n include: optimizeDepsIncludeDefaults,\n },\n plugins: [\n clientModuleResolution(),\n wrapCjsForClient(),\n ssrStripDistStyleImports(),\n reactDomServerInRsc(),\n stubPrettierInClient(),\n payloadDevTransforms(),\n rsc({ serverHandler: false }),\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 generated importMap files and colocated server-function\n // modules (`*.functions.ts`). Admin form saves are dispatched via\n // `runPayloadServerFn` (a TanStack Start `createServerFn`) rather than\n // a hand-rolled route, so there is no longer an `api.server-function.ts`\n // to special-case here. The `*.functions.ts` shims live next to the\n // routes that use them (e.g. `app/_payload/*.functions.ts`); they\n // define `createServerFn`s, not routes, so they must not be scanned.\n routeFileIgnorePattern: 'importMap\\\\.(?:js|server\\\\.ts)$|\\\\.functions\\\\.',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }),\n viteReact({ exclude: [], include: /\\.[jt]sx?$/ }),\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: ssrExternalPackages,\n noExternal: payloadNoExternalPatterns,\n },\n }\n\n const merged = vite ? mergeConfig(base, vite) : base\n\n if (silenceDependencyWarnings) {\n merged.customLogger = withQuietedDependencyWarnings(merged.customLogger)\n }\n\n return merged\n }\n}\n"],"names":["tanstackStart","viteReact","rsc","path","createLogger","mergeConfig","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","withPayload","additionalIgnoreImporters","payloadConfigPath","routesDirectory","silenceDependencyWarnings","srcDirectory","vite","_env","base","build","cssMinify","css","preprocessorOptions","scss","importers","silenceDeprecations","define","global","environments","rollupOptions","external","resolve","noExternal","ssr","optimizeDeps","exclude","include","plugins","serverHandler","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","files","router","autoCodeSplitting","codeSplittingOptions","defaultBehavior","routeFileIgnorePattern","enabled","alias","find","replacement","dedupe","extensions","tsconfigPaths","merged","customLogger"],"mappings":"AAEA,SAASA,aAAa,QAAQ,oCAA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"clientModuleResolution.d.ts","sourceRoot":"","sources":["../../../src/vite/workarounds/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 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/workarounds/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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AS/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 @@
|
|
|
1
|
+
{"version":3,"file":"devTransforms.d.ts","sourceRoot":"","sources":["../../../src/vite/workarounds/devTransforms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,CA2DnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/workarounds/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 *\n * The preamble is injected just before `</head>`, *after* everything React\n * renders into the head. React 19 treats `<meta>`/`<link>`/`<style>`/`<title>`\n * as hoistable resources it matches by key (position-tolerant), but a\n * non-hoistable inline `<script type=\"module\">` placed *before* React's first\n * rendered head node makes hydration position-match that script against a\n * `<style>`/`<meta>` and throw — discarding the whole tree client-side, which\n * aborts in-flight server-function fetches and intermittently breaks drawers,\n * forms, and navigation. Appending after React's head content keeps the\n * preamble out of that positional comparison while still running before the\n * body's app-entry module.\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>', `${devScripts}</head>`)\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;;;;;;;;;;;;;;;CAeC,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,W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erInRsc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAQxC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,CAyDlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/workarounds/reactDomServerInRsc.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\nimport { createRequire } from 'node:module'\n\nconst require = createRequire(import.meta.url)\n\nconst REACT_DOM_SERVER_RE = /^react-dom\\/server(?:\\.(?:edge|node|browser))?$/\n\n/**\n * Provides a working `react-dom/server` inside the RSC environment.\n *\n * Payload's version-diff converters (`@payloadcms/richtext-lexical`'s\n * `field/Diff/converters/*` and `@payloadcms/ui`'s `Version/RenderFieldsToDiff`)\n * call `renderToStaticMarkup` while rendering a Server Component. In the RSC\n * environment Vite activates the `react-server` export condition, under which\n * every `react-dom/server*` subpath resolves to `server.react-server.js` — a\n * stub that throws `react-dom/server is not supported in React Server\n * Components`. Force-resolving past the condition isn't enough either: the\n * static renderer reads the *client* React internals\n * (`__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE`), which\n * the `react-server` build of `react` doesn't expose.\n *\n * So we pre-bundle a self-contained `react-dom/server` with client React\n * inlined (esbuild, deliberately WITHOUT the `react-server` condition) and\n * redirect `react-dom/server` to it in the RSC graph only. The bundle is fully\n * self-contained, so the RSC environment's `react-server` condition can't\n * reach into it. JSX elements created by the RSC-graph React stay renderable\n * because React identifies elements via a process-global `Symbol.for(...)`.\n *\n * Delete this once `react-dom/server` (or an equivalent static renderer) is\n * usable from the `react-server` condition without a separate bundle.\n */\nexport function reactDomServerInRsc(): PluginOption {\n const RESOLVED_ID = '\\0payload:react-dom-server-rsc'\n let bundledCode: string | undefined\n\n const buildBundle = (): string => {\n if (bundledCode !== undefined) {\n return bundledCode\n }\n // esbuild is always present as a Vite dependency. Typed loosely because it\n // isn't a direct dependency of this package.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const esbuild: any = require('esbuild')\n const result = esbuild.buildSync({\n banner: {\n // The bundled CJS React DOM server build does `require('util')` etc.\n // esbuild's ESM output otherwise emits a stub that throws \"Dynamic\n // require of ... is not supported\" inside Vite's module runner, so wire\n // up a real `require` for Node built-ins.\n js: \"import { createRequire as __pl_cr } from 'node:module';const require = __pl_cr(import.meta.url);\",\n },\n bundle: true,\n // Resolve react/react-dom to their CLIENT builds — NOT the `react-server`\n // condition the RSC environment would otherwise apply.\n conditions: ['node', 'import', 'default'],\n define: { 'process.env.NODE_ENV': JSON.stringify('production') },\n format: 'esm',\n platform: 'node',\n stdin: {\n contents: [\n \"import * as ReactDOMServer from 'react-dom/server'\",\n \"export * from 'react-dom/server'\",\n 'export default ReactDOMServer',\n ].join('\\n'),\n loader: 'js',\n resolveDir: process.cwd(),\n },\n write: false,\n })\n const code = result.outputFiles[0].text as string\n bundledCode = code\n return code\n }\n\n return {\n name: 'payload:react-dom-server-in-rsc',\n enforce: 'pre',\n load(id) {\n if (id === RESOLVED_ID) {\n return buildBundle()\n }\n },\n resolveId(id) {\n if ((this as any).environment?.name === 'rsc' && REACT_DOM_SERVER_RE.test(id)) {\n return RESOLVED_ID\n }\n },\n }\n}\n"],"names":["createRequire","require","url","REACT_DOM_SERVER_RE","reactDomServerInRsc","RESOLVED_ID","bundledCode","buildBundle","undefined","esbuild","result","buildSync","banner","js","bundle","conditions","define","JSON","stringify","format","platform","stdin","contents","join","loader","resolveDir","process","cwd","write","code","outputFiles","text","name","enforce","load","id","resolveId","environment","test"],"mappings":"AAEA,SAASA,aAAa,QAAQ,cAAa;AAE3C,MAAMC,UAAUD,cAAc,YAAYE,GAAG;AAE7C,MAAMC,sBAAsB;AAE5B;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,SAASC;IACd,MAAMC,cAAc;IACpB,IAAIC;IAEJ,MAAMC,cAAc;QAClB,IAAID,gBAAgBE,WAAW;YAC7B,OAAOF;QACT;QACA,2EAA2E;QAC3E,6CAA6C;QAC7C,8DAA8D;QAC9D,MAAMG,UAAeR,QAAQ;QAC7B,MAAMS,SAASD,QAAQE,SAAS,CAAC;YAC/BC,QAAQ;gBACN,qEAAqE;gBACrE,mEAAmE;gBACnE,wEAAwE;gBACxE,0CAA0C;gBAC1CC,IAAI;YACN;YACAC,QAAQ;YACR,0EAA0E;YAC1E,uDAAuD;YACvDC,YAAY;gBAAC;gBAAQ;gBAAU;aAAU;YACzCC,QAAQ;gBAAE,wBAAwBC,KAAKC,SAAS,CAAC;YAAc;YAC/DC,QAAQ;YACRC,UAAU;YACVC,OAAO;gBACLC,UAAU;oBACR;oBACA;oBACA;iBACD,CAACC,IAAI,CAAC;gBACPC,QAAQ;gBACRC,YAAYC,QAAQC,GAAG;YACzB;YACAC,OAAO;QACT;QACA,MAAMC,OAAOnB,OAAOoB,WAAW,CAAC,EAAE,CAACC,IAAI;QACvCzB,cAAcuB;QACd,OAAOA;IACT;IAEA,OAAO;QACLG,MAAM;QACNC,SAAS;QACTC,MAAKC,EAAE;YACL,IAAIA,OAAO9B,aAAa;gBACtB,OAAOE;YACT;QACF;QACA6B,WAAUD,EAAE;YACV,IAAI,AAAC,IAAI,CAASE,WAAW,EAAEL,SAAS,SAAS7B,oBAAoBmC,IAAI,CAACH,KAAK;gBAC7E,OAAO9B;YACT;QACF;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripDistStyleImports.d.ts","sourceRoot":"","sources":["../../../src/vite/workarounds/stripDistStyleImports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAsDxC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,IAAI,YAAY,CAyEvD"}
|
|
@@ -14,6 +14,34 @@ const STYLE_EXTENSION_RE = /\.(?:s?css|less)$/i;
|
|
|
14
14
|
* (not a published `dist`), so the `dist/` rule below doesn't cover them and
|
|
15
15
|
* their `.css` side-effect imports survive into the SSR/RSC graph.
|
|
16
16
|
*/ const PAYLOAD_PKG_SRC_RE = /\/packages\/[^/]+\/src\//;
|
|
17
|
+
/**
|
|
18
|
+
* The version-diff component trees — matched in either published `dist/` or
|
|
19
|
+
* workspace `src/` form. The `.css` side-effect imports of these must be
|
|
20
|
+
* stripped in the RSC env (the rest of `@payloadcms/ui` must NOT be — see the
|
|
21
|
+
* note in `resolveId`/`transform` below), for two reasons rooted in the same
|
|
22
|
+
* `@vitejs/plugin-rsc` behaviour: it wraps every exported CSS-importing
|
|
23
|
+
* component with an async CSS-collector child
|
|
24
|
+
* (`__vite_rsc_wrap_css__` → `await import('virtual:vite-rsc/css?…')`).
|
|
25
|
+
*
|
|
26
|
+
* 1. Correctness: the diff converters render `CheckIcon` (`icons/*`) and `File`
|
|
27
|
+
* (`graphics/*`) through the SYNCHRONOUS `renderToStaticMarkup` (see
|
|
28
|
+
* `reactDomServerInRsc`). The async wrapper suspends, crashing that render
|
|
29
|
+
* with "A component suspended while responding to synchronous input" and
|
|
30
|
+
* taking down the entire field-diffs tree.
|
|
31
|
+
* 2. Performance: the diff view (`views/Version/*` — `RenderFieldsToDiff` and
|
|
32
|
+
* its per-field components, `DiffCollapser`, `SelectComparison`, the
|
|
33
|
+
* `Default` template — plus the `HTMLDiff`/`FieldDiffContainer`/
|
|
34
|
+
* `FieldDiffLabel` elements and lexical's `field/Diff/*`) renders dozens of
|
|
35
|
+
* these wrapped components in the Flight stream. Each async CSS import
|
|
36
|
+
* serializes a round-trip, ballooning the render from ~3s to ~25s and
|
|
37
|
+
* blowing past the e2e waits. Stripping them collapses it back to ~3s.
|
|
38
|
+
*
|
|
39
|
+
* Safe because every one of these components' styles also ship in the global
|
|
40
|
+
* `@payloadcms/ui/scss/app.scss` the admin imports, so dropping the per-module
|
|
41
|
+
* RSC collection here changes nothing visually (verified: diff + Nav stay
|
|
42
|
+
* styled). The admin `Nav` etc. are deliberately excluded — they rely on the
|
|
43
|
+
* RSC collection and a broad strip leaves them unstyled.
|
|
44
|
+
*/ const DIFF_VIEW_COMPONENT_RE = /@payloadcms\/ui\/(?:dist|src)\/(?:icons|graphics|views\/Version|elements\/(?:HTMLDiff|FieldDiffContainer|FieldDiffLabel))\/|@payloadcms\/richtext-lexical\/(?:dist|src)\/field\/Diff\//;
|
|
17
45
|
/**
|
|
18
46
|
* Stops Vite (and the underlying Node ESM loader) from trying to load
|
|
19
47
|
* SCSS/CSS/LESS during SSR/RSC when the importer lives inside a built
|
|
@@ -73,9 +101,11 @@ const STYLE_EXTENSION_RE = /\.(?:s?css|less)$/i;
|
|
|
73
101
|
if (!isServerEnv) {
|
|
74
102
|
return;
|
|
75
103
|
}
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
|
|
104
|
+
// In the RSC env, only strip from the version-diff component trees (see
|
|
105
|
+
// `DIFF_VIEW_COMPONENT_RE`). Every other server component (the admin
|
|
106
|
+
// `Nav`, etc.) must keep its `.css` import so plugin-rsc can collect it —
|
|
107
|
+
// see the matching note in `resolveId` above.
|
|
108
|
+
if (envName === 'rsc' && !DIFF_VIEW_COMPONENT_RE.test(id)) {
|
|
79
109
|
return;
|
|
80
110
|
}
|
|
81
111
|
// Only touch Payload dependency files: published `node_modules/.../dist/`
|
|
@@ -87,7 +117,10 @@ const STYLE_EXTENSION_RE = /\.(?:s?css|less)$/i;
|
|
|
87
117
|
if (!isPayloadDistFile && !isPayloadSrcFile) {
|
|
88
118
|
return;
|
|
89
119
|
}
|
|
90
|
-
|
|
120
|
+
// Allow a trailing query (`?v=…`, `?t=…`): Vite appends version/timestamp
|
|
121
|
+
// queries to module ids, especially in the RSC graph, so a strict `$`
|
|
122
|
+
// anchor would skip e.g. `icons/Check/index.js?v=83de8543`.
|
|
123
|
+
if (!/\.[mc]?[jt]sx?(?:$|\?)/.test(id)) {
|
|
91
124
|
return;
|
|
92
125
|
}
|
|
93
126
|
if (!STATIC_STYLE_IMPORT_RE.test(code)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/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/scss/app.scss` 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,cAAcH,SAASI,OAAQH,WAAWA,YAAY;YAC5D,IAAI,CAACE,aAAa;gBAChB;YACF;YACA,yEAAyE;YACzE,0EAA0E;YAC1E,2EAA2E;YAC3E,yEAAyE;YACzE,wEAAwE;YACxE,iEAAiE;YACjE,qEAAqE;YACrE,0EAA0E;YAC1E,IAAIF,YAAY,OAAO;gBACrB;YACF;YACA,IAAI,CAACZ,mBAAmBgB,IAAI,CAACR,KAAK;gBAChC;YACF;YACA,IAAIE,YAAa,CAAA,WAAWM,IAAI,CAACN,aAAaR,mBAAmBc,IAAI,CAACN,SAAQ,GAAI;gBAChF,OAAO;YACT;YACA,IAAI,WAAWM,IAAI,CAACR,OAAO,CAACA,GAAGS,UAAU,CAAC,QAAQ,CAACT,GAAGS,UAAU,CAAC,MAAM;gBACrE,OAAO;YACT;QACF;QACAC,WAAUC,IAAI,EAAEX,EAAE;YAChB,MAAMI,UAAU,AAAC,IAAI,CAASC,WAAW,EAAER;YAC3C,MAAMS,cAAcF,WAAWA,YAAY;YAC3C,IAAI,CAACE,aAAa;gBAChB;YACF;YACA,wEAAwE;YACxE,qEAAqE;YACrE,0EAA0E;YAC1E,8CAA8C;YAC9C,IAAIF,YAAY,SAAS,CAACT,uBAAuBa,IAAI,CAACR,KAAK;gBACzD;YACF;YACA,0EAA0E;YAC1E,0EAA0E;YAC1E,wEAAwE;YACxE,qEAAqE;YACrE,MAAMY,oBAAoB,mBAAmBJ,IAAI,CAACR,OAAO,WAAWQ,IAAI,CAACR;YACzE,MAAMa,mBAAmBnB,mBAAmBc,IAAI,CAACR;YACjD,IAAI,CAACY,qBAAqB,CAACC,kBAAkB;gBAC3C;YACF;YACA,0EAA0E;YAC1E,sEAAsE;YACtE,4DAA4D;YAC5D,IAAI,CAAC,yBAAyBL,IAAI,CAACR,KAAK;gBACtC;YACF;YACA,IAAI,CAACP,uBAAuBe,IAAI,CAACG,OAAO;gBACtClB,uBAAuBqB,SAAS,GAAG;gBACnC;YACF;YACArB,uBAAuBqB,SAAS,GAAG;YACnC,MAAMC,WAAWJ,KAAKK,OAAO,CAACvB,wBAAwB;YACtD,OAAO;gBAAEkB,MAAMI;gBAAUE,KAAK;YAAK;QACrC;IACF;AACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PluginOption } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Stubs `prettier` in the CLIENT bundle only.
|
|
4
|
+
*
|
|
5
|
+
* `payload`'s barrel transitively pulls `configToJSONSchema` →
|
|
6
|
+
* `json-schema-to-typescript` → `prettier` (CommonJS) into the client module
|
|
7
|
+
* graph through re-export side effects. That path is type-generation only
|
|
8
|
+
* (`payload generate:types`) and never runs in the browser, but the bundler
|
|
9
|
+
* still drags `prettier`'s `index.cjs` in — where it fails to parse as ESM and
|
|
10
|
+
* breaks the client build.
|
|
11
|
+
*
|
|
12
|
+
* We redirect `prettier` to a no-op `format` stub in the client environment
|
|
13
|
+
* only. SSR/RSC keep the real `prettier` (there `json-schema-to-typescript`
|
|
14
|
+
* stays external and resolves it from `node_modules`), and the `prettier` CLI /
|
|
15
|
+
* `payload generate:types` are unaffected.
|
|
16
|
+
*
|
|
17
|
+
* Delete this once `payload`'s barrel no longer reaches the type-gen path from
|
|
18
|
+
* the client-reachable export graph.
|
|
19
|
+
*/
|
|
20
|
+
export declare function stubPrettierInClient(): PluginOption;
|
|
21
|
+
//# sourceMappingURL=stubPrettierInClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stubPrettierInClient.d.ts","sourceRoot":"","sources":["../../../src/vite/workarounds/stubPrettierInClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,CAoBnD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stubs `prettier` in the CLIENT bundle only.
|
|
3
|
+
*
|
|
4
|
+
* `payload`'s barrel transitively pulls `configToJSONSchema` →
|
|
5
|
+
* `json-schema-to-typescript` → `prettier` (CommonJS) into the client module
|
|
6
|
+
* graph through re-export side effects. That path is type-generation only
|
|
7
|
+
* (`payload generate:types`) and never runs in the browser, but the bundler
|
|
8
|
+
* still drags `prettier`'s `index.cjs` in — where it fails to parse as ESM and
|
|
9
|
+
* breaks the client build.
|
|
10
|
+
*
|
|
11
|
+
* We redirect `prettier` to a no-op `format` stub in the client environment
|
|
12
|
+
* only. SSR/RSC keep the real `prettier` (there `json-schema-to-typescript`
|
|
13
|
+
* stays external and resolves it from `node_modules`), and the `prettier` CLI /
|
|
14
|
+
* `payload generate:types` are unaffected.
|
|
15
|
+
*
|
|
16
|
+
* Delete this once `payload`'s barrel no longer reaches the type-gen path from
|
|
17
|
+
* the client-reachable export graph.
|
|
18
|
+
*/ export function stubPrettierInClient() {
|
|
19
|
+
const RESOLVED_ID = '\0payload:prettier-client-stub';
|
|
20
|
+
return {
|
|
21
|
+
name: 'payload:stub-prettier-in-client',
|
|
22
|
+
enforce: 'pre',
|
|
23
|
+
load (id) {
|
|
24
|
+
if (id === RESOLVED_ID) {
|
|
25
|
+
return 'export const format = (source) => source;\nexport default { format };';
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
resolveId (id, _importer, options) {
|
|
29
|
+
if (options?.ssr) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (id === 'prettier') {
|
|
33
|
+
return RESOLVED_ID;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=stubPrettierInClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/workarounds/stubPrettierInClient.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\n/**\n * Stubs `prettier` in the CLIENT bundle only.\n *\n * `payload`'s barrel transitively pulls `configToJSONSchema` →\n * `json-schema-to-typescript` → `prettier` (CommonJS) into the client module\n * graph through re-export side effects. That path is type-generation only\n * (`payload generate:types`) and never runs in the browser, but the bundler\n * still drags `prettier`'s `index.cjs` in — where it fails to parse as ESM and\n * breaks the client build.\n *\n * We redirect `prettier` to a no-op `format` stub in the client environment\n * only. SSR/RSC keep the real `prettier` (there `json-schema-to-typescript`\n * stays external and resolves it from `node_modules`), and the `prettier` CLI /\n * `payload generate:types` are unaffected.\n *\n * Delete this once `payload`'s barrel no longer reaches the type-gen path from\n * the client-reachable export graph.\n */\nexport function stubPrettierInClient(): PluginOption {\n const RESOLVED_ID = '\\0payload:prettier-client-stub'\n\n return {\n name: 'payload:stub-prettier-in-client',\n enforce: 'pre',\n load(id) {\n if (id === RESOLVED_ID) {\n return 'export const format = (source) => source;\\nexport default { format };'\n }\n },\n resolveId(id, _importer, options) {\n if (options?.ssr) {\n return\n }\n if (id === 'prettier') {\n return RESOLVED_ID\n }\n },\n }\n}\n"],"names":["stubPrettierInClient","RESOLVED_ID","name","enforce","load","id","resolveId","_importer","options","ssr"],"mappings":"AAEA;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASA;IACd,MAAMC,cAAc;IAEpB,OAAO;QACLC,MAAM;QACNC,SAAS;QACTC,MAAKC,EAAE;YACL,IAAIA,OAAOJ,aAAa;gBACtB,OAAO;YACT;QACF;QACAK,WAAUD,EAAE,EAAEE,SAAS,EAAEC,OAAO;YAC9B,IAAIA,SAASC,KAAK;gBAChB;YACF;YACA,IAAIJ,OAAO,YAAY;gBACrB,OAAOJ;YACT;QACF;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapCjsForClient.d.ts","sourceRoot":"","sources":["../../../src/vite/workarounds/wrapCjsForClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,CAqE/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/workarounds/wrapCjsForClient.ts"],"sourcesContent":["import type { PluginOption } from 'vite'\n\n/**\n * Wraps CJS `node_modules` files in ESM-compatible code when served to the\n * client.\n *\n * Packages in `optimizeDeps.exclude` (like `payload`, `@payloadcms/ui`) import\n * CJS dependencies that Vite serves via raw `/@fs/` URLs, bypassing\n * pre-bundling. The browser fails to parse them because they use\n * `module.exports` / `exports.X` syntax.\n *\n * This plugin detects CJS patterns in the transform phase and wraps them with\n * a CommonJS-like runtime shim so the browser can execute them as ESM.\n */\nexport function wrapCjsForClient(): PluginOption {\n return {\n name: 'payload:wrap-cjs-client',\n apply: 'serve',\n enforce: 'post',\n transform(code, id, options) {\n if (options?.ssr) {\n return\n }\n\n if (!id.includes('/node_modules/') || id.includes('/node_modules/.vite/')) {\n return\n }\n\n const cleanId = id.replace(/\\?.*$/, '')\n if (!cleanId.endsWith('.js') && !cleanId.endsWith('.cjs')) {\n return\n }\n\n if (code.includes('import ') || code.includes('export ')) {\n return\n }\n\n if (\n !code.includes('module.exports') &&\n !code.includes('exports.') &&\n !code.includes('Object.defineProperty(exports')\n ) {\n return\n }\n\n const namedExports = extractCjsExports(code)\n const names = Object.keys(namedExports)\n\n const declaredIdentifiers = extractDeclaredIdentifiers(code)\n const safeNames = names.filter((name) => !declaredIdentifiers.has(name))\n\n // If the module already declares its own top-level `require` (rare but\n // possible for hand-written CJS), skip injecting our stub so we don't\n // produce a `SyntaxError: Identifier 'require' has already been declared`.\n const injectRequireStub = !declaredIdentifiers.has('require')\n\n const wrapped = [\n `var module = { exports: {} };`,\n `var exports = module.exports;`,\n // Expose a `require` stub so UMD wrappers that gate their CJS branch on\n // `typeof require === 'function'` (e.g. pluralize) take that branch and\n // assign to our `module.exports` instead of falling through to the\n // browser-globals branch (`root.foo = ...`), which throws in strict ESM\n // because the IIFE receives `this === undefined`.\n // The stub throws on actual invocation so any module that *really* needs\n // require fails loudly instead of silently misbehaving.\n injectRequireStub\n ? `var require = function require() { throw new Error(\"require() is not available in the browser bundle\"); };`\n : ``,\n ``,\n code,\n ``,\n `var __cjs_result__ = module.exports;`,\n `export default __cjs_result__;`,\n ...safeNames.map(\n (name) =>\n `export var ${name} = typeof __cjs_result__ === 'object' && __cjs_result__ !== null ? __cjs_result__[\"${name}\"] : undefined;`,\n ),\n ].join('\\n')\n\n return { code: wrapped, map: null }\n },\n }\n}\n\nfunction extractCjsExports(code: string): Record<string, true> {\n const found: Record<string, true> = {}\n const patterns = [\n /exports\\.(\\w+)\\s*=/g,\n /exports\\[[\"'](\\w+)[\"']\\]\\s*=/g,\n /Object\\.defineProperty\\(exports,\\s*[\"'](\\w+)[\"']/g,\n ]\n for (const re of patterns) {\n let m\n while ((m = re.exec(code)) !== null) {\n const name = m[1]!\n if (name !== '__esModule' && name !== 'default') {\n found[name] = true\n }\n }\n }\n return found\n}\n\n/**\n * Detects top-level identifiers declared with class/function/var/let/const in\n * CJS code. Used to avoid re-declaring them via `export var` in the CJS\n * wrapper, which would cause `SyntaxError: Identifier has already been\n * declared` in strict mode (ESM).\n */\nfunction extractDeclaredIdentifiers(code: string): Set<string> {\n const identifiers = new Set<string>()\n const patterns = [/\\bclass\\s+(\\w+)/g, /\\bfunction\\s+(\\w+)/g, /\\b(?:var|let|const)\\s+(\\w+)/g]\n for (const re of patterns) {\n let m\n while ((m = re.exec(code)) !== null) {\n identifiers.add(m[1]!)\n }\n }\n return identifiers\n}\n"],"names":["wrapCjsForClient","name","apply","enforce","transform","code","id","options","ssr","includes","cleanId","replace","endsWith","namedExports","extractCjsExports","names","Object","keys","declaredIdentifiers","extractDeclaredIdentifiers","safeNames","filter","has","injectRequireStub","wrapped","map","join","found","patterns","re","m","exec","identifiers","Set","add"],"mappings":"AAEA;;;;;;;;;;;CAWC,GACD,OAAO,SAASA;IACd,OAAO;QACLC,MAAM;QACNC,OAAO;QACPC,SAAS;QACTC,WAAUC,IAAI,EAAEC,EAAE,EAAEC,OAAO;YACzB,IAAIA,SAASC,KAAK;gBAChB;YACF;YAEA,IAAI,CAACF,GAAGG,QAAQ,CAAC,qBAAqBH,GAAGG,QAAQ,CAAC,yBAAyB;gBACzE;YACF;YAEA,MAAMC,UAAUJ,GAAGK,OAAO,CAAC,SAAS;YACpC,IAAI,CAACD,QAAQE,QAAQ,CAAC,UAAU,CAACF,QAAQE,QAAQ,CAAC,SAAS;gBACzD;YACF;YAEA,IAAIP,KAAKI,QAAQ,CAAC,cAAcJ,KAAKI,QAAQ,CAAC,YAAY;gBACxD;YACF;YAEA,IACE,CAACJ,KAAKI,QAAQ,CAAC,qBACf,CAACJ,KAAKI,QAAQ,CAAC,eACf,CAACJ,KAAKI,QAAQ,CAAC,kCACf;gBACA;YACF;YAEA,MAAMI,eAAeC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;QAAoB;QAAuB;KAA+B;IAC5F,KAAK,MAAMC,MAAMD,SAAU;QACzB,IAAIE;QACJ,MAAO,AAACA,CAAAA,IAAID,GAAGE,IAAI,CAAC1B,KAAI,MAAO,KAAM;YACnC2B,YAAYE,GAAG,CAACJ,CAAC,CAAC,EAAE;QACtB;IACF;IACA,OAAOE;AACT"}
|
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.811e0a4",
|
|
4
4
|
"description": "TanStack Start framework adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -57,34 +57,32 @@
|
|
|
57
57
|
"dist"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
+
"@vitejs/plugin-react": "^6.0.0",
|
|
61
|
+
"@vitejs/plugin-rsc": "^0.5.21",
|
|
60
62
|
"qs-esm": "^7.0.2",
|
|
61
|
-
"@payloadcms/translations": "4.0.0-internal.
|
|
62
|
-
"@payloadcms/ui": "4.0.0-internal.
|
|
63
|
+
"@payloadcms/translations": "4.0.0-internal.811e0a4",
|
|
64
|
+
"@payloadcms/ui": "4.0.0-internal.811e0a4"
|
|
63
65
|
},
|
|
64
66
|
"devDependencies": {
|
|
65
67
|
"@tanstack/react-router": "^1.120.0",
|
|
66
|
-
"@tanstack/react-start": "^1.
|
|
68
|
+
"@tanstack/react-start": "^1.168.26",
|
|
67
69
|
"@types/react": "^19.0.0",
|
|
68
70
|
"@types/react-dom": "^19.0.0",
|
|
69
|
-
"@vitejs/plugin-
|
|
71
|
+
"@vitejs/plugin-rsc": "^0.5.21",
|
|
70
72
|
"react": "^19.0.0",
|
|
71
73
|
"react-dom": "^19.0.0",
|
|
72
74
|
"vite": ">=8.0.0",
|
|
73
|
-
"payload": "4.0.0-internal.
|
|
75
|
+
"payload": "4.0.0-internal.811e0a4"
|
|
74
76
|
},
|
|
75
77
|
"peerDependencies": {
|
|
76
78
|
"@tanstack/react-router": "^1.120.0",
|
|
77
|
-
"@tanstack/react-start": "^1.
|
|
78
|
-
"@vitejs/plugin-react": "^6.0.0",
|
|
79
|
+
"@tanstack/react-start": "^1.168.26",
|
|
79
80
|
"react": "^19.0.0",
|
|
80
81
|
"react-dom": "^19.0.0",
|
|
81
82
|
"vite": ">=8.0.0",
|
|
82
|
-
"payload": "4.0.0-internal.
|
|
83
|
+
"payload": "4.0.0-internal.811e0a4"
|
|
83
84
|
},
|
|
84
85
|
"peerDependenciesMeta": {
|
|
85
|
-
"@vitejs/plugin-react": {
|
|
86
|
-
"optional": true
|
|
87
|
-
},
|
|
88
86
|
"vite": {
|
|
89
87
|
"optional": true
|
|
90
88
|
}
|
package/dist/@types/assets.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/@types/assets.d.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"switchLanguage.d.ts","sourceRoot":"","sources":["../../src/auth/switchLanguage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAK5D,wBAAsB,cAAc,CAAC,EACnC,MAAM,EACN,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;IACrC,QAAQ,EAAE,MAAM,CAAA;CACjB,iBAQA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { setResponseHeader } from '@tanstack/react-start/server';
|
|
2
|
-
import { getPayload } from 'payload';
|
|
3
|
-
export async function switchLanguage({ config, language }) {
|
|
4
|
-
const payload = await getPayload({
|
|
5
|
-
config
|
|
6
|
-
});
|
|
7
|
-
const cookiePrefix = payload.config.cookiePrefix || 'payload';
|
|
8
|
-
setResponseHeader('Set-Cookie', `${encodeURIComponent(`${cookiePrefix}-lng`)}=${encodeURIComponent(language)}; Path=/`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=switchLanguage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/switchLanguage.ts"],"sourcesContent":["import type { MaybePromise, SanitizedConfig } from 'payload'\n\nimport { setResponseHeader } from '@tanstack/react-start/server'\nimport { getPayload } from 'payload'\n\nexport async function switchLanguage({\n config,\n language,\n}: {\n config: MaybePromise<SanitizedConfig>\n language: string\n}) {\n const payload = await getPayload({ config })\n const cookiePrefix = payload.config.cookiePrefix || 'payload'\n\n setResponseHeader(\n 'Set-Cookie',\n `${encodeURIComponent(`${cookiePrefix}-lng`)}=${encodeURIComponent(language)}; Path=/`,\n )\n}\n"],"names":["setResponseHeader","getPayload","switchLanguage","config","language","payload","cookiePrefix","encodeURIComponent"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,UAAU,QAAQ,UAAS;AAEpC,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,QAAQ,EAIT;IACC,MAAMC,UAAU,MAAMJ,WAAW;QAAEE;IAAO;IAC1C,MAAMG,eAAeD,QAAQF,MAAM,CAACG,YAAY,IAAI;IAEpDN,kBACE,cACA,GAAGO,mBAAmB,GAAGD,aAAa,IAAI,CAAC,EAAE,CAAC,EAAEC,mBAAmBH,UAAU,QAAQ,CAAC;AAE1F"}
|