@payloadcms/tanstack-start 4.0.0-internal.293e026 → 4.0.0-internal.45cfa3d

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.
Files changed (130) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
  3. package/dist/elements/RouterAdapter/index.js +38 -15
  4. package/dist/elements/RouterAdapter/index.js.map +1 -1
  5. package/dist/exports/client.d.ts +4 -0
  6. package/dist/exports/client.d.ts.map +1 -1
  7. package/dist/exports/client.js +4 -0
  8. package/dist/exports/client.js.map +1 -1
  9. package/dist/exports/layouts.d.ts +1 -0
  10. package/dist/exports/layouts.d.ts.map +1 -1
  11. package/dist/exports/layouts.js +1 -0
  12. package/dist/exports/layouts.js.map +1 -1
  13. package/dist/exports/server.d.ts +2 -1
  14. package/dist/exports/server.d.ts.map +1 -1
  15. package/dist/exports/server.js +2 -1
  16. package/dist/exports/server.js.map +1 -1
  17. package/dist/exports/vite.d.ts +12 -2
  18. package/dist/exports/vite.d.ts.map +1 -1
  19. package/dist/exports/vite.js +8 -1
  20. package/dist/exports/vite.js.map +1 -1
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
  26. package/dist/layouts/Root/getLayoutData.js +36 -0
  27. package/dist/layouts/Root/getLayoutData.js.map +1 -1
  28. package/dist/layouts/Root/index.d.ts +9 -2
  29. package/dist/layouts/Root/index.d.ts.map +1 -1
  30. package/dist/layouts/Root/index.js.map +1 -1
  31. package/dist/layouts/Root/withPayloadRoot.d.ts +65 -0
  32. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -0
  33. package/dist/layouts/Root/withPayloadRoot.js +92 -0
  34. package/dist/layouts/Root/withPayloadRoot.js.map +1 -0
  35. package/dist/routes/adminRoutes.d.ts +111 -0
  36. package/dist/routes/adminRoutes.d.ts.map +1 -0
  37. package/dist/routes/adminRoutes.js +108 -0
  38. package/dist/routes/adminRoutes.js.map +1 -0
  39. package/dist/routes/apiRoute.d.ts +29 -0
  40. package/dist/routes/apiRoute.d.ts.map +1 -0
  41. package/dist/routes/apiRoute.js +38 -0
  42. package/dist/routes/apiRoute.js.map +1 -0
  43. package/dist/routes/layoutRoute.d.ts +26 -0
  44. package/dist/routes/layoutRoute.d.ts.map +1 -0
  45. package/dist/routes/layoutRoute.js +57 -0
  46. package/dist/routes/layoutRoute.js.map +1 -0
  47. package/dist/utilities/handleAPIRoute.d.ts +11 -0
  48. package/dist/utilities/handleAPIRoute.d.ts.map +1 -0
  49. package/dist/utilities/handleAPIRoute.js +17 -0
  50. package/dist/utilities/handleAPIRoute.js.map +1 -0
  51. package/dist/utilities/importMap.server.d.ts +4 -5
  52. package/dist/utilities/importMap.server.d.ts.map +1 -1
  53. package/dist/utilities/importMap.server.js +5 -6
  54. package/dist/utilities/importMap.server.js.map +1 -1
  55. package/dist/utilities/loadAdminPage.d.ts +54 -0
  56. package/dist/utilities/loadAdminPage.d.ts.map +1 -0
  57. package/dist/utilities/loadAdminPage.js +230 -0
  58. package/dist/utilities/loadAdminPage.js.map +1 -0
  59. package/dist/utilities/loadLayoutData.d.ts +15 -0
  60. package/dist/utilities/loadLayoutData.d.ts.map +1 -0
  61. package/dist/utilities/loadLayoutData.js +23 -0
  62. package/dist/utilities/loadLayoutData.js.map +1 -0
  63. package/dist/utilities/serverFunctionClient.d.ts +29 -0
  64. package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
  65. package/dist/utilities/serverFunctionClient.js +109 -0
  66. package/dist/utilities/serverFunctionClient.js.map +1 -0
  67. package/dist/vite/config/external.d.ts +26 -0
  68. package/dist/vite/config/external.d.ts.map +1 -0
  69. package/dist/vite/config/external.js +57 -0
  70. package/dist/vite/config/external.js.map +1 -0
  71. package/dist/vite/config/optimizeDeps.d.ts +25 -0
  72. package/dist/vite/config/optimizeDeps.d.ts.map +1 -0
  73. package/dist/vite/config/optimizeDeps.js +123 -0
  74. package/dist/vite/config/optimizeDeps.js.map +1 -0
  75. package/dist/vite/config/scss.d.ts +14 -0
  76. package/dist/vite/config/scss.d.ts.map +1 -0
  77. package/dist/vite/config/scss.js +28 -0
  78. package/dist/vite/config/scss.js.map +1 -0
  79. package/dist/vite/index.d.ts +55 -0
  80. package/dist/vite/index.d.ts.map +1 -0
  81. package/dist/vite/{plugin.js → index.js} +91 -46
  82. package/dist/vite/index.js.map +1 -0
  83. package/dist/vite/workarounds/clientModuleResolution.d.ts.map +1 -0
  84. package/dist/vite/workarounds/clientModuleResolution.js.map +1 -0
  85. package/dist/vite/workarounds/devTransforms.d.ts.map +1 -0
  86. package/dist/vite/workarounds/devTransforms.js.map +1 -0
  87. package/dist/vite/workarounds/reactDomServerInRsc.d.ts.map +1 -0
  88. package/dist/vite/workarounds/reactDomServerInRsc.js.map +1 -0
  89. package/dist/vite/workarounds/stripDistStyleImports.d.ts.map +1 -0
  90. package/dist/vite/{plugins → workarounds}/stripDistStyleImports.js +37 -4
  91. package/dist/vite/workarounds/stripDistStyleImports.js.map +1 -0
  92. package/dist/vite/workarounds/stubPrettierInClient.d.ts +21 -0
  93. package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +1 -0
  94. package/dist/vite/workarounds/stubPrettierInClient.js +39 -0
  95. package/dist/vite/workarounds/stubPrettierInClient.js.map +1 -0
  96. package/dist/vite/workarounds/wrapCjsForClient.d.ts.map +1 -0
  97. package/dist/vite/workarounds/wrapCjsForClient.js.map +1 -0
  98. package/package.json +10 -12
  99. package/dist/@types/assets.d.js +0 -2
  100. package/dist/@types/assets.d.js.map +0 -1
  101. package/dist/auth/switchLanguage.d.ts +0 -6
  102. package/dist/auth/switchLanguage.d.ts.map +0 -1
  103. package/dist/auth/switchLanguage.js +0 -11
  104. package/dist/auth/switchLanguage.js.map +0 -1
  105. package/dist/vite/constants.d.ts +0 -37
  106. package/dist/vite/constants.d.ts.map +0 -1
  107. package/dist/vite/constants.js +0 -129
  108. package/dist/vite/constants.js.map +0 -1
  109. package/dist/vite/plugin.d.ts +0 -38
  110. package/dist/vite/plugin.d.ts.map +0 -1
  111. package/dist/vite/plugin.js.map +0 -1
  112. package/dist/vite/plugins/clientModuleResolution.d.ts.map +0 -1
  113. package/dist/vite/plugins/clientModuleResolution.js.map +0 -1
  114. package/dist/vite/plugins/devTransforms.d.ts.map +0 -1
  115. package/dist/vite/plugins/devTransforms.js.map +0 -1
  116. package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +0 -1
  117. package/dist/vite/plugins/reactDomServerInRsc.js.map +0 -1
  118. package/dist/vite/plugins/stripDistStyleImports.d.ts.map +0 -1
  119. package/dist/vite/plugins/stripDistStyleImports.js.map +0 -1
  120. package/dist/vite/plugins/wrapCjsForClient.d.ts.map +0 -1
  121. package/dist/vite/plugins/wrapCjsForClient.js.map +0 -1
  122. /package/dist/vite/{plugins → workarounds}/clientModuleResolution.d.ts +0 -0
  123. /package/dist/vite/{plugins → workarounds}/clientModuleResolution.js +0 -0
  124. /package/dist/vite/{plugins → workarounds}/devTransforms.d.ts +0 -0
  125. /package/dist/vite/{plugins → workarounds}/devTransforms.js +0 -0
  126. /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.d.ts +0 -0
  127. /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.js +0 -0
  128. /package/dist/vite/{plugins → workarounds}/stripDistStyleImports.d.ts +0 -0
  129. /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.d.ts +0 -0
  130. /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.js +0 -0
