vite-plugin-react-server 0.3.18 → 1.0.0

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 (246) hide show
  1. package/README.md +220 -141
  2. package/bin/patch.mjs +8 -2
  3. package/dist/package.json +15 -8
  4. package/dist/plugin/checkFilesExist.d.ts.map +1 -1
  5. package/dist/plugin/checkFilesExist.js +6 -2
  6. package/dist/plugin/checkFilesExist.js.map +1 -1
  7. package/dist/plugin/collect-manifest-client-files.d.ts +23 -0
  8. package/dist/plugin/collect-manifest-client-files.d.ts.map +1 -0
  9. package/dist/plugin/collect-manifest-client-files.js +131 -0
  10. package/dist/plugin/collect-manifest-client-files.js.map +1 -0
  11. package/dist/plugin/components.d.ts +3 -13
  12. package/dist/plugin/components.d.ts.map +1 -1
  13. package/dist/plugin/components.js +3 -13
  14. package/dist/plugin/config/defaults.d.ts +14 -6
  15. package/dist/plugin/config/defaults.d.ts.map +1 -1
  16. package/dist/plugin/config/defaults.js +9 -5
  17. package/dist/plugin/config/defaults.js.map +1 -1
  18. package/dist/plugin/config/getPaths.d.ts +0 -1
  19. package/dist/plugin/config/getPaths.d.ts.map +1 -1
  20. package/dist/plugin/config/getPaths.js +2 -7
  21. package/dist/plugin/config/getPaths.js.map +1 -1
  22. package/dist/plugin/config/mimeTypes.d.ts +2 -0
  23. package/dist/plugin/config/mimeTypes.d.ts.map +1 -0
  24. package/dist/plugin/config/mimeTypes.js +24 -0
  25. package/dist/plugin/config/mimeTypes.js.map +1 -0
  26. package/dist/plugin/config/resolveOptions.d.ts +2 -2
  27. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  28. package/dist/plugin/config/resolveOptions.js +47 -28
  29. package/dist/plugin/config/resolveOptions.js.map +1 -1
  30. package/dist/plugin/config/resolvePages.d.ts +1 -0
  31. package/dist/plugin/config/resolvePages.d.ts.map +1 -1
  32. package/dist/plugin/config/resolvePages.js +9 -5
  33. package/dist/plugin/config/resolvePages.js.map +1 -1
  34. package/dist/plugin/config/resolveUserConfig.d.ts +2 -1
  35. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  36. package/dist/plugin/config/resolveUserConfig.js +181 -147
  37. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  38. package/dist/plugin/copy-dir.js +23 -18
  39. package/dist/plugin/copy-dir.js.map +1 -0
  40. package/dist/plugin/css-collector-inline.d.ts +10 -0
  41. package/dist/plugin/css-collector-inline.d.ts.map +1 -0
  42. package/dist/plugin/css-collector-inline.js +55 -0
  43. package/dist/plugin/css-collector-inline.js.map +1 -0
  44. package/dist/plugin/css-collector.d.ts +14 -0
  45. package/dist/plugin/css-collector.d.ts.map +1 -0
  46. package/dist/plugin/css-collector.js +49 -0
  47. package/dist/plugin/css-collector.js.map +1 -0
  48. package/dist/plugin/helpers/createHandler.d.ts +17 -0
  49. package/dist/plugin/helpers/createHandler.d.ts.map +1 -0
  50. package/dist/plugin/helpers/createHandler.js +111 -0
  51. package/dist/plugin/helpers/createHandler.js.map +1 -0
  52. package/dist/plugin/helpers/createRscStream.d.ts +27 -0
  53. package/dist/plugin/helpers/createRscStream.d.ts.map +1 -0
  54. package/dist/plugin/helpers/createRscStream.js +80 -0
  55. package/dist/plugin/helpers/createRscStream.js.map +1 -0
  56. package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
  57. package/dist/plugin/helpers/getBundleManifest.js +12 -4
  58. package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
  59. package/dist/plugin/html.d.ts +5 -0
  60. package/dist/plugin/html.d.ts.map +1 -0
  61. package/dist/plugin/html.js +11 -0
  62. package/dist/plugin/html.js.map +1 -0
  63. package/dist/plugin/loader/createBuildLoader.d.ts +1 -1
  64. package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
  65. package/dist/plugin/loader/createBuildLoader.js +8 -5
  66. package/dist/plugin/loader/createBuildLoader.js.map +1 -1
  67. package/dist/plugin/loader/css-loader.d.ts.map +1 -1
  68. package/dist/plugin/loader/css-loader.js.map +1 -1
  69. package/dist/plugin/loader/react-loader.js +2 -2
  70. package/dist/plugin/loader/react-loader.js.map +1 -1
  71. package/dist/plugin/preserver/plugin.d.ts.map +1 -1
  72. package/dist/plugin/preserver/plugin.js +49 -14
  73. package/dist/plugin/preserver/plugin.js.map +1 -1
  74. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  75. package/dist/plugin/react-client/plugin.js +21 -78
  76. package/dist/plugin/react-client/plugin.js.map +1 -1
  77. package/dist/plugin/react-server/index.d.ts.map +1 -1
  78. package/dist/plugin/react-server/index.js +2 -0
  79. package/dist/plugin/react-server/index.js.map +1 -1
  80. package/dist/plugin/react-server/plugin.d.ts +2 -1
  81. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  82. package/dist/plugin/react-server/plugin.js +92 -225
  83. package/dist/plugin/react-server/plugin.js.map +1 -1
  84. package/dist/plugin/react-static/index.d.ts +2 -0
  85. package/dist/plugin/react-static/index.d.ts.map +1 -0
  86. package/dist/plugin/react-static/index.js +1 -0
  87. package/dist/plugin/react-static/plugin.d.ts +7 -0
  88. package/dist/plugin/react-static/plugin.d.ts.map +1 -0
  89. package/dist/plugin/react-static/plugin.js +207 -0
  90. package/dist/plugin/react-static/plugin.js.map +1 -0
  91. package/dist/plugin/react-static/types.d.ts +2 -0
  92. package/dist/plugin/react-static/types.d.ts.map +1 -0
  93. package/dist/plugin/resolvePage.d.ts.map +1 -1
  94. package/dist/plugin/resolvePage.js +9 -0
  95. package/dist/plugin/resolvePage.js.map +1 -1
  96. package/dist/plugin/root.d.ts +2 -0
  97. package/dist/plugin/root.d.ts.map +1 -0
  98. package/dist/plugin/root.js +12 -0
  99. package/dist/plugin/root.js.map +1 -0
  100. package/dist/plugin/transformer/plugin.d.ts.map +1 -1
  101. package/dist/plugin/transformer/plugin.js +32 -23
  102. package/dist/plugin/transformer/plugin.js.map +1 -1
  103. package/dist/plugin/transformer/types.d.ts +1 -18
  104. package/dist/plugin/transformer/types.d.ts.map +1 -1
  105. package/dist/plugin/types.d.ts +70 -15
  106. package/dist/plugin/types.d.ts.map +1 -1
  107. package/dist/plugin/worker/createWorker.js +0 -1
  108. package/dist/plugin/worker/createWorker.js.map +1 -1
  109. package/dist/plugin/worker/html/html-worker.development.d.ts +30 -0
  110. package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -1
  111. package/dist/plugin/worker/html/html-worker.development.js +30 -2
  112. package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
  113. package/dist/plugin/worker/html/html-worker.production.js +3 -5
  114. package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
  115. package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
  116. package/dist/plugin/worker/html/messageHandler.js +12 -3
  117. package/dist/plugin/worker/html/messageHandler.js.map +1 -1
  118. package/dist/plugin/worker/html/renderPages.d.ts +13 -26
  119. package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
  120. package/dist/plugin/worker/html/renderPages.js +138 -86
  121. package/dist/plugin/worker/html/renderPages.js.map +1 -1
  122. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
  123. package/dist/plugin/worker/rsc/messageHandler.js +104 -84
  124. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
  125. package/dist/plugin/worker/rsc/rsc-worker.development.js +13 -18
  126. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
  127. package/dist/plugin/worker/rsc/rsc-worker.production.js +4 -1
  128. package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
  129. package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
  130. package/dist/plugin/worker/rsc/state.js.map +1 -1
  131. package/dist/plugin/worker/types.d.ts +3 -0
  132. package/dist/plugin/worker/types.d.ts.map +1 -1
  133. package/dist/tsconfig.tsbuildinfo +1 -1
  134. package/package.json +14 -6
  135. package/plugin/checkFilesExist.ts +7 -3
  136. package/plugin/collect-manifest-client-files.ts +167 -0
  137. package/plugin/components.ts +3 -0
  138. package/plugin/config/defaults.tsx +70 -0
  139. package/plugin/config/getPaths.ts +1 -7
  140. package/plugin/config/mimeTypes.ts +17 -0
  141. package/plugin/config/resolveOptions.ts +58 -45
  142. package/plugin/config/resolvePages.ts +8 -4
  143. package/plugin/config/resolveUserConfig.ts +220 -176
  144. package/plugin/css-collector-inline.tsx +60 -0
  145. package/plugin/css-collector.tsx +62 -0
  146. package/plugin/helpers/createHandler.ts +135 -0
  147. package/plugin/helpers/createRscStream.ts +109 -0
  148. package/plugin/helpers/getBundleManifest.ts +14 -5
  149. package/plugin/html.tsx +9 -0
  150. package/plugin/loader/createBuildLoader.ts +9 -6
  151. package/plugin/loader/css-loader.ts +0 -2
  152. package/plugin/loader/react-loader.ts +2 -2
  153. package/plugin/preserver/plugin.ts +64 -17
  154. package/plugin/react-client/plugin.ts +23 -93
  155. package/plugin/react-server/index.ts +2 -0
  156. package/plugin/react-server/plugin.ts +111 -302
  157. package/plugin/react-static/index.ts +1 -0
  158. package/plugin/react-static/plugin.ts +256 -0
  159. package/plugin/react-static/types.ts +3 -0
  160. package/plugin/resolvePage.ts +9 -0
  161. package/plugin/root.ts +4 -0
  162. package/plugin/transformer/plugin.ts +40 -31
  163. package/plugin/transformer/types.ts +0 -19
  164. package/plugin/types.ts +77 -16
  165. package/plugin/worker/createWorker.ts +1 -1
  166. package/plugin/worker/html/README.md +63 -0
  167. package/plugin/worker/html/html-worker.development.tsx +89 -2
  168. package/plugin/worker/html/html-worker.production.tsx +8 -10
  169. package/plugin/worker/html/messageHandler.ts +12 -3
  170. package/plugin/worker/html/renderPages.ts +178 -138
  171. package/plugin/worker/rsc/README.md +58 -0
  172. package/plugin/worker/rsc/messageHandler.tsx +112 -113
  173. package/plugin/worker/rsc/rsc-worker.development.ts +12 -22
  174. package/plugin/worker/rsc/rsc-worker.production.ts +5 -1
  175. package/plugin/worker/rsc/state.ts +0 -3
  176. package/plugin/worker/types.ts +3 -0
  177. package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +114 -12
  178. package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +10571 -121
  179. package/tsconfig.json +2 -2
  180. package/dist/plugin/collect-css-manifest.d.ts +0 -4
  181. package/dist/plugin/collect-css-manifest.d.ts.map +0 -1
  182. package/dist/plugin/collect-css-manifest.js +0 -65
  183. package/dist/plugin/collect-css-manifest.js.map +0 -1
  184. package/dist/plugin/config/createModuleIdGenerator.d.ts +0 -11
  185. package/dist/plugin/config/createModuleIdGenerator.d.ts.map +0 -1
  186. package/dist/plugin/config/createModuleIdGenerator.js +0 -44
  187. package/dist/plugin/config/createModuleIdGenerator.js.map +0 -1
  188. package/dist/plugin/getEnv.d.ts +0 -19
  189. package/dist/plugin/getEnv.d.ts.map +0 -1
  190. package/dist/plugin/getEnv.js +0 -107
  191. package/dist/plugin/loader/createCssLoader.d.ts +0 -30
  192. package/dist/plugin/loader/createCssLoader.d.ts.map +0 -1
  193. package/dist/plugin/loader/createCssLoader.js +0 -35
  194. package/dist/plugin/loader/createPageLoader.d.ts +0 -24
  195. package/dist/plugin/loader/createPageLoader.d.ts.map +0 -1
  196. package/dist/plugin/loader/createPageLoader.js +0 -50
  197. package/dist/plugin/loader/rsc/messageHandler.d.ts +0 -2
  198. package/dist/plugin/loader/rsc/messageHandler.d.ts.map +0 -1
  199. package/dist/plugin/loader/rsc/rsc-worker.development.d.ts +0 -2
  200. package/dist/plugin/loader/rsc/rsc-worker.development.d.ts.map +0 -1
  201. package/dist/plugin/loader/rsc/rsc-worker.development.js +0 -1
  202. package/dist/plugin/module-graph.d.ts +0 -10
  203. package/dist/plugin/module-graph.d.ts.map +0 -1
  204. package/dist/plugin/module-graph.js +0 -35
  205. package/dist/plugin/react-server/createHandler.d.ts +0 -17
  206. package/dist/plugin/react-server/createHandler.d.ts.map +0 -1
  207. package/dist/plugin/react-server/createHandler.js +0 -126
  208. package/dist/plugin/react-server/createHandler.js.map +0 -1
  209. package/dist/plugin/react-server/createRscStream.d.ts +0 -16
  210. package/dist/plugin/react-server/createRscStream.d.ts.map +0 -1
  211. package/dist/plugin/react-server/createRscStream.js +0 -70
  212. package/dist/plugin/react-server/createRscStream.js.map +0 -1
  213. package/dist/plugin/react-server/createSsrHandler.d.ts +0 -4
  214. package/dist/plugin/react-server/createSsrHandler.d.ts.map +0 -1
  215. package/dist/plugin/react-server/createSsrHandler.js +0 -95
  216. package/dist/plugin/utils/logger.d.ts +0 -9
  217. package/dist/plugin/utils/logger.d.ts.map +0 -1
  218. package/dist/plugin/utils/logger.js +0 -68
  219. package/dist/plugin/utils/logger.js.map +0 -1
  220. package/dist/plugin/worker/html/plugin.d.ts +0 -4
  221. package/dist/plugin/worker/html/plugin.d.ts.map +0 -1
  222. package/dist/plugin/worker/html/plugin.js +0 -94
  223. package/dist/plugin/worker/plugin.d.ts +0 -19
  224. package/dist/plugin/worker/plugin.d.ts.map +0 -1
  225. package/dist/plugin/worker/plugin.js +0 -23
  226. package/dist/plugin/worker/rsc/plugin.d.ts +0 -4
  227. package/dist/plugin/worker/rsc/plugin.d.ts.map +0 -1
  228. package/dist/plugin/worker/rsc/plugin.js +0 -76
  229. package/plugin/collect-css-manifest.ts +0 -82
  230. package/plugin/components.tsx +0 -14
  231. package/plugin/config/createModuleIdGenerator.ts +0 -52
  232. package/plugin/config/defaults.ts +0 -51
  233. package/plugin/getEnv.ts +0 -135
  234. package/plugin/loader/createCssLoader.ts +0 -73
  235. package/plugin/loader/createPageLoader.ts +0 -103
  236. package/plugin/loader/rsc/messageHandler.tsx +0 -1
  237. package/plugin/loader/rsc/rsc-worker.development.ts +0 -1
  238. package/plugin/module-graph.ts +0 -48
  239. package/plugin/react-server/createHandler.ts +0 -162
  240. package/plugin/react-server/createRscStream.ts +0 -86
  241. package/plugin/react-server/createSsrHandler.ts +0 -125
  242. package/plugin/utils/logger.ts +0 -52
  243. package/plugin/worker/html/plugin.ts +0 -101
  244. package/plugin/worker/plugin.ts +0 -26
  245. package/plugin/worker/rsc/plugin.ts +0 -84
  246. /package/dist/plugin/{loader/rsc/messageHandler.js → react-static/types.js} +0 -0
