@payloadcms/tanstack-start 4.0.0-internal.cea8867 → 4.0.0-internal.e387174
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +1 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/server.d.ts +1 -1
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +1 -1
- package/dist/exports/server.js.map +1 -1
- package/dist/exports/vite.d.ts +2 -2
- package/dist/exports/vite.d.ts.map +1 -1
- package/dist/exports/vite.js +1 -1
- package/dist/exports/vite.js.map +1 -1
- package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
- package/dist/layouts/Root/getLayoutData.js +1 -1
- package/dist/layouts/Root/getLayoutData.js.map +1 -1
- package/dist/layouts/Root/index.js +2 -4
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/layouts/Root/withPayloadRoot.d.ts +31 -7
- package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -1
- package/dist/layouts/Root/withPayloadRoot.js +34 -33
- package/dist/layouts/Root/withPayloadRoot.js.map +1 -1
- package/dist/node/cssLoader.d.mts +2 -24
- package/dist/node/cssLoader.d.mts.map +1 -1
- package/dist/routes/adminRoutes.d.ts.map +1 -1
- package/dist/routes/layoutRoute.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/utilities/serverAdapter.server.d.ts.map +1 -1
- package/dist/vite/constants.d.ts +42 -0
- package/dist/vite/constants.d.ts.map +1 -0
- package/dist/vite/{config/optimizeDeps.js → constants.js} +63 -9
- package/dist/vite/constants.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 +177 -0
- package/dist/vite/plugin.js.map +1 -0
- package/dist/vite/plugins/clientModuleResolution.d.ts.map +1 -0
- package/dist/vite/plugins/clientModuleResolution.js.map +1 -0
- package/dist/vite/plugins/devTransforms.d.ts.map +1 -0
- package/dist/vite/{workarounds → plugins}/devTransforms.js +0 -5
- package/dist/vite/plugins/devTransforms.js.map +1 -0
- package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +1 -0
- package/dist/vite/plugins/reactDomServerInRsc.js.map +1 -0
- package/dist/vite/plugins/stripDistStyleImports.d.ts.map +1 -0
- package/dist/vite/plugins/stripDistStyleImports.js.map +1 -0
- package/dist/vite/plugins/wrapCjsForClient.d.ts.map +1 -0
- package/dist/vite/plugins/wrapCjsForClient.js.map +1 -0
- package/package.json +5 -10
- package/dist/vite/config/external.d.ts +0 -11
- package/dist/vite/config/external.d.ts.map +0 -1
- package/dist/vite/config/external.js +0 -48
- package/dist/vite/config/external.js.map +0 -1
- package/dist/vite/config/optimizeDeps.d.ts +0 -25
- package/dist/vite/config/optimizeDeps.d.ts.map +0 -1
- package/dist/vite/config/optimizeDeps.js.map +0 -1
- package/dist/vite/config/scss.d.ts +0 -14
- package/dist/vite/config/scss.d.ts.map +0 -1
- package/dist/vite/config/scss.js +0 -28
- package/dist/vite/config/scss.js.map +0 -1
- package/dist/vite/index.d.ts +0 -99
- package/dist/vite/index.d.ts.map +0 -1
- package/dist/vite/index.js +0 -258
- package/dist/vite/index.js.map +0 -1
- package/dist/vite/workarounds/clientModuleResolution.d.ts.map +0 -1
- package/dist/vite/workarounds/clientModuleResolution.js.map +0 -1
- package/dist/vite/workarounds/devTransforms.d.ts.map +0 -1
- package/dist/vite/workarounds/devTransforms.js.map +0 -1
- package/dist/vite/workarounds/reactDomServerInRsc.d.ts.map +0 -1
- package/dist/vite/workarounds/reactDomServerInRsc.js.map +0 -1
- package/dist/vite/workarounds/stripDistStyleImports.d.ts.map +0 -1
- package/dist/vite/workarounds/stripDistStyleImports.js.map +0 -1
- package/dist/vite/workarounds/stubPrettierInClient.d.ts +0 -13
- package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +0 -1
- package/dist/vite/workarounds/stubPrettierInClient.js +0 -32
- package/dist/vite/workarounds/stubPrettierInClient.js.map +0 -1
- package/dist/vite/workarounds/wrapCjsForClient.d.ts.map +0 -1
- package/dist/vite/workarounds/wrapCjsForClient.js.map +0 -1
- /package/dist/vite/{workarounds → plugins}/clientModuleResolution.d.ts +0 -0
- /package/dist/vite/{workarounds → plugins}/clientModuleResolution.js +0 -0
- /package/dist/vite/{workarounds → plugins}/devTransforms.d.ts +0 -0
- /package/dist/vite/{workarounds → plugins}/reactDomServerInRsc.d.ts +0 -0
- /package/dist/vite/{workarounds → plugins}/reactDomServerInRsc.js +0 -0
- /package/dist/vite/{workarounds → plugins}/stripDistStyleImports.d.ts +0 -0
- /package/dist/vite/{workarounds → plugins}/stripDistStyleImports.js +0 -0
- /package/dist/vite/{workarounds → plugins}/wrapCjsForClient.d.ts +0 -0
- /package/dist/vite/{workarounds → plugins}/wrapCjsForClient.js +0 -0
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Client dep-optimizer config used by `withPayload`. Kept separate from the
|
|
3
|
-
* SSR/RSC externalization config (`./external.ts`) so each concern stays small.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Packages we know contain Node-only code or top-level side effects requiring
|
|
7
|
-
* Node APIs. Excluding them from the client optimizer prevents Vite from
|
|
8
|
-
* walking into their main entries and trying to bundle server-only imports
|
|
9
|
-
* for the browser.
|
|
10
|
-
*/
|
|
11
|
-
export declare const optimizeDepsExcludeDefaults: string[];
|
|
12
|
-
/**
|
|
13
|
-
* Transitive dependencies of `@payloadcms/ui` and `payload` that need to be
|
|
14
|
-
* pre-bundled for the client. Vite's auto-discovery doesn't reliably pick
|
|
15
|
-
* these up because their parent packages are in `optimizeDeps.exclude`, so we
|
|
16
|
-
* list them explicitly using the `parent > child` syntax.
|
|
17
|
-
*
|
|
18
|
-
* Each entry below fixes a specific late-discovery re-optimization: without it,
|
|
19
|
-
* Vite discovers the dep *after* its initial crawl, forcing a full dep
|
|
20
|
-
* re-optimization mid-session that 404s in-flight `.vite/deps/*` chunks and
|
|
21
|
-
* remounts the admin (dropping client state). This is why the list can't simply
|
|
22
|
-
* be deleted — it is the "complete first pass" for the admin's dep graph.
|
|
23
|
-
*/
|
|
24
|
-
export declare const optimizeDepsIncludeDefaults: string[];
|
|
25
|
-
//# sourceMappingURL=optimizeDeps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"optimizeDeps.d.ts","sourceRoot":"","sources":["../../../src/vite/config/optimizeDeps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAsB/C,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EA8E/C,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/vite/config/optimizeDeps.ts"],"sourcesContent":["/**\n * Client dep-optimizer config used by `withPayload`. Kept separate from the\n * SSR/RSC externalization config (`./external.ts`) so each concern stays small.\n */\n\n/**\n * Packages we know contain Node-only code or top-level side effects requiring\n * Node APIs. Excluding them from the client optimizer prevents Vite from\n * walking into their main entries and trying to bundle server-only imports\n * for the browser.\n */\nexport const optimizeDepsExcludeDefaults: string[] = [\n 'sharp',\n '@payloadcms/ui',\n '@payloadcms/tanstack-start',\n 'payload',\n 'pino',\n 'pino-pretty',\n 'busboy',\n 'get-tsconfig',\n 'ws',\n 'croner',\n 'prompts',\n 'file-type',\n // Server-only SDKs used by `@payloadcms/storage-*` adapters. Vite\n // sometimes walks these from the main package entry while scanning\n // workspace deps, and the browser sub-bundles do not expose the\n // server-only APIs (e.g. `BlobSASPermissions`), which crashes the dev\n // server with a `MISSING_EXPORT` error before any test runs.\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n]\n\n/**\n * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be\n * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick\n * these up because their parent packages are in `optimizeDeps.exclude`, so we\n * list them explicitly using the `parent > child` syntax.\n *\n * Each entry below fixes a specific late-discovery re-optimization: without it,\n * Vite discovers the dep *after* its initial crawl, forcing a full dep\n * re-optimization mid-session that 404s in-flight `.vite/deps/*` chunks and\n * remounts the admin (dropping client state). This is why the list can't simply\n * be deleted — it is the \"complete first pass\" for the admin's dep graph.\n */\nexport const optimizeDepsIncludeDefaults: string[] = [\n '@payloadcms/ui > sonner',\n '@payloadcms/ui > @faceless-ui/modal',\n '@payloadcms/ui > @faceless-ui/window-info',\n '@payloadcms/ui > @faceless-ui/scroll-info',\n '@payloadcms/ui > @dnd-kit/core',\n '@payloadcms/ui > @dnd-kit/sortable',\n '@payloadcms/ui > @dnd-kit/utilities',\n '@payloadcms/ui > react-datepicker',\n '@payloadcms/ui > react-select',\n '@payloadcms/ui > react-select/creatable',\n '@payloadcms/ui > react-image-crop',\n '@payloadcms/ui > @monaco-editor/react',\n '@payloadcms/ui > date-fns',\n '@payloadcms/ui > date-fns/transpose',\n '@payloadcms/ui > @date-fns/tz/date/mini',\n '@payloadcms/ui > uuid',\n '@payloadcms/ui > use-context-selector',\n '@payloadcms/ui > bson-objectid',\n '@payloadcms/ui > dequal',\n '@payloadcms/ui > object-to-formdata',\n '@payloadcms/ui > md5',\n 'payload > deepmerge',\n 'payload > pluralize',\n // `scheduler` is a transitive dep of `react-dom`, not a direct dependency of\n // the app, so a bare `'scheduler'` specifier fails to resolve from an isolated\n // install (`test/node_modules` built with `pnpm i --ignore-workspace`), where\n // it isn't hoisted to the top level. Path it through `react-dom` so the\n // optimizer resolves the exact copy the runtime loads.\n 'react-dom > scheduler',\n // `@payloadcms/ui` (in `optimizeDeps.exclude`) ships compiled output that the\n // React Compiler rewrote to `import { c } from 'react/compiler-runtime'`.\n // Because its parent is excluded, the optimizer never crawls in to discover\n // this entry, so Vite serves `react/compiler-runtime` raw. That file is\n // CommonJS (`module.exports = require(...)`), so the named `c` export can't be\n // statically extracted and every client component throws \"does not provide an\n // export named 'c'\". Pre-bundling it lets esbuild synthesize the named export.\n 'react/compiler-runtime',\n // Transitive deps that Vite otherwise discovers *after* the initial crawl\n // (react-select pulls in @floating-ui at runtime; react-is is reached via\n // react-transition-group/prop-types; the default date-fns locale is loaded\n // through a dynamic `date-fns/locale/${key}` import). A late discovery forces\n // a full dep re-optimization mid-session, which 404s every in-flight\n // `.vite/deps/*` chunk (\"Pre-transform error: file does not exist in the\n // optimize deps directory\") and breaks the admin UI in CI cold starts.\n // Pre-bundling them keeps the first optimization pass complete.\n '@payloadcms/ui > react-select > @floating-ui/dom',\n '@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',\n '@payloadcms/ui > react-select > prop-types > react-is',\n '@payloadcms/ui > date-fns/locale/en-US',\n // Further late discoveries observed re-optimizing mid-run in CI cold starts\n // (see CI logs: \"✨ new dependencies optimized: @dnd-kit/modifiers / ajv /\n // dequal/lite\"). The modular dashboard pulls in `@dnd-kit/modifiers` on first\n // render; form-state diffing reaches `dequal/lite` (a distinct entry point\n // from the already-listed `dequal`); client-side field validation reaches\n // `ajv` *through `payload`* — it is `ssrExternal` server-side but still\n // bundled into the client, and must be pathed via `payload` so the optimizer\n // pre-bundles the exact copy the runtime loads.\n '@payloadcms/ui > @dnd-kit/modifiers',\n '@payloadcms/ui > dequal/lite',\n 'payload > ajv',\n // The storage client-upload suites (esp. vercel-blob) crawl part of the\n // `payload` server runtime into the client bundle and discover these late,\n // triggering several \"optimized dependencies changed. reloading\" waves that\n // reload the page mid-test (the bulk-upload drawer's Create New button /\n // dropzone vanish and the direct-to-bucket PUT never fires). Pre-bundle the\n // whole observed set so the first pass is complete.\n 'payload > undici',\n 'payload > jose',\n 'payload > dataloader',\n 'payload > path-to-regexp',\n 'payload > console-table-printer',\n 'payload > ci-info',\n 'payload > image-size',\n 'payload > image-size/fromFile',\n 'payload > ipaddr.js',\n 'payload > range-parser',\n 'payload > sanitize-filename',\n]\n"],"names":["optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults"],"mappings":"AAAA;;;CAGC,GAED;;;;;CAKC,GACD,OAAO,MAAMA,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,kEAAkE;IAClE,mEAAmE;IACnE,gEAAgE;IAChE,sEAAsE;IACtE,6DAA6D;IAC7D;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,6EAA6E;IAC7E,+EAA+E;IAC/E,8EAA8E;IAC9E,wEAAwE;IACxE,uDAAuD;IACvD;IACA,8EAA8E;IAC9E,0EAA0E;IAC1E,4EAA4E;IAC5E,wEAAwE;IACxE,+EAA+E;IAC/E,8EAA8E;IAC9E,+EAA+E;IAC/E;IACA,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,8EAA8E;IAC9E,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,gEAAgE;IAChE;IACA;IACA;IACA;IACA,4EAA4E;IAC5E,0EAA0E;IAC1E,8EAA8E;IAC9E,2EAA2E;IAC3E,0EAA0E;IAC1E,wEAAwE;IACxE,6EAA6E;IAC7E,gDAAgD;IAChD;IACA;IACA;IACA,wEAAwE;IACxE,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,4EAA4E;IAC5E,oDAAoD;IACpD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SCSS `@import`/`@use` importers applied for every Payload consumer.
|
|
3
|
-
*
|
|
4
|
-
* Resolves webpack-style `~@payloadcms/...` tilde specifiers (emitted by
|
|
5
|
-
* first-party Payload package styles, e.g. `@payloadcms/richtext-slate`) to the
|
|
6
|
-
* installed package via Node resolution. Because it goes through the package's
|
|
7
|
-
* `exports` map, it picks the workspace `src` scss in the monorepo and the
|
|
8
|
-
* published `dist` scss in a consumer install automatically — no per-app
|
|
9
|
-
* `findFileUrl` shim needed.
|
|
10
|
-
*/
|
|
11
|
-
export declare const payloadScssImporters: {
|
|
12
|
-
findFileUrl(url: string): null | URL;
|
|
13
|
-
}[];
|
|
14
|
-
//# sourceMappingURL=scss.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scss.d.ts","sourceRoot":"","sources":["../../../src/vite/config/scss.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;qBAEZ,MAAM,GAAG,IAAI,GAAG,GAAG;GAWvC,CAAA"}
|
package/dist/vite/config/scss.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
import { pathToFileURL } from 'node:url';
|
|
3
|
-
const require = createRequire(import.meta.url);
|
|
4
|
-
/**
|
|
5
|
-
* SCSS `@import`/`@use` importers applied for every Payload consumer.
|
|
6
|
-
*
|
|
7
|
-
* Resolves webpack-style `~@payloadcms/...` tilde specifiers (emitted by
|
|
8
|
-
* first-party Payload package styles, e.g. `@payloadcms/richtext-slate`) to the
|
|
9
|
-
* installed package via Node resolution. Because it goes through the package's
|
|
10
|
-
* `exports` map, it picks the workspace `src` scss in the monorepo and the
|
|
11
|
-
* published `dist` scss in a consumer install automatically — no per-app
|
|
12
|
-
* `findFileUrl` shim needed.
|
|
13
|
-
*/ export const payloadScssImporters = [
|
|
14
|
-
{
|
|
15
|
-
findFileUrl (url) {
|
|
16
|
-
if (!url.startsWith('~@payloadcms/')) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
return pathToFileURL(require.resolve(url.slice(1)));
|
|
21
|
-
} catch {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=scss.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/vite/config/scss.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport { pathToFileURL } from 'node:url'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * SCSS `@import`/`@use` importers applied for every Payload consumer.\n *\n * Resolves webpack-style `~@payloadcms/...` tilde specifiers (emitted by\n * first-party Payload package styles, e.g. `@payloadcms/richtext-slate`) to the\n * installed package via Node resolution. Because it goes through the package's\n * `exports` map, it picks the workspace `src` scss in the monorepo and the\n * published `dist` scss in a consumer install automatically — no per-app\n * `findFileUrl` shim needed.\n */\nexport const payloadScssImporters = [\n {\n findFileUrl(url: string): null | URL {\n if (!url.startsWith('~@payloadcms/')) {\n return null\n }\n try {\n return pathToFileURL(require.resolve(url.slice(1)))\n } catch {\n return null\n }\n },\n },\n]\n"],"names":["createRequire","pathToFileURL","require","url","payloadScssImporters","findFileUrl","startsWith","resolve","slice"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAa;AAC3C,SAASC,aAAa,QAAQ,WAAU;AAExC,MAAMC,UAAUF,cAAc,YAAYG,GAAG;AAE7C;;;;;;;;;CASC,GACD,OAAO,MAAMC,uBAAuB;IAClC;QACEC,aAAYF,GAAW;YACrB,IAAI,CAACA,IAAIG,UAAU,CAAC,kBAAkB;gBACpC,OAAO;YACT;YACA,IAAI;gBACF,OAAOL,cAAcC,QAAQK,OAAO,CAACJ,IAAIK,KAAK,CAAC;YACjD,EAAE,OAAM;gBACN,OAAO;YACT;QACF;IACF;CACD,CAAA"}
|
package/dist/vite/index.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import type { ConfigEnv, UserConfig, UserConfigFnObject } from 'vite';
|
|
2
|
-
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
3
|
-
import viteReact from '@vitejs/plugin-react';
|
|
4
|
-
import rsc from '@vitejs/plugin-rsc';
|
|
5
|
-
export type WithPayloadOptions = {
|
|
6
|
-
/** Extra import-protection `ignoreImporters` patterns for the TanStack Start plugin. */
|
|
7
|
-
additionalIgnoreImporters?: RegExp[];
|
|
8
|
-
/** Route id of Payload's admin layout, eager-loaded instead of code-split. Defaults to `'/_payload'`. */
|
|
9
|
-
adminRouteId?: string;
|
|
10
|
-
/** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */
|
|
11
|
-
clientDenialExcludeFiles?: string[];
|
|
12
|
-
/** Path to the user's `payload.config.ts` (required) */
|
|
13
|
-
payloadConfigPath: string;
|
|
14
|
-
/** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'` */
|
|
15
|
-
routesDirectory?: string;
|
|
16
|
-
/** Silence Vite warnings about third-party dependency sourcemaps. Defaults to `true`. */
|
|
17
|
-
silenceDependencyWarnings?: boolean;
|
|
18
|
-
/** TanStack source directory. Defaults to `'src'` */
|
|
19
|
-
srcDirectory?: string;
|
|
20
|
-
/** Extra Vite config deep-merged over the Payload defaults. Ignored in `build` mode. */
|
|
21
|
-
vite?: UserConfig;
|
|
22
|
-
};
|
|
23
|
-
/** The options Payload's admin requires for each third-party plugin. */
|
|
24
|
-
export type PayloadPluginOptions = {
|
|
25
|
-
react: NonNullable<Parameters<typeof viteReact>[0]>;
|
|
26
|
-
rsc: NonNullable<Parameters<typeof rsc>[0]>;
|
|
27
|
-
tanstackStart: NonNullable<Parameters<typeof tanstackStart>[0]>;
|
|
28
|
-
};
|
|
29
|
-
export type WithPayloadBuilderContext = {
|
|
30
|
-
env: ConfigEnv;
|
|
31
|
-
/** Options to pass to the `viteReact`/`rsc`/`tanstackStart` factories you import. */
|
|
32
|
-
pluginOptions: PayloadPluginOptions;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Returns the extra Vite config — the plugins you instantiate plus any overrides.
|
|
36
|
-
* `withPayload` deep-merges it onto Payload's base config, so you don't spread or
|
|
37
|
-
* merge the base yourself.
|
|
38
|
-
*/
|
|
39
|
-
export type WithPayloadBuilder = (context: WithPayloadBuilderContext) => UserConfig;
|
|
40
|
-
/**
|
|
41
|
-
* Vite config helper for Payload + TanStack Start; the counterpart to Next.js'
|
|
42
|
-
* `withPayload`.
|
|
43
|
-
*
|
|
44
|
-
* Zero-config — Payload instantiates the RSC, React, and TanStack Start plugins:
|
|
45
|
-
*
|
|
46
|
-
* ```ts
|
|
47
|
-
* export default withPayload(undefined, { payloadConfigPath: './src/payload.config.ts' })
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* Guest mode — pass a `build` callback to instantiate them yourself (one copy of
|
|
51
|
-
* each; `@vitejs/plugin-rsc` is a hard singleton). Return only your additions;
|
|
52
|
-
* `withPayload` deep-merges them onto Payload's base config:
|
|
53
|
-
*
|
|
54
|
-
* ```ts
|
|
55
|
-
* export default withPayload(
|
|
56
|
-
* ({ pluginOptions }) => ({
|
|
57
|
-
* plugins: [
|
|
58
|
-
* rsc(pluginOptions.rsc),
|
|
59
|
-
* tanstackStart(pluginOptions.tanstackStart),
|
|
60
|
-
* viteReact(pluginOptions.react),
|
|
61
|
-
* ],
|
|
62
|
-
* // ...other config options
|
|
63
|
-
* }),
|
|
64
|
-
* { payloadConfigPath: './src/payload.config.ts' },
|
|
65
|
-
* )
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
export declare function withPayload(build: undefined | WithPayloadBuilder, options: WithPayloadOptions): UserConfigFnObject;
|
|
69
|
-
/** `@vitejs/plugin-rsc` options for Payload: `serverHandler: false` (TanStack owns the handler). */
|
|
70
|
-
export declare function payloadRscOptions(): NonNullable<Parameters<typeof rsc>[0]>;
|
|
71
|
-
/** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */
|
|
72
|
-
export declare function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]>;
|
|
73
|
-
export type PayloadTanstackStartOptionsArgs = {
|
|
74
|
-
/** Additional import-protection `ignoreImporters` patterns. */
|
|
75
|
-
additionalIgnoreImporters?: RegExp[];
|
|
76
|
-
/**
|
|
77
|
-
* Route id of Payload's admin layout route, eager-loaded (not code-split) so it
|
|
78
|
-
* hydrates on first paint. It and its children skip splitting; host routes keep
|
|
79
|
-
* TanStack's default. Defaults to `'/_payload'` (the `_payload.tsx` convention).
|
|
80
|
-
*/
|
|
81
|
-
adminRouteId?: string;
|
|
82
|
-
/**
|
|
83
|
-
* Extra globs exempted from TanStack's `.client.*` SSR denial, on top of the
|
|
84
|
-
* default node_modules exemption. Needed only when Payload's own `.client.*`
|
|
85
|
-
* files resolve outside node_modules (e.g. the monorepo's `packages` sources).
|
|
86
|
-
*/
|
|
87
|
-
clientDenialExcludeFiles?: string[];
|
|
88
|
-
/** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'`. */
|
|
89
|
-
routesDirectory?: string;
|
|
90
|
-
/** TanStack source directory. Defaults to `'src'`. */
|
|
91
|
-
srcDirectory?: string;
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* The `tanstackStart` options Payload's admin requires (import-protection and
|
|
95
|
-
* code-splitting). TanStack Start is one-per-app, so a host that already runs it
|
|
96
|
-
* should merge these into its single `tanstackStart` call.
|
|
97
|
-
*/
|
|
98
|
-
export declare function payloadTanstackStartOptions(args?: PayloadTanstackStartOptionsArgs): NonNullable<Parameters<typeof tanstackStart>[0]>;
|
|
99
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/vite/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAwB,UAAU,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAI3F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AACjE,OAAO,SAAS,MAAM,sBAAsB,CAAA;AAC5C,OAAO,GAAG,MAAM,oBAAoB,CAAA;AA0DpC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wFAAwF;IACxF,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;IACpC,yGAAyG;IACzG,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wGAAwG;IACxG,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,wDAAwD;IACxD,iBAAiB,EAAE,MAAM,CAAA;IACzB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,yFAAyF;IACzF,yBAAyB,CAAC,EAAE,OAAO,CAAA;IACnC,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wFAAwF;IACxF,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED,wEAAwE;AACxE,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACnD,GAAG,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3C,aAAa,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAChE,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,SAAS,CAAA;IACd,qFAAqF;IACrF,aAAa,EAAE,oBAAoB,CAAA;CACpC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,yBAAyB,KAAK,UAAU,CAAA;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,GAAG,kBAAkB,EACrC,OAAO,EAAE,kBAAkB,GAC1B,kBAAkB,CAqGpB;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAE1E;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAElF;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,+DAA+D;IAC/D,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;IACpC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC,wFAAwF;IACxF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,GAAE,+BAAoC,GACzC,WAAW,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAwClD"}
|
package/dist/vite/index.js
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
// Optional peers, not deps: `plugin-rsc` is a singleton, so bundling our own copy
|
|
2
|
-
// alongside the host's would load two instances and crash.
|
|
3
|
-
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
4
|
-
import viteReact from '@vitejs/plugin-react';
|
|
5
|
-
import rsc from '@vitejs/plugin-rsc';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import { createLogger, mergeConfig } from 'vite';
|
|
8
|
-
import { payloadNoExternalPatterns, ssrExternalPackages } from './config/external.js';
|
|
9
|
-
import { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults } from './config/optimizeDeps.js';
|
|
10
|
-
import { payloadScssImporters } from './config/scss.js';
|
|
11
|
-
import { defaultImportProtectionIgnoreImporters, onImportProtectionViolation, serverOnlyClientSpecifiers } from './importProtection.js';
|
|
12
|
-
import { clientModuleResolution } from './workarounds/clientModuleResolution.js';
|
|
13
|
-
import { payloadDevTransforms } from './workarounds/devTransforms.js';
|
|
14
|
-
import { reactDomServerInRsc } from './workarounds/reactDomServerInRsc.js';
|
|
15
|
-
import { ssrStripDistStyleImports } from './workarounds/stripDistStyleImports.js';
|
|
16
|
-
import { stubPrettierInClient } from './workarounds/stubPrettierInClient.js';
|
|
17
|
-
import { wrapCjsForClient } from './workarounds/wrapCjsForClient.js';
|
|
18
|
-
/**
|
|
19
|
-
* Vite dependency warnings Payload consumers can't act on: third-party packages
|
|
20
|
-
* ship sourcemaps whose original sources aren't published, so Vite warns on
|
|
21
|
-
* every one. Suppressed by default (see `silenceDependencyWarnings`).
|
|
22
|
-
*/ const suppressibleWarningPatterns = [
|
|
23
|
-
'points to missing source files',
|
|
24
|
-
'Sourcemap for'
|
|
25
|
-
];
|
|
26
|
-
/**
|
|
27
|
-
* Wraps a Vite logger so warnings matching {@link suppressibleWarningPatterns}
|
|
28
|
-
* are dropped. Mutates and returns the given logger (or a fresh default one).
|
|
29
|
-
*/ function withQuietedDependencyWarnings(existing) {
|
|
30
|
-
const logger = existing ?? createLogger();
|
|
31
|
-
const shouldSuppress = (msg)=>typeof msg === 'string' && suppressibleWarningPatterns.some((pattern)=>msg.includes(pattern));
|
|
32
|
-
const baseWarn = logger.warn.bind(logger);
|
|
33
|
-
const baseWarnOnce = logger.warnOnce.bind(logger);
|
|
34
|
-
logger.warn = (msg, options)=>{
|
|
35
|
-
if (!shouldSuppress(msg)) {
|
|
36
|
-
baseWarn(msg, options);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
logger.warnOnce = (msg, options)=>{
|
|
40
|
-
if (!shouldSuppress(msg)) {
|
|
41
|
-
baseWarnOnce(msg, options);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
return logger;
|
|
45
|
-
}
|
|
46
|
-
/** Applies dependency-warning suppression to a config in place when enabled. */ function applyDependencyWarningSuppression(config, enabled) {
|
|
47
|
-
if (enabled) {
|
|
48
|
-
config.customLogger = withQuietedDependencyWarnings(config.customLogger);
|
|
49
|
-
}
|
|
50
|
-
return config;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Vite config helper for Payload + TanStack Start; the counterpart to Next.js'
|
|
54
|
-
* `withPayload`.
|
|
55
|
-
*
|
|
56
|
-
* Zero-config — Payload instantiates the RSC, React, and TanStack Start plugins:
|
|
57
|
-
*
|
|
58
|
-
* ```ts
|
|
59
|
-
* export default withPayload(undefined, { payloadConfigPath: './src/payload.config.ts' })
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* Guest mode — pass a `build` callback to instantiate them yourself (one copy of
|
|
63
|
-
* each; `@vitejs/plugin-rsc` is a hard singleton). Return only your additions;
|
|
64
|
-
* `withPayload` deep-merges them onto Payload's base config:
|
|
65
|
-
*
|
|
66
|
-
* ```ts
|
|
67
|
-
* export default withPayload(
|
|
68
|
-
* ({ pluginOptions }) => ({
|
|
69
|
-
* plugins: [
|
|
70
|
-
* rsc(pluginOptions.rsc),
|
|
71
|
-
* tanstackStart(pluginOptions.tanstackStart),
|
|
72
|
-
* viteReact(pluginOptions.react),
|
|
73
|
-
* ],
|
|
74
|
-
* // ...other config options
|
|
75
|
-
* }),
|
|
76
|
-
* { payloadConfigPath: './src/payload.config.ts' },
|
|
77
|
-
* )
|
|
78
|
-
* ```
|
|
79
|
-
*/ export function withPayload(build, options) {
|
|
80
|
-
const { additionalIgnoreImporters = [], adminRouteId, clientDenialExcludeFiles = [], payloadConfigPath, routesDirectory = 'app', silenceDependencyWarnings = true, srcDirectory = 'src', vite } = options;
|
|
81
|
-
return (env)=>{
|
|
82
|
-
const base = {
|
|
83
|
-
build: {
|
|
84
|
-
cssMinify: 'esbuild'
|
|
85
|
-
},
|
|
86
|
-
css: {
|
|
87
|
-
preprocessorOptions: {
|
|
88
|
-
scss: {
|
|
89
|
-
importers: payloadScssImporters,
|
|
90
|
-
silenceDeprecations: [
|
|
91
|
-
'import',
|
|
92
|
-
'global-builtin'
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
define: {
|
|
98
|
-
global: 'globalThis'
|
|
99
|
-
},
|
|
100
|
-
environments: {
|
|
101
|
-
rsc: {
|
|
102
|
-
build: {
|
|
103
|
-
rollupOptions: {
|
|
104
|
-
external: ssrExternalPackages
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
resolve: {
|
|
108
|
-
noExternal: payloadNoExternalPatterns
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
ssr: {
|
|
112
|
-
build: {
|
|
113
|
-
rollupOptions: {
|
|
114
|
-
external: ssrExternalPackages
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
resolve: {
|
|
118
|
-
noExternal: payloadNoExternalPatterns
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
optimizeDeps: {
|
|
123
|
-
exclude: optimizeDepsExcludeDefaults,
|
|
124
|
-
include: optimizeDepsIncludeDefaults
|
|
125
|
-
},
|
|
126
|
-
// Payload's internal workaround plugins only. The RSC, TanStack Start, and
|
|
127
|
-
// React plugins are appended below (default form) or by the consumer's
|
|
128
|
-
// `build` callback (guest form).
|
|
129
|
-
plugins: [
|
|
130
|
-
clientModuleResolution(),
|
|
131
|
-
wrapCjsForClient(),
|
|
132
|
-
ssrStripDistStyleImports(),
|
|
133
|
-
reactDomServerInRsc(),
|
|
134
|
-
stubPrettierInClient(),
|
|
135
|
-
payloadDevTransforms()
|
|
136
|
-
],
|
|
137
|
-
resolve: {
|
|
138
|
-
alias: [
|
|
139
|
-
{
|
|
140
|
-
find: '@payload-config',
|
|
141
|
-
replacement: path.resolve(payloadConfigPath)
|
|
142
|
-
}
|
|
143
|
-
],
|
|
144
|
-
dedupe: [
|
|
145
|
-
'react',
|
|
146
|
-
'react-dom',
|
|
147
|
-
'scheduler',
|
|
148
|
-
'@payloadcms/ui',
|
|
149
|
-
'@payloadcms/richtext-lexical'
|
|
150
|
-
],
|
|
151
|
-
extensions: [
|
|
152
|
-
'.mjs',
|
|
153
|
-
'.js',
|
|
154
|
-
'.mts',
|
|
155
|
-
'.ts',
|
|
156
|
-
'.jsx',
|
|
157
|
-
'.tsx',
|
|
158
|
-
'.json'
|
|
159
|
-
],
|
|
160
|
-
tsconfigPaths: true
|
|
161
|
-
},
|
|
162
|
-
ssr: {
|
|
163
|
-
external: ssrExternalPackages,
|
|
164
|
-
noExternal: payloadNoExternalPatterns
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
const pluginOptions = {
|
|
168
|
-
react: payloadReactOptions(),
|
|
169
|
-
rsc: payloadRscOptions(),
|
|
170
|
-
tanstackStart: payloadTanstackStartOptions({
|
|
171
|
-
additionalIgnoreImporters,
|
|
172
|
-
adminRouteId,
|
|
173
|
-
clientDenialExcludeFiles,
|
|
174
|
-
routesDirectory,
|
|
175
|
-
srcDirectory
|
|
176
|
-
})
|
|
177
|
-
};
|
|
178
|
-
if (build) {
|
|
179
|
-
return applyDependencyWarningSuppression(mergeConfig(base, build({
|
|
180
|
-
env,
|
|
181
|
-
pluginOptions
|
|
182
|
-
})), silenceDependencyWarnings);
|
|
183
|
-
}
|
|
184
|
-
base.plugins = [
|
|
185
|
-
...base.plugins,
|
|
186
|
-
rsc(pluginOptions.rsc),
|
|
187
|
-
tanstackStart(pluginOptions.tanstackStart),
|
|
188
|
-
viteReact(pluginOptions.react)
|
|
189
|
-
];
|
|
190
|
-
const merged = vite ? mergeConfig(base, vite) : base;
|
|
191
|
-
return applyDependencyWarningSuppression(merged, silenceDependencyWarnings);
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
/** `@vitejs/plugin-rsc` options for Payload: `serverHandler: false` (TanStack owns the handler). */ export function payloadRscOptions() {
|
|
195
|
-
return {
|
|
196
|
-
serverHandler: false
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
/** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */ export function payloadReactOptions() {
|
|
200
|
-
return {
|
|
201
|
-
exclude: [],
|
|
202
|
-
include: /\.[jt]sx?$/
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* The `tanstackStart` options Payload's admin requires (import-protection and
|
|
207
|
-
* code-splitting). TanStack Start is one-per-app, so a host that already runs it
|
|
208
|
-
* should merge these into its single `tanstackStart` call.
|
|
209
|
-
*/ export function payloadTanstackStartOptions(args = {}) {
|
|
210
|
-
const { additionalIgnoreImporters = [], adminRouteId = '/_payload', clientDenialExcludeFiles = [], routesDirectory = 'app', srcDirectory = 'src' } = args;
|
|
211
|
-
return {
|
|
212
|
-
importProtection: {
|
|
213
|
-
client: {
|
|
214
|
-
excludeFiles: [],
|
|
215
|
-
specifiers: serverOnlyClientSpecifiers
|
|
216
|
-
},
|
|
217
|
-
ignoreImporters: [
|
|
218
|
-
...defaultImportProtectionIgnoreImporters,
|
|
219
|
-
...additionalIgnoreImporters
|
|
220
|
-
],
|
|
221
|
-
include: [
|
|
222
|
-
'**/*'
|
|
223
|
-
],
|
|
224
|
-
mockAccess: 'warn',
|
|
225
|
-
onViolation: onImportProtectionViolation,
|
|
226
|
-
// Payload's `.client.*` components are React Client Components that must be
|
|
227
|
-
// server-rendered during SSR; TanStack's default `**/*.client.*` server
|
|
228
|
-
// denial would mock and crash them. All such files live in `@payloadcms/*`
|
|
229
|
-
// packages, so keep the denial (host `.client.*` files still get it) and
|
|
230
|
-
// just exempt Payload's — `node_modules` covers published installs.
|
|
231
|
-
server: {
|
|
232
|
-
excludeFiles: [
|
|
233
|
-
'**/node_modules/**',
|
|
234
|
-
...clientDenialExcludeFiles
|
|
235
|
-
]
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
router: {
|
|
239
|
-
codeSplittingOptions: {
|
|
240
|
-
// Eager-load only Payload's admin routes so they hydrate on first paint —
|
|
241
|
-
// a split admin renders but isn't interactive until its lazy `?tsr-split=`
|
|
242
|
-
// chunk lands. Returning `[]` disables splitting for a route; `undefined`
|
|
243
|
-
// lets host routes keep TanStack's default per-route splitting.
|
|
244
|
-
splitBehavior: ({ routeId })=>routeId === adminRouteId || routeId.startsWith(`${adminRouteId}/`) ? [] : undefined
|
|
245
|
-
},
|
|
246
|
-
// Ignore generated importMap files and colocated `*.functions.ts` modules
|
|
247
|
-
// (they define `createServerFn`s, not routes).
|
|
248
|
-
routeFileIgnorePattern: 'importMap\\.(?:js|server\\.ts)$|\\.functions\\.',
|
|
249
|
-
routesDirectory
|
|
250
|
-
},
|
|
251
|
-
rsc: {
|
|
252
|
-
enabled: true
|
|
253
|
-
},
|
|
254
|
-
srcDirectory
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
//# sourceMappingURL=index.js.map
|
package/dist/vite/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vite/index.ts"],"sourcesContent":["import type { ConfigEnv, Logger, PluginOption, UserConfig, UserConfigFnObject } from 'vite'\n\n// Optional peers, not deps: `plugin-rsc` is a singleton, so bundling our own copy\n// alongside the host's would load two instances and crash.\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite'\nimport viteReact from '@vitejs/plugin-react'\nimport rsc from '@vitejs/plugin-rsc'\nimport path from 'node:path'\nimport { createLogger, mergeConfig } from 'vite'\n\nimport { 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\n/** Applies dependency-warning suppression to a config in place when enabled. */\nfunction applyDependencyWarningSuppression(config: UserConfig, enabled: boolean): UserConfig {\n if (enabled) {\n config.customLogger = withQuietedDependencyWarnings(config.customLogger)\n }\n return config\n}\n\nexport type WithPayloadOptions = {\n /** Extra import-protection `ignoreImporters` patterns for the TanStack Start plugin. */\n additionalIgnoreImporters?: RegExp[]\n /** Route id of Payload's admin layout, eager-loaded instead of code-split. Defaults to `'/_payload'`. */\n adminRouteId?: string\n /** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */\n clientDenialExcludeFiles?: string[]\n /** Path to the user's `payload.config.ts` (required) */\n payloadConfigPath: string\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'` */\n routesDirectory?: string\n /** Silence Vite warnings about third-party dependency sourcemaps. Defaults to `true`. */\n silenceDependencyWarnings?: boolean\n /** TanStack source directory. Defaults to `'src'` */\n srcDirectory?: string\n /** Extra Vite config deep-merged over the Payload defaults. Ignored in `build` mode. */\n vite?: UserConfig\n}\n\n/** The options Payload's admin requires for each third-party plugin. */\nexport type PayloadPluginOptions = {\n react: NonNullable<Parameters<typeof viteReact>[0]>\n rsc: NonNullable<Parameters<typeof rsc>[0]>\n tanstackStart: NonNullable<Parameters<typeof tanstackStart>[0]>\n}\n\nexport type WithPayloadBuilderContext = {\n env: ConfigEnv\n /** Options to pass to the `viteReact`/`rsc`/`tanstackStart` factories you import. */\n pluginOptions: PayloadPluginOptions\n}\n\n/**\n * Returns the extra Vite config — the plugins you instantiate plus any overrides.\n * `withPayload` deep-merges it onto Payload's base config, so you don't spread or\n * merge the base yourself.\n */\nexport type WithPayloadBuilder = (context: WithPayloadBuilderContext) => UserConfig\n\n/**\n * Vite config helper for Payload + TanStack Start; the counterpart to Next.js'\n * `withPayload`.\n *\n * Zero-config — Payload instantiates the RSC, React, and TanStack Start plugins:\n *\n * ```ts\n * export default withPayload(undefined, { payloadConfigPath: './src/payload.config.ts' })\n * ```\n *\n * Guest mode — pass a `build` callback to instantiate them yourself (one copy of\n * each; `@vitejs/plugin-rsc` is a hard singleton). Return only your additions;\n * `withPayload` deep-merges them onto Payload's base config:\n *\n * ```ts\n * export default withPayload(\n * ({ pluginOptions }) => ({\n * plugins: [\n * rsc(pluginOptions.rsc),\n * tanstackStart(pluginOptions.tanstackStart),\n * viteReact(pluginOptions.react),\n * ],\n * // ...other config options\n * }),\n * { payloadConfigPath: './src/payload.config.ts' },\n * )\n * ```\n */\nexport function withPayload(\n build: undefined | WithPayloadBuilder,\n options: WithPayloadOptions,\n): UserConfigFnObject {\n const {\n additionalIgnoreImporters = [],\n adminRouteId,\n clientDenialExcludeFiles = [],\n payloadConfigPath,\n routesDirectory = 'app',\n silenceDependencyWarnings = true,\n srcDirectory = 'src',\n vite,\n } = options\n\n return (env) => {\n 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 // Payload's internal workaround plugins only. The RSC, TanStack Start, and\n // React plugins are appended below (default form) or by the consumer's\n // `build` callback (guest form).\n plugins: [\n clientModuleResolution(),\n wrapCjsForClient(),\n ssrStripDistStyleImports(),\n reactDomServerInRsc(),\n stubPrettierInClient(),\n payloadDevTransforms(),\n ],\n resolve: {\n alias: [{ find: '@payload-config', replacement: path.resolve(payloadConfigPath) }],\n dedupe: [\n 'react',\n 'react-dom',\n 'scheduler',\n '@payloadcms/ui',\n '@payloadcms/richtext-lexical',\n ],\n extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'],\n tsconfigPaths: true,\n } as any,\n ssr: {\n external: ssrExternalPackages,\n noExternal: payloadNoExternalPatterns,\n },\n }\n\n const pluginOptions: PayloadPluginOptions = {\n react: payloadReactOptions(),\n rsc: payloadRscOptions(),\n tanstackStart: payloadTanstackStartOptions({\n additionalIgnoreImporters,\n adminRouteId,\n clientDenialExcludeFiles,\n routesDirectory,\n srcDirectory,\n }),\n }\n\n if (build) {\n return applyDependencyWarningSuppression(\n mergeConfig(base, build({ env, pluginOptions })),\n silenceDependencyWarnings,\n )\n }\n\n base.plugins = [\n ...(base.plugins as PluginOption[]),\n rsc(pluginOptions.rsc),\n tanstackStart(pluginOptions.tanstackStart),\n viteReact(pluginOptions.react),\n ]\n\n const merged = vite ? mergeConfig(base, vite) : base\n\n return applyDependencyWarningSuppression(merged, silenceDependencyWarnings)\n }\n}\n\n/** `@vitejs/plugin-rsc` options for Payload: `serverHandler: false` (TanStack owns the handler). */\nexport function payloadRscOptions(): NonNullable<Parameters<typeof rsc>[0]> {\n return { serverHandler: false }\n}\n\n/** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */\nexport function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]> {\n return { exclude: [], include: /\\.[jt]sx?$/ }\n}\n\nexport type PayloadTanstackStartOptionsArgs = {\n /** Additional import-protection `ignoreImporters` patterns. */\n additionalIgnoreImporters?: RegExp[]\n /**\n * Route id of Payload's admin layout route, eager-loaded (not code-split) so it\n * hydrates on first paint. It and its children skip splitting; host routes keep\n * TanStack's default. Defaults to `'/_payload'` (the `_payload.tsx` convention).\n */\n adminRouteId?: string\n /**\n * Extra globs exempted from TanStack's `.client.*` SSR denial, on top of the\n * default node_modules exemption. Needed only when Payload's own `.client.*`\n * files resolve outside node_modules (e.g. the monorepo's `packages` sources).\n */\n clientDenialExcludeFiles?: string[]\n /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'`. */\n routesDirectory?: string\n /** TanStack source directory. Defaults to `'src'`. */\n srcDirectory?: string\n}\n\n/**\n * The `tanstackStart` options Payload's admin requires (import-protection and\n * code-splitting). TanStack Start is one-per-app, so a host that already runs it\n * should merge these into its single `tanstackStart` call.\n */\nexport function payloadTanstackStartOptions(\n args: PayloadTanstackStartOptionsArgs = {},\n): NonNullable<Parameters<typeof tanstackStart>[0]> {\n const {\n additionalIgnoreImporters = [],\n adminRouteId = '/_payload',\n clientDenialExcludeFiles = [],\n routesDirectory = 'app',\n srcDirectory = 'src',\n } = args\n\n return {\n importProtection: {\n client: { excludeFiles: [], specifiers: serverOnlyClientSpecifiers },\n ignoreImporters: [...defaultImportProtectionIgnoreImporters, ...additionalIgnoreImporters],\n include: ['**/*'],\n mockAccess: 'warn',\n onViolation: onImportProtectionViolation,\n // Payload's `.client.*` components are React Client Components that must be\n // server-rendered during SSR; TanStack's default `**/*.client.*` server\n // denial would mock and crash them. All such files live in `@payloadcms/*`\n // packages, so keep the denial (host `.client.*` files still get it) and\n // just exempt Payload's — `node_modules` covers published installs.\n server: { excludeFiles: ['**/node_modules/**', ...clientDenialExcludeFiles] },\n },\n router: {\n codeSplittingOptions: {\n // Eager-load only Payload's admin routes so they hydrate on first paint —\n // a split admin renders but isn't interactive until its lazy `?tsr-split=`\n // chunk lands. Returning `[]` disables splitting for a route; `undefined`\n // lets host routes keep TanStack's default per-route splitting.\n splitBehavior: ({ routeId }: { routeId: string }) =>\n routeId === adminRouteId || routeId.startsWith(`${adminRouteId}/`) ? [] : undefined,\n },\n // Ignore generated importMap files and colocated `*.functions.ts` modules\n // (they define `createServerFn`s, not routes).\n routeFileIgnorePattern: 'importMap\\\\.(?:js|server\\\\.ts)$|\\\\.functions\\\\.',\n routesDirectory,\n } as any,\n rsc: { enabled: true },\n srcDirectory,\n }\n}\n"],"names":["tanstackStart","viteReact","rsc","path","createLogger","mergeConfig","payloadNoExternalPatterns","ssrExternalPackages","optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults","payloadScssImporters","defaultImportProtectionIgnoreImporters","onImportProtectionViolation","serverOnlyClientSpecifiers","clientModuleResolution","payloadDevTransforms","reactDomServerInRsc","ssrStripDistStyleImports","stubPrettierInClient","wrapCjsForClient","suppressibleWarningPatterns","withQuietedDependencyWarnings","existing","logger","shouldSuppress","msg","some","pattern","includes","baseWarn","warn","bind","baseWarnOnce","warnOnce","options","applyDependencyWarningSuppression","config","enabled","customLogger","withPayload","build","additionalIgnoreImporters","adminRouteId","clientDenialExcludeFiles","payloadConfigPath","routesDirectory","silenceDependencyWarnings","srcDirectory","vite","env","base","cssMinify","css","preprocessorOptions","scss","importers","silenceDeprecations","define","global","environments","rollupOptions","external","resolve","noExternal","ssr","optimizeDeps","exclude","include","plugins","alias","find","replacement","dedupe","extensions","tsconfigPaths","pluginOptions","react","payloadReactOptions","payloadRscOptions","payloadTanstackStartOptions","merged","serverHandler","args","importProtection","client","excludeFiles","specifiers","ignoreImporters","mockAccess","onViolation","server","router","codeSplittingOptions","splitBehavior","routeId","startsWith","undefined","routeFileIgnorePattern"],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
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,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"}
|
|
@@ -1 +0,0 @@
|
|
|
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,CAgEnD"}
|
|
@@ -1 +0,0 @@
|
|
|
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 // Skip if a host already injected the preamble — a second copy breaks HMR.\n if (str && str.includes('__vite_plugin_react_preamble_installed__')) {\n injected = true\n return chunk\n }\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,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,2EAA2E;oBAC3E,IAAIH,OAAOA,IAAID,QAAQ,CAAC,6CAA6C;wBACnET,WAAW;wBACX,OAAOM;oBACT;oBACA,IAAII,OAAOA,IAAID,QAAQ,CAAC,YAAY;wBAClCT,WAAW;wBACX,OAAOU,IAAIM,OAAO,CAAC,WAAW,GAAGzB,WAAW,OAAO,CAAC;oBACtD;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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactDomServerInRsc.d.ts","sourceRoot":"","sources":["../../../src/vite/workarounds/reactDomServerInRsc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAQxC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,CAyDlD"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { PluginOption } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* Stubs `prettier` in the CLIENT bundle only.
|
|
4
|
-
*
|
|
5
|
-
* `payload`'s barrel transitively pulls `json-schema-to-typescript` → `prettier`
|
|
6
|
-
* (CommonJS) into the client graph. That path is type-gen only and never runs in
|
|
7
|
-
* the browser, but the bundler still drags in `prettier`'s `index.cjs`, which
|
|
8
|
-
* fails to parse as ESM and breaks the client build. SSR/RSC keep real prettier.
|
|
9
|
-
*
|
|
10
|
-
* Delete once `payload`'s barrel no longer reaches type-gen from the client graph.
|
|
11
|
-
*/
|
|
12
|
-
export declare function stubPrettierInClient(): PluginOption;
|
|
13
|
-
//# sourceMappingURL=stubPrettierInClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,IAAI,YAAY,CAqBnD"}
|