@@ -0,0 +1,25 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,123 @@
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
+ * Packages we know contain Node-only code or top-level side effects requiring
6
+ * Node APIs. Excluding them from the client optimizer prevents Vite from
7
+ * walking into their main entries and trying to bundle server-only imports
8
+ * for the browser.
9
+ */ export const optimizeDepsExcludeDefaults = [
10
+ 'sharp',
11
+ '@payloadcms/ui',
12
+ '@payloadcms/tanstack-start',
13
+ 'payload',
14
+ 'pino',
15
+ 'pino-pretty',
16
+ 'busboy',
17
+ 'get-tsconfig',
18
+ 'ws',
19
+ 'croner',
20
+ 'prompts',
21
+ 'file-type',
22
+ // Server-only SDKs used by `@payloadcms/storage-*` adapters. Vite
23
+ // sometimes walks these from the main package entry while scanning
24
+ // workspace deps, and the browser sub-bundles do not expose the
25
+ // server-only APIs (e.g. `BlobSASPermissions`), which crashes the dev
26
+ // server with a `MISSING_EXPORT` error before any test runs.
27
+ '@azure/storage-blob',
28
+ '@aws-sdk/client-s3',
29
+ '@aws-sdk/s3-request-presigner',
30
+ '@google-cloud/storage'
31
+ ];
32
+ /**
33
+ * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be
34
+ * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick
35
+ * these up because their parent packages are in `optimizeDeps.exclude`, so we
36
+ * list them explicitly using the `parent > child` syntax.
37
+ *
38
+ * Each entry below fixes a specific late-discovery re-optimization: without it,
39
+ * Vite discovers the dep *after* its initial crawl, forcing a full dep
40
+ * re-optimization mid-session that 404s in-flight `.vite/deps/*` chunks and
41
+ * remounts the admin (dropping client state). This is why the list can't simply
42
+ * be deleted — it is the "complete first pass" for the admin's dep graph.
43
+ */ export const optimizeDepsIncludeDefaults = [
44
+ '@payloadcms/ui > sonner',
45
+ '@payloadcms/ui > @faceless-ui/modal',
46
+ '@payloadcms/ui > @faceless-ui/window-info',
47
+ '@payloadcms/ui > @faceless-ui/scroll-info',
48
+ '@payloadcms/ui > @dnd-kit/core',
49
+ '@payloadcms/ui > @dnd-kit/sortable',
50
+ '@payloadcms/ui > @dnd-kit/utilities',
51
+ '@payloadcms/ui > react-datepicker',
52
+ '@payloadcms/ui > react-select',
53
+ '@payloadcms/ui > react-select/creatable',
54
+ '@payloadcms/ui > react-image-crop',
55
+ '@payloadcms/ui > @monaco-editor/react',
56
+ '@payloadcms/ui > date-fns',
57
+ '@payloadcms/ui > date-fns/transpose',
58
+ '@payloadcms/ui > @date-fns/tz/date/mini',
59
+ '@payloadcms/ui > uuid',
60
+ '@payloadcms/ui > use-context-selector',
61
+ '@payloadcms/ui > bson-objectid',
62
+ '@payloadcms/ui > dequal',
63
+ '@payloadcms/ui > object-to-formdata',
64
+ '@payloadcms/ui > md5',
65
+ 'payload > deepmerge',
66
+ 'payload > pluralize',
67
+ // `scheduler` is a transitive dep of `react-dom`, not a direct dependency of
68
+ // the app, so a bare `'scheduler'` specifier fails to resolve from an isolated
69
+ // install (`test/node_modules` built with `pnpm i --ignore-workspace`), where
70
+ // it isn't hoisted to the top level. Path it through `react-dom` so the
71
+ // optimizer resolves the exact copy the runtime loads.
72
+ 'react-dom > scheduler',
73
+ // `@payloadcms/ui` (in `optimizeDeps.exclude`) ships compiled output that the
74
+ // React Compiler rewrote to `import { c } from 'react/compiler-runtime'`.
75
+ // Because its parent is excluded, the optimizer never crawls in to discover
76
+ // this entry, so Vite serves `react/compiler-runtime` raw. That file is
77
+ // CommonJS (`module.exports = require(...)`), so the named `c` export can't be
78
+ // statically extracted and every client component throws "does not provide an
79
+ // export named 'c'". Pre-bundling it lets esbuild synthesize the named export.
80
+ 'react/compiler-runtime',
81
+ // Transitive deps that Vite otherwise discovers *after* the initial crawl
82
+ // (react-select pulls in @floating-ui at runtime; react-is is reached via
83
+ // react-transition-group/prop-types; the default date-fns locale is loaded
84
+ // through a dynamic `date-fns/locale/${key}` import). A late discovery forces
85
+ // a full dep re-optimization mid-session, which 404s every in-flight
86
+ // `.vite/deps/*` chunk ("Pre-transform error: file does not exist in the
87
+ // optimize deps directory") and breaks the admin UI in CI cold starts.
88
+ // Pre-bundling them keeps the first optimization pass complete.
89
+ '@payloadcms/ui > react-select > @floating-ui/dom',
90
+ '@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',
91
+ '@payloadcms/ui > react-select > prop-types > react-is',
92
+ '@payloadcms/ui > date-fns/locale/en-US',
93
+ // Further late discoveries observed re-optimizing mid-run in CI cold starts
94
+ // (see CI logs: "✨ new dependencies optimized: @dnd-kit/modifiers / ajv /
95
+ // dequal/lite"). The modular dashboard pulls in `@dnd-kit/modifiers` on first
96
+ // render; form-state diffing reaches `dequal/lite` (a distinct entry point
97
+ // from the already-listed `dequal`); client-side field validation reaches
98
+ // `ajv` *through `payload`* — it is `ssrExternal` server-side but still
99
+ // bundled into the client, and must be pathed via `payload` so the optimizer
100
+ // pre-bundles the exact copy the runtime loads.
101
+ '@payloadcms/ui > @dnd-kit/modifiers',
102
+ '@payloadcms/ui > dequal/lite',
103
+ 'payload > ajv',
104
+ // The storage client-upload suites (esp. vercel-blob) crawl part of the
105
+ // `payload` server runtime into the client bundle and discover these late,
106
+ // triggering several "optimized dependencies changed. reloading" waves that
107
+ // reload the page mid-test (the bulk-upload drawer's Create New button /
108
+ // dropzone vanish and the direct-to-bucket PUT never fires). Pre-bundle the
109
+ // whole observed set so the first pass is complete.
110
+ 'payload > undici',
111
+ 'payload > jose',
112
+ 'payload > dataloader',
113
+ 'payload > path-to-regexp',
114
+ 'payload > console-table-printer',
115
+ 'payload > ci-info',
116
+ 'payload > image-size',
117
+ 'payload > image-size/fromFile',
118
+ 'payload > ipaddr.js',
119
+ 'payload > range-parser',
120
+ 'payload > sanitize-filename'
121
+ ];
122
+
123
+ //# sourceMappingURL=optimizeDeps.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,14 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,28 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,55 @@
1
+ import type { UserConfig, UserConfigFnObject } from 'vite';
2
+ export type WithPayloadOptions = {
3
+ /**
4
+ * Additional import-protection `ignoreImporters` patterns. This is a
5
+ * Payload-specific knob on the TanStack Start plugin, so it cannot be
6
+ * expressed through `vite` — pass it here.
7
+ */
8
+ additionalIgnoreImporters?: RegExp[];
9
+ /** Path to the user's `payload.config.ts` (required) */
10
+ payloadConfigPath: string;
11
+ /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'` */
12
+ routesDirectory?: string;
13
+ /**
14
+ * Silence Vite warnings about third-party dependency sourcemaps pointing to
15
+ * missing source files — noise Payload consumers can't act on. Defaults to
16
+ * `true`; set `false` to see them. Composes with a `vite.customLogger`.
17
+ */
18
+ silenceDependencyWarnings?: boolean;
19
+ /** TanStack source directory. Defaults to `'src'` */
20
+ srcDirectory?: string;
21
+ /**
22
+ * Extra Vite config merged on top of the Payload defaults via Vite's own
23
+ * `mergeConfig`. Objects are deep-merged and arrays are appended, so this is
24
+ * the single hook for everything a consumer used to reach through separate
25
+ * options: extra `plugins`, `resolve.alias` entries, `optimizeDeps.include`,
26
+ * `ssr.external`, `server`, `build`, and so on.
27
+ *
28
+ * @example
29
+ * withPayload({
30
+ * payloadConfigPath: './src/payload.config.ts',
31
+ * vite: { server: { port: 4000 } },
32
+ * })
33
+ */
34
+ vite?: UserConfig;
35
+ };
36
+ /**
37
+ * Vite config helper for Payload + TanStack Start. The Vite-side counterpart to
38
+ * `withPayload` for Next.js: it owns the whole Vite setup needed to run the
39
+ * Payload admin — the RSC, React, and TanStack Start plugins plus a small set of
40
+ * Payload-specific workarounds — so a consumer's `vite.config.ts` collapses to:
41
+ *
42
+ * ```ts
43
+ * import { withPayload } from '@payloadcms/tanstack-start/vite'
44
+ *
45
+ * export default withPayload({ payloadConfigPath: './src/payload.config.ts' })
46
+ * ```
47
+ *
48
+ * The React (`@vitejs/plugin-react`), RSC (`@vitejs/plugin-rsc`), and TanStack
49
+ * Start plugins are instantiated internally with the settings the admin
50
+ * requires — consumers no longer pass them in. Each remaining Payload
51
+ * workaround lives in its own file under `./workarounds/` so it can be deleted
52
+ * individually once the corresponding upstream fix lands.
53
+ */
54
+ export declare function withPayload(options: WithPayloadOptions): UserConfigFnObject;
55
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,UAAU,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAsDlE,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;IACpC,wDAAwD;IACxD,iBAAiB,EAAE,MAAM,CAAA;IACzB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;IACnC,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;;;;;;;OAYG;IACH,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,CAwI3E"}
@@ -1,25 +1,71 @@
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 { optimizeDepsExcludeDefaults, optimizeDepsIncludeDefaults, payloadNoExternalPatterns, payloadRscNoExternalPatterns, ssrExternalPackages } from './constants.js';
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 './plugins/clientModuleResolution.js';
5
- import { payloadDevTransforms } from './plugins/devTransforms.js';
6
- import { reactDomServerInRsc } from './plugins/reactDomServerInRsc.js';
7
- import { ssrStripDistStyleImports } from './plugins/stripDistStyleImports.js';
8
- import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
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 plugin for Payload + TanStack Start. The Vite-side counterpart to
11
- * `withPayload` for Next.js: it configures the Vite environment so the Payload
12
- * admin can run, then composes the TanStack Start plugin with two small
13
- * Payload-specific workarounds (dev HMR injection, SSR style stripping). Each
14
- * remaining workaround lives in its own file under `./plugins/` so it can be
15
- * deleted individually once the corresponding upstream fix lands.
16
- */ export function payloadPlugin(options) {
17
- const { additionalAliases = [], additionalIgnoreImporters = [], additionalOptimizeDepsInclude = [], additionalSsrExternal = [], payloadConfigPath, plugins: extraPlugins = [], reactPlugin, routesDirectory = 'app', rscPlugin, srcDirectory = 'src', tanstackStart } = options;
18
- process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED = 'true';
19
- return (_env)=>({
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 = {
20
65
  css: {
21
66
  preprocessorOptions: {
22
67
  scss: {
68
+ importers: payloadScssImporters,
23
69
  silenceDeprecations: [
24
70
  'import',
25
71
  'global-builtin'
@@ -28,13 +74,12 @@ import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
28
74
  }
29
75
  },
30
76
  define: {
31
- global: 'globalThis',
32
- 'process.env.PAYLOAD_FRAMEWORK_RSC_ENABLED': JSON.stringify('true')
77
+ global: 'globalThis'
33
78
  },
34
79
  environments: {
35
80
  rsc: {
36
81
  resolve: {
37
- noExternal: payloadRscNoExternalPatterns
82
+ noExternal: payloadNoExternalPatterns
38
83
  }
39
84
  },
40
85
  ssr: {
@@ -45,18 +90,18 @@ import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
45
90
  },
46
91
  optimizeDeps: {
47
92
  exclude: optimizeDepsExcludeDefaults,
48
- include: [
49
- ...optimizeDepsIncludeDefaults,
50
- ...additionalOptimizeDepsInclude
51
- ]
93
+ include: optimizeDepsIncludeDefaults
52
94
  },
53
95
  plugins: [
54
96
  clientModuleResolution(),
55
97
  wrapCjsForClient(),
56
98
  ssrStripDistStyleImports(),
57
99
  reactDomServerInRsc(),
100
+ stubPrettierInClient(),
58
101
  payloadDevTransforms(),
59
- rscPlugin,
102
+ rsc({
103
+ serverHandler: false
104
+ }),
60
105
  tanstackStart({
61
106
  importProtection: {
62
107
  client: {
@@ -122,11 +167,14 @@ import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
122
167
  codeSplittingOptions: {
123
168
  defaultBehavior: []
124
169
  },
125
- // Exclude only generated importMap files. Admin form saves are
126
- // dispatched via `runPayloadServerFn` (a TanStack Start
127
- // `createServerFn`) rather than a hand-rolled route, so there is
128
- // no longer an `api.server-function.ts` to special-case here.
129
- routeFileIgnorePattern: 'importMap\\.(?:js|server\\.ts)$',
170
+ // Exclude generated importMap files and colocated server-function
171
+ // modules (`*.functions.ts`). Admin form saves are dispatched via
172
+ // `runPayloadServerFn` (a TanStack Start `createServerFn`) rather than
173
+ // a hand-rolled route, so there is no longer an `api.server-function.ts`
174
+ // to special-case here. The `*.functions.ts` shims live next to the
175
+ // routes that use them (e.g. `app/_payload/*.functions.ts`); they
176
+ // define `createServerFn`s, not routes, so they must not be scanned.
177
+ routeFileIgnorePattern: 'importMap\\.(?:js|server\\.ts)$|\\.functions\\.',
130
178
  routesDirectory
131
179
  },
132
180
  rsc: {
@@ -134,16 +182,17 @@ import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
134
182
  },
135
183
  srcDirectory
136
184
  }),
137
- reactPlugin,
138
- ...extraPlugins
185
+ viteReact({
186
+ exclude: [],
187
+ include: /\.[jt]sx?$/
188
+ })
139
189
  ],
140
190
  resolve: {
141
191
  alias: [
142
192
  {
143
193
  find: '@payload-config',
144
194
  replacement: path.resolve(payloadConfigPath)
145
- },
146
- ...additionalAliases
195
+ }
147
196
  ],
148
197
  dedupe: [
149
198
  'react',
@@ -163,21 +212,17 @@ import { wrapCjsForClient } from './plugins/wrapCjsForClient.js';
163
212
  ],
164
213
  tsconfigPaths: true
165
214
  },
166
- server: {
167
- warmup: {
168
- clientFiles: [
169
- './src/importMap.js'
170
- ]
171
- }
172
- },
173
215
  ssr: {
174
- external: [
175
- ...ssrExternalPackages,
176
- ...additionalSsrExternal
177
- ],
216
+ external: ssrExternalPackages,
178
217
  noExternal: payloadNoExternalPatterns
179
218
  }
180
- });
219
+ };
220
+ const merged = vite ? mergeConfig(base, vite) : base;
221
+ if (silenceDependencyWarnings) {
222
+ merged.customLogger = withQuietedDependencyWarnings(merged.customLogger);
223
+ }
224
+ return merged;
225
+ };
181
226
  }
182
227
 
183
- //# sourceMappingURL=plugin.js.map
228
+ //# 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 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: { resolve: { noExternal: payloadNoExternalPatterns } },\n ssr: { resolve: { noExternal: payloadNoExternalPatterns } },\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","css","preprocessorOptions","scss","importers","silenceDeprecations","define","global","environments","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","external","merged","customLogger"],"mappings":"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"}
@@ -0,0 +1 @@
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"}
@@ -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,kCAAkC;YAChC;YACA;YACA;SACD;IACH;IAEA,OAAO;QACLC,MAAM;QACNC,SAAS;QACTC,MAAKC,EAAE;YACL,IAAI,CAACA,GAAGC,UAAU,CAACP,aAAa;gBAC9B;YACF;YACA,MAAMQ,YAAYF,GAAGG,KAAK,CAACT,WAAWU,MAAM;YAC5C,MAAMC,UAAUT,iBAAiB,CAACM,UAAU;YAC5C,IAAIG,SAAS;gBACX,OAAOA,QAAQC,GAAG,CAAC,CAACT,OAAS,CAAC,aAAa,EAAEA,KAAK,cAAc,CAAC,EAAEU,IAAI,CAAC;YAC1E;YACA,OAAO,CAAC,oBAAoB,CAAC;QAC/B;QACA,MAAMC,WAAUR,EAAE,EAAES,QAAQ,EAAEC,OAAO;YACnC,IAAIA,SAASC,KAAK;gBAChB;YACF;YAEA,IAAIhB,mBAAmBiB,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,CAACd,MAAM;gBAC9C,OAAON,aAAaM;YACtB;YAEA,IAAIA,OAAO,aAAaS,YAAY,CAACA,SAASM,QAAQ,CAAC,mBAAmB;gBACxE,MAAMC,mBAAmB,6DAA6DF,IAAI,CACxFL;gBAEF,IAAI,CAACO,kBAAkB;oBACrB,OAAO,IAAI,CAACC,OAAO,CAAC,kBAAkBR,UAAU;wBAAE,GAAGC,OAAO;wBAAEQ,UAAU;oBAAK;gBAC/E;YACF;YAEA,IAAI,kDAAkDJ,IAAI,CAACd,KAAK;gBAC9D,MAAMmB,WAAW,MAAM,IAAI,CAACF,OAAO,CAACjB,IAAIS,UAAU;oBAAE,GAAGC,OAAO;oBAAEQ,UAAU;gBAAK;gBAC/E,IAAIC,UAAU;oBACZ,OAAOA;gBACT;gBACA,MAAMC,UAAUpB,GAAGqB,OAAO,CAAC,aAAa;gBACxC,MAAMC,cAAc,MAAM,IAAI,CAACL,OAAO,CAACG,SAASX,UAAU;oBAAE,GAAGC,OAAO;oBAAEQ,UAAU;gBAAK;gBACvF,IAAII,aAAa;oBACf,MAAMC,SAAS/B,KAAKgC,OAAO,CAACF,YAAYtB,EAAE;oBAC1C,MAAMyB,aAAa;wBACjBjC,KAAKyB,OAAO,CAACM,QAAQ,OAAO,WAAW;wBACvC/B,KAAKyB,OAAO,CAACM,QAAQ,OAAO,WAAW;wBACvC/B,KAAKyB,OAAO,CAACM,QAAQ,QAAQ,WAAW;qBACzC;oBACD,KAAK,MAAMG,aAAaD,WAAY;wBAClC,IAAIlC,GAAGoC,UAAU,CAACD,YAAY;4BAC5B,OAAOA;wBACT;oBACF;gBACF;YACF;QACF;IACF;AACF"}
@@ -0,0 +1 @@
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,WAAW;gBACf,MAAMC,YAAYH,IAAII,KAAK;gBAC3B,MAAMC,UAAUL,IAAIM,GAAG;gBAEvB,SAASC,UAAUC,KAAU;oBAC3B,IAAIN,YAAYM,SAAS,MAAM;wBAC7B,OAAOA;oBACT;oBACA,MAAMC,KAAKT,IAAIU,SAAS,CAAC;oBACzB,IAAI,OAAOD,OAAO,YAAY,CAACA,GAAGE,QAAQ,CAAC,cAAc;wBACvD,OAAOH;oBACT;oBACA,MAAMI,MACJ,OAAOJ,UAAU,WACbA,QACAK,OAAOC,QAAQ,CAACN,SACdA,MAAMO,QAAQ,KACdP,iBAAiBQ,aACfH,OAAOI,IAAI,CAACT,OAAOO,QAAQ,KAC3B;oBACV,IAAIH,OAAOA,IAAID,QAAQ,CAAC,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"}
@@ -0,0 +1 @@
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"}
@@ -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"}