package/README.md CHANGED
@@ -1,213 +1,292 @@
1
- # Vite React Server Components Plugin
1
+ # Vite React Server Plugin
2
2
 
3
- A Vite plugin that enables React Server Components (RSC) streaming and static building of html pages. Uses experimental dependencies from React, specifically `react-server-dom-esm`.
3
+ A Vite plugin that enables React Server Components (RSC) streaming and static HTML page generation. It leverages experimental dependencies from React, specifically `react-server-dom-esm`.
4
4
 
5
- ## Features
5
+ ## Example Projects
6
6
 
7
- - 🚀 Super fast static build times
8
- - 🔄 Use vite to create your personal meta-framework
9
- - ⚡ Full RSC streaming support
10
- - 📦 Dual-worker architecture for optimal performance
11
- - 🔧 Automatic client/server code splitting
12
- - 🎯 Directive-based component targeting
13
-
14
- ## Example Project
15
-
16
- The [mmcelebration.com project](https://github.com/nicobrinkkemper/mmc) uses this plugin. Build time for ~200 html pages is just a few seconds.
7
+ - [The official demo](https://github.com/nicobrinkkemper/vite-plugin-react-server-demo-official)
8
+ - [The mmcelebration.com project](https://github.com/nicobrinkkemper/mmc)
17
9
 
18
10
  ## Installation
19
11
 
20
- ```bash
21
- npm install vite-plugin-react-server
12
+ ```sh
13
+ npm install -D vite-plugin-react-stream
22
14
  ```
23
15
 
24
- ### React Canary Setup
16
+ ## Open Source and Work in Progress
25
17
 
26
- This plugin requires React's experimental features. You'll need to:
18
+ This project uses the latest *OSS-experimental* React version from [the official React GitHub repository](https://github.com/facebook/react). The plugin includes a patch system to facilitate setup. First, install dependencies and patches:
27
19
 
28
- 1. Install react-server-dom-esm (currently an empty stub package):
29
- ```bash
30
- npm install react-server-dom-esm
20
+ ```sh
21
+ npm install -D patch-package react@experimental react-dom@experimental react-server-dom-esm
31
22
  ```
32
23
 
33
- 2. Apply the patch:
34
- ```bash
35
- npx vite-plugin-react-server/patch
24
+ Add the following command to your `package.json` scripts:
25
+
26
+ ```json
27
+ "patch": "check-react-version && patch"
36
28
  ```
37
- This will:
38
- - Detect your installed React version
39
- - Adapt the patch accordingly
40
- - Create `patches/react-server-dom-esm+YOUR-REACT-VERSION.patch`
41
29
 
42
- 3. Install patch-package:
43
- ```bash
44
- npm install patch-package --save-dev
30
+ Run the patch command:
31
+
32
+ ```sh
33
+ npm run patch
45
34
  ```
46
35
 
47
- 4. Add to package.json:
36
+ It will instruct you to add:
37
+
48
38
  ```json
49
- {
50
- "scripts": {
51
- "postinstall": "patch-package"
52
- }
53
- }
39
+ "postinstall": "patch-package"
54
40
  ```
55
41
 
56
- Alternative: You can build React from source and use `npm link` for react-server-dom-esm, react, and react-dom (though the patch system is recommended).
42
+ This ensures the patch is applied after every `npm install`. If errors arise related to `react-server-dom-esm`, verify that the postinstall step ran.
57
43
 
58
- ## Basic Configuration
44
+ ---
59
45
 
60
- ```typescript
61
- // vite.react-server.config.ts
62
- import { defineConfig } from 'vite'
63
- import type { Options } from 'vite-plugin-react-server'
46
+ ## Plugin Structure and Purpose
64
47
 
65
- // Custom router example
66
- const createRouter = (file: 'props.ts' | 'Page.tsx') => (url: string) => {
67
- if(url.includes('bidoof')) return `src/page/bidoof/${file}`
68
- if(url === '/index.rsc') return `src/page/${file}`;
69
- return `src/page/404/${file}`;
70
- }
48
+ ### Strict Client-Server Separation
71
49
 
72
- export const streamPluginOptions: Options = {
73
- moduleBase: "src",
74
- Page: createRouter('Page.tsx'),
75
- props: createRouter('props.ts'),
76
- pageExportName: "Page",
77
- propsExportName: "props",
78
- }
50
+ This plugin enforces a **strict architectural separation** between client and server execution. It achieves this by requiring **distinct entry files** for both environments, preventing unintended dependencies or cross-thread interactions. While this approach improves maintainability and clarity, it requires additional boilerplate.
51
+
52
+ The separation is accomplished through two complementary plugins:
53
+
54
+ - **vite-plugin-react-server/client** → Handles client-side rendering and ESM bundling
55
+ - **vite-plugin-react-server** → Manages server-side streaming and RSC processing
56
+
57
+ This ensures that client-side and server-side concerns remain isolated from the beginning, reducing potential inconsistencies.
58
+
59
+ ### Custom composition
60
+
61
+ You can pick and choose only the plugins you like to get the desired behavior as well. For example, we can choose only to use the preserver, the transformer, static plugin, etc.
62
+
63
+ ### Worker support
64
+
65
+ The client plugin uses the `rsc-worker` to create server side streams. The server plugin uses the `html-worker` to create client side html. If you don't want to use the rsc-worker, simply don't serve the client plugin. If you don't want to use the `html-worker` simply don't configure the `build.pages` option.
66
+
67
+ ### Custom Worker
68
+
69
+ Both workers can be customized using the `htmlWorkerPath` and `rscWorkerPath` respectively. The paths will be used to create the workers instead of the prebuilt worker included with this plugin. If these paths are defined, they will be made part of your application build as well.
70
+
71
+ Keep in mind that, using your custom worker means interacting with the message system of this plugin during development/static generation process.
72
+
73
+
74
+ ## Plugin Usage
75
+
76
+ ### vite-plugin-react-server/client
77
+
78
+ Used in `vite.config.ts` for standard Vite client-side behavior
79
+
80
+ ```ts
81
+ import { defineConfig, type Plugin } from "vite";
82
+ import { vitePluginReactClient } from "vite-plugin-react-server/client";
83
+ import { config } from "./vite.react.config";
84
+
85
+ export default defineConfig({
86
+ plugins: vitePluginReactClient(config) as Plugin[],
87
+ });
88
+ ```
89
+
90
+ #### Build Steps
91
+
92
+ ```sh
93
+ vite build
79
94
  ```
95
+ Outputs React client-side ESM files to `dist/client`.
80
96
 
81
- ### Client Build Config
97
+ ```sh
98
+ vite build --ssr
99
+ ```
100
+ Outputs files for server-side execution to `dist/server`.
101
+
102
+ ```sh
103
+ vite preview
104
+ ```
105
+ Serves the static directory.
82
106
 
83
- ```typescript
84
- // vite.config.ts
85
- import { defineConfig } from 'vite'
86
- import { viteReactStreamPlugin } from 'vite-plugin-react-server/client'
87
- import { streamPluginOptions } from './vite.react-server.config.js'
107
+ ---
108
+
109
+ ### vite-plugin-react-server
110
+
111
+ Used in `vite.server.config.ts`, this plugin strictly separates client and server execution. The client components will be emitted as references.
112
+
113
+ ```ts
114
+ import { defineConfig, Plugin } from "vite";
115
+ import { vitePluginReactServer } from "vite-plugin-react-server";
116
+ import { config } from "./vite.react.config";
88
117
 
89
118
  export default defineConfig({
90
- plugins: [viteReactStreamPlugin(streamPluginOptions)]
91
- })
119
+ plugins: vitePluginReactServer(config) as Plugin[],
120
+ });
121
+ ```
122
+
123
+ #### Running in Development
124
+
125
+ ```sh
126
+ NODE_OPTIONS="--conditions=react-server" vite --config vite.server.config.ts
127
+ ```
128
+
129
+ #### Build Steps
130
+
131
+ ```sh
132
+ NODE_OPTIONS="--conditions=react-server" vite build --config vite.server.config.ts
92
133
  ```
134
+ Generates server and static folder. The plugin ensures proper SSR handling without requiring `--ssr` manually.
135
+ Note: ssr can still be disabled via config `{ssr:false}`, which will enable vite's browser virtualization
93
136
 
94
- ### Server Build Config
137
+ ---
95
138
 
96
- ```typescript
97
- // vite.server.config.ts
98
- import { defineConfig } from 'vite'
99
- import { viteReactStreamPlugin } from 'vite-plugin-react-server/server'
100
- import { streamPluginOptions } from './vite.react-server.config.js'
139
+ ## Static Site Generation
140
+
141
+ Single-out the static generation step by only inluding the static plugin. Expects client and server folders to be there.
142
+ ```ts
143
+ import { defineConfig, Plugin } from "vite";
144
+ import { reactStaticPlugin } from "vite-plugin-react-server/static";
145
+ import { config } from "./vite.react.config";
101
146
 
102
147
  export default defineConfig({
103
- plugins: [viteReactStreamPlugin(streamPluginOptions)]
104
- })
148
+ plugins: [reactStaticPlugin(config)],
149
+ });
105
150
  ```
106
151
 
107
- ### Scripts Setup
152
+ Example output structure:
108
153
 
109
- ```json
110
- {
111
- "scripts": {
112
- "start": "NODE_OPTIONS=--conditions=react-server vite",
113
- "build": "npm run build:client && npm run build:server",
114
- "build:client": "vite build",
115
- "build:server": "NODE_OPTIONS=--conditions=react-server vite build --ssr --config vite.server.config.ts",
116
- "test:server": "NODE_OPTIONS=--conditions=react-server vitest --config vite.server.config.ts"
117
- }
118
- }
154
+ ```sh
155
+ dist/static/index.html
156
+ dist/static/index.rsc
157
+ dist/static/about/index.html
158
+ dist/static/about/index.rsc
119
159
  ```
120
160
 
121
- ## Component Types
161
+ The entire `dist/client` directory is copied into `dist/static`, as well as any assets used server-side. Allowing easy deployment by moving the static folder to a hosting service.
122
162
 
123
- ### Server Components (Default)
124
- ```tsx
125
- // src/page/pokemon/page.tsx
126
- export function Page({ pokemon }) {
127
- return <div>Its a {pokemon.name}!</div>
163
+ ---
164
+
165
+ ## Configuration
166
+
167
+ ### moduleBase
168
+
169
+ ```ts
170
+ const config = {
171
+ moduleBase: "src",
128
172
  }
129
173
  ```
174
+ Defines the root directory for project modules. This can be customized.
130
175
 
131
- ### Page Props
132
- ```tsx
133
- // src/page/pokemon/props.ts
134
- export const props = async () => {
135
- const res = await fetch("https://pokeapi.co/api/v2/pokemon-form/399/")
136
- return res.json()
137
- }
176
+ ### moduleBasePath
177
+
178
+ ```ts
179
+ moduleBasePath: "",
138
180
  ```
181
+ Passed as the second argument to `renderToPipeableStream` for server-side rendering.
139
182
 
140
- ### Client Components
141
- Use the "use client" directive for client-side features:
142
- ```tsx
143
- "use client"
144
- import { useState } from 'react'
183
+ ### moduleBaseURL
145
184
 
146
- export function Counter() {
147
- const [count, setCount] = useState(0)
148
- return <button onClick={() => setCount(c => c + 1)}>{count}</button>
149
- }
185
+ ```ts
186
+ moduleBaseURL: "https://github.com/my-gh-pages",
150
187
  ```
188
+ Defines asset URL resolution for CSS collectors and bootstrapModule.
151
189
 
152
- ### Server Actions
153
- Use the "use server" directive for server-side API endpoints:
154
- ```tsx
155
- "use server"
156
- export async function submitForm(data: FormData) {
157
- // Server-side logic
158
- }
190
+ ### Page and props Mapping
191
+
192
+ ```ts
193
+ Page: (id) => join(id.replace('index.rsc',''), 'page.tsx')
194
+ ```
195
+ Defines how pages are mapped to file paths.
196
+ ```ts
197
+ props: (id) => join(id.replace('index.rsc',''), 'props.ts')
159
198
  ```
199
+ Defines how to load the initial props of the page file.
160
200
 
161
- ## Notes
201
+ If you do not want prop files, just don't define it.
202
+ ```ts
203
+ pageExport: 'Page',
204
+ ```
205
+ Changes the default name "Page"
206
+ ```ts
207
+ propsExport: 'props',
208
+ ```
209
+ Changes the default name "props"
162
210
 
163
- - Requires `NODE_OPTIONS="--conditions=react-server"` for the Vite process
164
- - CSS files are automatically collected and link tags emitted
165
- - Components are streamed only when visited
166
- - Supports both sync and async props, and all kinds of combinations I haven't tried or tested yet!
211
+ ---
167
212
 
168
- ## License
213
+ ## Example Setup
169
214
 
170
- MIT
215
+ ### package.json Scripts
216
+
217
+ ```json
218
+ "scripts": {
219
+ "build": "build:client && build:server",
220
+ "dev": "NODE_OPTIONS='--conditions react-server' vite --config vite.server.config.ts",
221
+ "dev:client": "vite",
222
+ "build:server": "NODE_OPTIONS='--conditions react-server' vite build --config vite.server.config.ts",
223
+ "build:client": "vite build"
224
+ }
225
+ ```
171
226
 
172
- ## FAQ
227
+ ### Sample Page Component
173
228
 
174
- ### Why does this plugin use two separate workers?
229
+ ```tsx
230
+ // src/my-page.tsx
231
+ export const Page = ({ name }) => {
232
+ return <div>Hello {name}</div>;
233
+ };
234
+ ```
175
235
 
176
- The plugin uses a dual-worker architecture to handle the complex boundary between server and client code in React 19's new paradigm. This design enables four key scenarios:
236
+ ### Sample Props File
177
237
 
178
- 1. **Pure Client** - Client-side React rendering
179
- 2. **Pure Server** - Server-side RSC streaming
180
- 3. **Client-with-server-worker** - Thread WITHOUT React server conditions using dependencies that are ONLY available using the server condition
181
- 4. **Server-with-client-worker** - Thread WITH React server conditions using dependencies that are ONLY available WITHOUT the server condition
238
+ ```ts
239
+ // src/my-props.ts
240
+ export const props = {
241
+ name: "John Doe",
242
+ };
243
+ ```
182
244
 
183
- This architecture is necessary because React 19 introduces a fundamental shift in how server/client boundaries work. While React was traditionally client/browser-oriented, version 19 moves much of the functionality to the server by default.
245
+ ### Vite Configuration Files
184
246
 
185
- ## When to use which directive?
247
+ #### Client Configuration (`vite.config.ts`)
186
248
 
187
- The "use client" should be used for components that use client-only things, like hooks - browser window, localStorage, etc.
249
+ ```ts
250
+ import { vitePluginReactClient } from "vite-plugin-react-server/client";
251
+ import { defineConfig } from "vite";
188
252
 
253
+ export default defineConfig({
254
+ plugins: vitePluginReactClient(),
255
+ });
256
+ ```
189
257
 
190
- The "use server" directive is *not* for server components, it's for server actions. Every component is a server component by default. If the "use server" directive is present,
191
- this plugin will register it as a server action - which means you can intend the exported functions to be API endpoints.
258
+ #### Server Configuration (`vite.server.config.ts`)
192
259
 
193
- ## What about .client.tsx files, .server.tsx files?
260
+ ```ts
261
+ import { vitePluginReactServer } from "vite-plugin-react-server";
262
+ import { defineConfig } from "vite";
194
263
 
195
- Whenever you use the directive, it's recommended to also name the file with the .client.tsx or .server.tsx extension respectively.
196
- While this isn't required for the plugin to work - it's the only way to make sure all client and server files are included in the build -
197
- even if they are not a main entry point.
264
+ export default defineConfig({
265
+ plugins: vitePluginReactServer(),
266
+ });
267
+ ```
198
268
 
199
- ### What's the deal with NODE_OPTIONS and conditions?
269
+ ---
200
270
 
201
- The React Server Components system requires specific Node conditions:
271
+ ```sh
272
+ NODE_OPTIONS='--conditions react-server' npx vite --config vite.server.config.ts
273
+ ```
202
274
 
203
- - `NODE_OPTIONS='--conditions=react-server'` is required for RSC functionality (generating RSC streams)
204
- - This condition must NOT be present for client-side React operations (generating HTML from RSC streams)
275
+ In development mode, the server plugin pipes the React stream directly to the response.
205
276
 
206
- The plugin recommends using the react-server condition in the main thread to enable React server features from the start. When different conditions are needed (e.g., generating static HTML), the plugin uses workers with appropriate conditions.
277
+ ```sh
278
+ NODE_OPTIONS='--conditions react-server' npx vite build --config vite.server.config.ts
279
+ ```
280
+ This builds the `dist/server` directory. It sets ssr to true by default, so you can't forget to. Additionally, when the build is done it generates the `dist/static` directory using the /static plugin.
207
281
 
208
- ### Why start with "use client"?
282
+ ---
209
283
 
210
- With React 19's server-first approach, many existing ecosystem tools and patterns need the "use client" directive to work as they did before. It's becoming a common pattern to start with "use client" to maintain compatibility with existing code while gradually adopting the new server-first paradigm.
284
+ ## Summary
211
285
 
286
+ - **Strict Client-Server Separation** → Ensures modularity and maintainability
287
+ - **Static Site Generation** → Produces deployable HTML and RSC files
288
+ - **Dual RSC Implementation** → Supports direct streaming and worker-based approaches
289
+ - **Customizable Module Loading** → Allows flexible project configurations
212
290
 
291
+ This plugin provides a workflow for React Server Components within Vite, balancing **performance, modularity, and ease of use**.
213
292
 
package/bin/patch.mjs CHANGED
@@ -13,8 +13,6 @@ async function patchReactExperimental() {
13
13
  try {
14
14
  // Read installed React version from user's project
15
15
 
16
- const installedVersion = React.version
17
- const PATCH_RECONCILER_VERSION = installedVersion.replace('19.1.0', '0.0.0')
18
16
  if(TEMPLATE_VERSION === PATCH_RECONCILER_VERSION) {
19
17
  console.log('React version is patched')
20
18
  }
@@ -25,6 +23,14 @@ async function patchReactExperimental() {
25
23
  template: `../scripts/react-server-dom-esm+${TEMPLATE_VERSION}.patch`,
26
24
  output: `react-server-dom-esm+${STUB_VERSION}.patch`
27
25
  },
26
+ {
27
+ template: `../scripts/react+${TEMPLATE_VERSION}.patch`,
28
+ output: `react+${PATCH_RECONCILER_VERSION}.patch`
29
+ },
30
+ {
31
+ template: `../scripts/react-dom+${TEMPLATE_VERSION}.patch`,
32
+ output: `react-dom+${PATCH_RECONCILER_VERSION}.patch`
33
+ },
28
34
  ]
29
35
 
30
36
  // Create patches dir in user's project
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-react-server",
3
- "version": "0.3.18",
3
+ "version": "1.0.0",
4
4
  "description": "Vite plugin for React Server Components (RSC)",
5
5
  "type": "module",
6
6
  "main": "./dist/plugin/index.js",
@@ -19,13 +19,15 @@
19
19
  ".": "./dist/plugin/index.js",
20
20
  "./client": "./dist/client.js",
21
21
  "./server": "./dist/server.js",
22
+ "./static": "./dist/static.js",
22
23
  "./html-worker": "./dist/plugin/worker/html-worker.js",
23
24
  "./rsc-worker": "./dist/plugin/worker/rsc-worker.js",
24
25
  "./loader": "./dist/plugin/worker/loader.js",
25
26
  "./package.json": "./package.json",
26
27
  "./patch": "./scripts/patch.mjs",
27
28
  "./check-react-version": "./scripts/check-react-version.mjs",
28
- "./css-loader": "./dist/plugin/loader/css-loader.js"
29
+ "./css-loader": "./dist/plugin/loader/css-loader.js",
30
+ "./components": "./dist/plugin/components.js"
29
31
  },
30
32
  "typesVersions": {
31
33
  "*": {
@@ -38,11 +40,17 @@
38
40
  "server": [
39
41
  "./dist/plugin/react-server/plugin.d.ts"
40
42
  ],
43
+ "static": [
44
+ "./dist/plugin/static/plugin.d.ts"
45
+ ],
41
46
  "worker": [
42
47
  "./dist/plugin/worker/worker.d.ts"
43
48
  ],
44
49
  "loader": [
45
50
  "./dist/plugin/worker/loader.d.ts"
51
+ ],
52
+ "components": [
53
+ "./dist/plugin/components.d.ts"
46
54
  ]
47
55
  }
48
56
  },
@@ -91,8 +99,8 @@
91
99
  },
92
100
  "homepage": "https://github.com/nicobrinkkemper/vite-plugin-react-server#readme",
93
101
  "peerDependencies": {
94
- "react": "^0.0.0-experimental-d55cc79b-20250228",
95
- "react-dom": "^0.0.0-experimental-d55cc79b-20250228",
102
+ "react": "^0.0.0-experimental-f9d78089-20250306",
103
+ "react-dom": "^0.0.0-experimental-f9d78089-20250306",
96
104
  "vite": "*"
97
105
  },
98
106
  "peerDependenciesMeta": {
@@ -120,13 +128,12 @@
120
128
  "typescript": "^5.7.3",
121
129
  "vite": "^6.0.11",
122
130
  "vitest": "^3.0.4",
123
- "webpack-sources": "^3.2.3"
131
+ "webpack-sources": "^3.2.3",
132
+ "tsx": "^4.19.2"
124
133
  },
125
134
  "bin": {
126
135
  "check-react-version": "./scripts/check-react-version.mjs",
127
136
  "patch": "./bin/patch.mjs"
128
137
  },
129
- "dependencies": {
130
- "tsx": "^4.19.2"
131
- }
138
+ "dependencies": {}
132
139
  }
@@ -1 +1 @@
1
- {"version":3,"file":"checkFilesExist.d.ts","sourceRoot":"","sources":["../../plugin/checkFilesExist.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAW7E,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,CAAC,CA4ChC"}
1
+ {"version":3,"file":"checkFilesExist.d.ts","sourceRoot":"","sources":["../../plugin/checkFilesExist.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAY7E,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,CAAC,CA+ChC"}
@@ -5,9 +5,9 @@
5
5
  */
6
6
  import { existsSync } from 'node:fs';
7
7
  import { join } from 'node:path';
8
- import 'vite';
9
8
  import { createInputNormalizer } from './helpers/inputNormalizer.js';
10
9
 
10
+ let stashedFiles = null;
11
11
  const resolveFileOption = (pageOrProps) => {
12
12
  if (typeof pageOrProps === "string") {
13
13
  return () => pageOrProps;
@@ -15,6 +15,9 @@ const resolveFileOption = (pageOrProps) => {
15
15
  return pageOrProps;
16
16
  };
17
17
  async function checkFilesExist(pages, options, root) {
18
+ if (stashedFiles) {
19
+ return stashedFiles;
20
+ }
18
21
  if (!root || root === "") {
19
22
  throw new Error("Root not found");
20
23
  }
@@ -56,7 +59,8 @@ async function checkFilesExist(pages, options, root) {
56
59
  pageMap.set(pageKey, pageValue);
57
60
  propsMap.set(propsKey, propsValue);
58
61
  }
59
- return { pageMap, pageSet, propsMap, propsSet, urlMap, errors };
62
+ stashedFiles = { pageMap, pageSet, propsMap, propsSet, urlMap, errors };
63
+ return stashedFiles;
60
64
  }
61
65
 
62
66
  export { checkFilesExist };
@@ -1 +1 @@
1
- {"version":3,"file":"checkFilesExist.js","sources":["../../plugin/checkFilesExist.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { CheckFilesExistReturn, ResolvedUserOptions } from \"./types.js\";\nimport { normalizePath } from \"vite\";\nimport { createInputNormalizer } from \"./helpers/inputNormalizer.js\";\n\nconst resolveFileOption = (pageOrProps: string | ((url: string) => string)) => {\n if (typeof pageOrProps === \"string\") {\n return () => pageOrProps;\n }\n return pageOrProps;\n};\n\nexport async function checkFilesExist(\n pages: string[],\n options: ResolvedUserOptions,\n root: string\n): Promise<CheckFilesExistReturn> {\n if (!root || root === \"\") {\n throw new Error(\"Root not found\");\n }\n const errors: string[] = [];\n const pageSet = new Set<string>();\n const propsSet = new Set<string>();\n const pageMap = new Map<string, string>();\n const propsMap = new Map<string, string>();\n const urlMap = new Map<string, { props: string; page: string }>();\n const normalizer = createInputNormalizer({\n root,\n preserveModulesRoot: options.build.preserveModulesRoot === true ? options.moduleBase : undefined,\n removeExtension: true,\n });\n const pageFn = resolveFileOption(options.Page);\n const propsFn = resolveFileOption(options.props);\n for (const page of pages) {\n const pagePath = pageFn(page);\n const propsPath = propsFn(page);\n const [pageKey, pageValue] = normalizer(pagePath);\n const [propsKey, propsValue] = normalizer(propsPath);\n try {\n if (!existsSync(join(root, pageValue))) {\n errors.push(\n `Page file not found: ${pagePath}, ${join(root, pagePath)}`\n );\n }\n if (!existsSync(join(root, propsValue))) {\n errors.push(\n `Props file not found: ${propsPath}, ${join(root, propsPath)}`\n );\n }\n } catch (error) {\n errors.push(`Error checking files: ${error}`);\n }\n urlMap.set(page, { props: propsPath, page: pagePath });\n pageSet.add(pagePath);\n propsSet.add(propsPath);\n pageMap.set(pageKey, pageValue);\n propsMap.set(propsKey, propsValue);\n }\n\n return { pageMap, pageSet, propsMap, propsSet, urlMap, errors };\n}\n"],"names":[],"mappings":";;;;;;;;;;AAMA,MAAM,iBAAA,GAAoB,CAAC,WAAoD,KAAA;AAC7E,EAAI,IAAA,OAAO,gBAAgB,QAAU,EAAA;AACnC,IAAA,OAAO,MAAM,WAAA;AAAA;AAEf,EAAO,OAAA,WAAA;AACT,CAAA;AAEsB,eAAA,eAAA,CACpB,KACA,EAAA,OAAA,EACA,IACgC,EAAA;AAChC,EAAI,IAAA,CAAC,IAAQ,IAAA,IAAA,KAAS,EAAI,EAAA;AACxB,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA;AAAA;AAElC,EAAA,MAAM,SAAmB,EAAC;AAC1B,EAAM,MAAA,OAAA,uBAAc,GAAY,EAAA;AAChC,EAAM,MAAA,QAAA,uBAAe,GAAY,EAAA;AACjC,EAAM,MAAA,OAAA,uBAAc,GAAoB,EAAA;AACxC,EAAM,MAAA,QAAA,uBAAe,GAAoB,EAAA;AACzC,EAAM,MAAA,MAAA,uBAAa,GAA6C,EAAA;AAChE,EAAA,MAAM,aAAa,qBAAsB,CAAA;AAAA,IACvC,IAAA;AAAA,IACA,qBAAqB,OAAQ,CAAA,KAAA,CAAM,mBAAwB,KAAA,IAAA,GAAO,QAAQ,UAAa,GAAA,SAAA;AAAA,IACvF,eAAiB,EAAA;AAAA,GAClB,CAAA;AACD,EAAM,MAAA,MAAA,GAAS,iBAAkB,CAAA,OAAA,CAAQ,IAAI,CAAA;AAC7C,EAAM,MAAA,OAAA,GAAU,iBAAkB,CAAA,OAAA,CAAQ,KAAK,CAAA;AAC/C,EAAA,KAAA,MAAW,QAAQ,KAAO,EAAA;AACxB,IAAM,MAAA,QAAA,GAAW,OAAO,IAAI,CAAA;AAC5B,IAAM,MAAA,SAAA,GAAY,QAAQ,IAAI,CAAA;AAC9B,IAAA,MAAM,CAAC,OAAA,EAAS,SAAS,CAAA,GAAI,WAAW,QAAQ,CAAA;AAChD,IAAA,MAAM,CAAC,QAAA,EAAU,UAAU,CAAA,GAAI,WAAW,SAAS,CAAA;AACnD,IAAI,IAAA;AACF,MAAA,IAAI,CAAC,UAAW,CAAA,IAAA,CAAK,IAAM,EAAA,SAAS,CAAC,CAAG,EAAA;AACtC,QAAO,MAAA,CAAA,IAAA;AAAA,UACL,wBAAwB,QAAQ,CAAA,EAAA,EAAK,IAAK,CAAA,IAAA,EAAM,QAAQ,CAAC,CAAA;AAAA,SAC3D;AAAA;AAEF,MAAA,IAAI,CAAC,UAAW,CAAA,IAAA,CAAK,IAAM,EAAA,UAAU,CAAC,CAAG,EAAA;AACvC,QAAO,MAAA,CAAA,IAAA;AAAA,UACL,yBAAyB,SAAS,CAAA,EAAA,EAAK,IAAK,CAAA,IAAA,EAAM,SAAS,CAAC,CAAA;AAAA,SAC9D;AAAA;AACF,aACO,KAAO,EAAA;AACd,MAAO,MAAA,CAAA,IAAA,CAAK,CAAyB,sBAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AAAA;AAE9C,IAAA,MAAA,CAAO,IAAI,IAAM,EAAA,EAAE,OAAO,SAAW,EAAA,IAAA,EAAM,UAAU,CAAA;AACrD,IAAA,OAAA,CAAQ,IAAI,QAAQ,CAAA;AACpB,IAAA,QAAA,CAAS,IAAI,SAAS,CAAA;AACtB,IAAQ,OAAA,CAAA,GAAA,CAAI,SAAS,SAAS,CAAA;AAC9B,IAAS,QAAA,CAAA,GAAA,CAAI,UAAU,UAAU,CAAA;AAAA;AAGnC,EAAA,OAAO,EAAE,OAAS,EAAA,OAAA,EAAS,QAAU,EAAA,QAAA,EAAU,QAAQ,MAAO,EAAA;AAChE;;;;"}
1
+ {"version":3,"file":"checkFilesExist.js","sources":["../../plugin/checkFilesExist.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { CheckFilesExistReturn, ResolvedUserOptions } from \"./types.js\";\nimport { createInputNormalizer } from \"./helpers/inputNormalizer.js\";\n\nlet stashedFiles: CheckFilesExistReturn | null = null;\n\nconst resolveFileOption = (pageOrProps: string | ((url: string) => string)) => {\n if (typeof pageOrProps === \"string\") {\n return () => pageOrProps;\n }\n return pageOrProps;\n};\n\nexport async function checkFilesExist(\n pages: string[],\n options: ResolvedUserOptions,\n root: string\n): Promise<CheckFilesExistReturn> {\n if(stashedFiles){\n return stashedFiles;\n }\n if (!root || root === \"\") {\n throw new Error(\"Root not found\");\n }\n const errors: string[] = [];\n const pageSet = new Set<string>();\n const propsSet = new Set<string>();\n const pageMap = new Map<string, string>();\n const propsMap = new Map<string, string>();\n const urlMap = new Map<string, { props: string; page: string }>();\n const normalizer = createInputNormalizer({\n root,\n preserveModulesRoot: options.build.preserveModulesRoot === true ? options.moduleBase : undefined,\n removeExtension: true,\n });\n const pageFn = resolveFileOption(options.Page);\n const propsFn = resolveFileOption(options.props);\n for (const page of pages) {\n const pagePath = pageFn(page);\n const propsPath = propsFn(page);\n const [pageKey, pageValue] = normalizer(pagePath);\n const [propsKey, propsValue] = normalizer(propsPath);\n try {\n if (!existsSync(join(root, pageValue))) {\n errors.push(\n `Page file not found: ${pagePath}, ${join(root, pagePath)}`\n );\n }\n if (!existsSync(join(root, propsValue))) {\n errors.push(\n `Props file not found: ${propsPath}, ${join(root, propsPath)}`\n );\n }\n } catch (error) {\n errors.push(`Error checking files: ${error}`);\n }\n urlMap.set(page, { props: propsPath, page: pagePath });\n pageSet.add(pagePath);\n propsSet.add(propsPath);\n pageMap.set(pageKey, pageValue);\n propsMap.set(propsKey, propsValue);\n }\n stashedFiles = { pageMap, pageSet, propsMap, propsSet, urlMap, errors };\n return stashedFiles;\n}\n"],"names":[],"mappings":";;;;;;;;;AAKA,IAAI,YAA6C,GAAA,IAAA;AAEjD,MAAM,iBAAA,GAAoB,CAAC,WAAoD,KAAA;AAC7E,EAAI,IAAA,OAAO,gBAAgB,QAAU,EAAA;AACnC,IAAA,OAAO,MAAM,WAAA;AAAA;AAEf,EAAO,OAAA,WAAA;AACT,CAAA;AAEsB,eAAA,eAAA,CACpB,KACA,EAAA,OAAA,EACA,IACgC,EAAA;AAChC,EAAA,IAAG,YAAa,EAAA;AACd,IAAO,OAAA,YAAA;AAAA;AAET,EAAI,IAAA,CAAC,IAAQ,IAAA,IAAA,KAAS,EAAI,EAAA;AACxB,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA;AAAA;AAElC,EAAA,MAAM,SAAmB,EAAC;AAC1B,EAAM,MAAA,OAAA,uBAAc,GAAY,EAAA;AAChC,EAAM,MAAA,QAAA,uBAAe,GAAY,EAAA;AACjC,EAAM,MAAA,OAAA,uBAAc,GAAoB,EAAA;AACxC,EAAM,MAAA,QAAA,uBAAe,GAAoB,EAAA;AACzC,EAAM,MAAA,MAAA,uBAAa,GAA6C,EAAA;AAChE,EAAA,MAAM,aAAa,qBAAsB,CAAA;AAAA,IACvC,IAAA;AAAA,IACA,qBAAqB,OAAQ,CAAA,KAAA,CAAM,mBAAwB,KAAA,IAAA,GAAO,QAAQ,UAAa,GAAA,SAAA;AAAA,IACvF,eAAiB,EAAA;AAAA,GAClB,CAAA;AACD,EAAM,MAAA,MAAA,GAAS,iBAAkB,CAAA,OAAA,CAAQ,IAAI,CAAA;AAC7C,EAAM,MAAA,OAAA,GAAU,iBAAkB,CAAA,OAAA,CAAQ,KAAK,CAAA;AAC/C,EAAA,KAAA,MAAW,QAAQ,KAAO,EAAA;AACxB,IAAM,MAAA,QAAA,GAAW,OAAO,IAAI,CAAA;AAC5B,IAAM,MAAA,SAAA,GAAY,QAAQ,IAAI,CAAA;AAC9B,IAAA,MAAM,CAAC,OAAA,EAAS,SAAS,CAAA,GAAI,WAAW,QAAQ,CAAA;AAChD,IAAA,MAAM,CAAC,QAAA,EAAU,UAAU,CAAA,GAAI,WAAW,SAAS,CAAA;AACnD,IAAI,IAAA;AACF,MAAA,IAAI,CAAC,UAAW,CAAA,IAAA,CAAK,IAAM,EAAA,SAAS,CAAC,CAAG,EAAA;AACtC,QAAO,MAAA,CAAA,IAAA;AAAA,UACL,wBAAwB,QAAQ,CAAA,EAAA,EAAK,IAAK,CAAA,IAAA,EAAM,QAAQ,CAAC,CAAA;AAAA,SAC3D;AAAA;AAEF,MAAA,IAAI,CAAC,UAAW,CAAA,IAAA,CAAK,IAAM,EAAA,UAAU,CAAC,CAAG,EAAA;AACvC,QAAO,MAAA,CAAA,IAAA;AAAA,UACL,yBAAyB,SAAS,CAAA,EAAA,EAAK,IAAK,CAAA,IAAA,EAAM,SAAS,CAAC,CAAA;AAAA,SAC9D;AAAA;AACF,aACO,KAAO,EAAA;AACd,MAAO,MAAA,CAAA,IAAA,CAAK,CAAyB,sBAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AAAA;AAE9C,IAAA,MAAA,CAAO,IAAI,IAAM,EAAA,EAAE,OAAO,SAAW,EAAA,IAAA,EAAM,UAAU,CAAA;AACrD,IAAA,OAAA,CAAQ,IAAI,QAAQ,CAAA;AACpB,IAAA,QAAA,CAAS,IAAI,SAAS,CAAA;AACtB,IAAQ,OAAA,CAAA,GAAA,CAAI,SAAS,SAAS,CAAA;AAC9B,IAAS,QAAA,CAAA,GAAA,CAAI,UAAU,UAAU,CAAA;AAAA;AAEnC,EAAA,YAAA,GAAe,EAAE,OAAS,EAAA,OAAA,EAAS,QAAU,EAAA,QAAA,EAAU,QAAQ,MAAO,EAAA;AACtE,EAAO,OAAA,YAAA;AACT;;;;"}
@@ -0,0 +1,23 @@
1
+ import type { Manifest, ModuleGraph } from "vite";
2
+ export declare function collectModuleGraphCss({ moduleGraph, pagePath, onCss, parentUrl, }: {
3
+ moduleGraph: ModuleGraph;
4
+ pagePath: string;
5
+ onCss?: (path: string, parentUrl: string) => void;
6
+ parentUrl?: string;
7
+ }): Promise<Map<string, string>>;
8
+ export declare function collectManifestClientFiles({ manifest, root, pagePath, preserveModulesRoot, moduleBase, onCss, onClientModule, testClient, testJson, }: {
9
+ manifest: Manifest;
10
+ root: string;
11
+ pagePath: string;
12
+ preserveModulesRoot?: boolean;
13
+ moduleBase?: string;
14
+ onCss?: (path: string, parentUrl: string) => void;
15
+ onClientModule?: (path: string, parentUrl: string) => void;
16
+ parentUrl?: string;
17
+ testClient?: (id: string) => boolean;
18
+ testJson?: (id: string) => boolean;
19
+ }): {
20
+ cssFiles: Map<string, string>;
21
+ clientFiles: Map<string, string>;
22
+ };
23
+ //# sourceMappingURL=collect-manifest-client-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect-manifest-client-files.d.ts","sourceRoot":"","sources":["../../plugin/collect-manifest-client-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAIlD,wBAAsB,qBAAqB,CAAC,EAC1C,WAAW,EACX,QAAQ,EACR,KAAK,EACL,SAAS,GACV,EAAE;IACD,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,gCAoBA;AAED,wBAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,mBAAmB,EACnB,UAAU,EACV,KAAK,EACL,cAAc,EACd,UAA0D,EAC1D,QAAmD,GACpD,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;CACpC;;;EA6GA"}