vite-plugin-react-server 1.1.10 → 1.1.12

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 (361) hide show
  1. package/README.md +208 -27
  2. package/dist/package.json +34 -14
  3. package/dist/plugin/{css-collector-elements.d.ts → components/css-collector-elements.d.ts} +1 -1
  4. package/dist/plugin/components/css-collector-elements.d.ts.map +1 -0
  5. package/dist/plugin/components/css-collector-elements.js.map +1 -0
  6. package/dist/plugin/{css-collector.d.ts → components/css-collector.d.ts} +1 -1
  7. package/dist/plugin/components/css-collector.d.ts.map +1 -0
  8. package/dist/plugin/components/css-collector.js.map +1 -0
  9. package/dist/plugin/components/html.d.ts +4 -0
  10. package/dist/plugin/components/html.d.ts.map +1 -0
  11. package/dist/plugin/components/html.js +17 -0
  12. package/dist/plugin/components/html.js.map +1 -0
  13. package/dist/plugin/components/index.d.ts +5 -0
  14. package/dist/plugin/components/index.d.ts.map +1 -0
  15. package/dist/plugin/components.js +9 -3
  16. package/dist/plugin/components.js.map +1 -0
  17. package/dist/plugin/config/autoDiscover/index.d.ts +6 -0
  18. package/dist/plugin/config/autoDiscover/index.d.ts.map +1 -0
  19. package/dist/plugin/config/autoDiscover/index.js +8 -0
  20. package/dist/plugin/config/{resolveAutoDiscover.d.ts → autoDiscover/resolveAutoDiscover.d.ts} +1 -1
  21. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -0
  22. package/dist/plugin/config/{resolveAutoDiscover.js → autoDiscover/resolveAutoDiscover.js} +10 -9
  23. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +1 -0
  24. package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -1
  25. package/dist/plugin/config/autoDiscover/resolveBuildPages.js +10 -10
  26. package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +1 -1
  27. package/dist/plugin/config/defaults.d.ts +4 -3
  28. package/dist/plugin/config/defaults.d.ts.map +1 -1
  29. package/dist/plugin/config/defaults.js +5 -3
  30. package/dist/plugin/config/defaults.js.map +1 -1
  31. package/dist/plugin/config/index.d.ts +1 -0
  32. package/dist/plugin/config/index.d.ts.map +1 -1
  33. package/dist/plugin/config/index.js +1 -0
  34. package/dist/plugin/config/resolveEnv.d.ts +11 -1
  35. package/dist/plugin/config/resolveEnv.d.ts.map +1 -1
  36. package/dist/plugin/config/resolveEnv.js +104 -5
  37. package/dist/plugin/config/resolveEnv.js.map +1 -1
  38. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  39. package/dist/plugin/config/resolveOptions.js +11 -4
  40. package/dist/plugin/config/resolveOptions.js.map +1 -1
  41. package/dist/plugin/config/resolveUrlOption.d.ts +1 -1
  42. package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -1
  43. package/dist/plugin/config/resolveUrlOption.js +1 -2
  44. package/dist/plugin/config/resolveUrlOption.js.map +1 -1
  45. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  46. package/dist/plugin/config/resolveUserConfig.js +43 -18
  47. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  48. package/dist/plugin/config.js +17 -0
  49. package/dist/plugin/config.js.map +1 -0
  50. package/dist/plugin/env/index.d.ts +2 -0
  51. package/dist/plugin/env/index.d.ts.map +1 -0
  52. package/dist/plugin/env/index.js +1 -0
  53. package/dist/plugin/env/plugin.d.ts +30 -0
  54. package/dist/plugin/env/plugin.d.ts.map +1 -0
  55. package/dist/plugin/env/plugin.js +64 -0
  56. package/dist/plugin/env.js +45 -0
  57. package/dist/plugin/env.js.map +1 -0
  58. package/dist/plugin/error/toError.d.ts +6 -0
  59. package/dist/plugin/error/toError.d.ts.map +1 -0
  60. package/dist/plugin/error/toError.js +19 -0
  61. package/dist/plugin/error/toError.js.map +1 -0
  62. package/dist/plugin/file-preserver/plugin.d.ts +19 -0
  63. package/dist/plugin/file-preserver/plugin.d.ts.map +1 -0
  64. package/dist/plugin/file-preserver/plugin.js +108 -0
  65. package/dist/plugin/file-preserver.js +96 -0
  66. package/dist/plugin/file-preserver.js.map +1 -0
  67. package/dist/plugin/helpers/createEventHandler.d.ts +1 -1
  68. package/dist/plugin/helpers/createRscStream.js +1 -1
  69. package/dist/plugin/helpers/createRscStream.js.map +1 -1
  70. package/dist/plugin/helpers/formatMetrics.d.ts +3 -1
  71. package/dist/plugin/helpers/formatMetrics.d.ts.map +1 -1
  72. package/dist/plugin/helpers/formatMetrics.js +22 -7
  73. package/dist/plugin/helpers/formatMetrics.js.map +1 -0
  74. package/dist/plugin/helpers/getRouteFiles.d.ts +1 -1
  75. package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -1
  76. package/dist/plugin/helpers/getRouteFiles.js +37 -18
  77. package/dist/plugin/helpers/getRouteFiles.js.map +1 -0
  78. package/dist/plugin/helpers/index.d.ts +24 -0
  79. package/dist/plugin/helpers/index.d.ts.map +1 -0
  80. package/dist/plugin/helpers/index.js +31 -0
  81. package/dist/plugin/helpers/metrics.js +26 -2
  82. package/dist/plugin/helpers/metrics.js.map +1 -1
  83. package/dist/plugin/helpers/moduleRefs.d.ts.map +1 -0
  84. package/dist/plugin/helpers/moduleRefs.js.map +1 -0
  85. package/dist/plugin/helpers/requestInfo.d.ts +10 -0
  86. package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
  87. package/dist/plugin/helpers/requestInfo.js.map +1 -1
  88. package/dist/plugin/helpers/requestToRoute.js +22 -14
  89. package/dist/plugin/helpers/requestToRoute.js.map +1 -0
  90. package/dist/plugin/helpers/resolvePage.d.ts.map +1 -0
  91. package/dist/plugin/{resolvePage.js → helpers/resolvePage.js} +19 -3
  92. package/dist/plugin/helpers/resolvePage.js.map +1 -0
  93. package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
  94. package/dist/plugin/helpers/resolvePageAndProps.js +7 -4
  95. package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -1
  96. package/dist/plugin/helpers/resolveProps.d.ts.map +1 -0
  97. package/dist/plugin/{resolveProps.js → helpers/resolveProps.js} +9 -6
  98. package/dist/plugin/helpers/resolveProps.js.map +1 -0
  99. package/dist/plugin/helpers/serializeUserOptions.js +1 -1
  100. package/dist/plugin/helpers/serializeUserOptions.js.map +1 -1
  101. package/dist/plugin/helpers/stashReturnValue.js +19 -13
  102. package/dist/plugin/helpers/stashReturnValue.js.map +1 -0
  103. package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
  104. package/dist/plugin/helpers/tryManifest.js +0 -1
  105. package/dist/plugin/helpers/tryManifest.js.map +1 -1
  106. package/dist/plugin/helpers.js +27 -0
  107. package/dist/plugin/helpers.js.map +1 -0
  108. package/dist/plugin/loader/createBuildLoader.js +1 -1
  109. package/dist/plugin/loader/createBuildLoader.js.map +1 -1
  110. package/dist/plugin/loader/env-loader.development.d.ts +12 -0
  111. package/dist/plugin/loader/env-loader.development.d.ts.map +1 -0
  112. package/dist/plugin/loader/env-loader.development.js +60 -0
  113. package/dist/plugin/plugin.client.d.ts.map +1 -1
  114. package/dist/plugin/plugin.client.js +2 -0
  115. package/dist/plugin/plugin.client.js.map +1 -1
  116. package/dist/plugin/plugin.d.ts.map +1 -1
  117. package/dist/plugin/plugin.js +1 -2
  118. package/dist/plugin/plugin.server.d.ts.map +1 -1
  119. package/dist/plugin/plugin.server.js +3 -0
  120. package/dist/plugin/plugin.server.js.map +1 -1
  121. package/dist/plugin/process-env.d.ts +14 -0
  122. package/dist/plugin/process-env.d.ts.map +1 -0
  123. package/dist/plugin/react-client/createMessageHandlers.d.ts +2 -1
  124. package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
  125. package/dist/plugin/react-client/createMessageHandlers.js +13 -2
  126. package/dist/plugin/react-client/createMessageHandlers.js.map +1 -1
  127. package/dist/plugin/react-client/createWorkerStream.d.ts +8 -2
  128. package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
  129. package/dist/plugin/react-client/createWorkerStream.js +49 -8
  130. package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
  131. package/dist/plugin/react-client/handleWorkerRscStream.d.ts +19 -0
  132. package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -0
  133. package/dist/plugin/react-client/handleWorkerRscStream.js +47 -0
  134. package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -0
  135. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  136. package/dist/plugin/react-client/plugin.js +18 -2
  137. package/dist/plugin/react-client/plugin.js.map +1 -1
  138. package/dist/plugin/react-client/restartWorker.d.ts +6 -1
  139. package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
  140. package/dist/plugin/react-client/restartWorker.js +13 -5
  141. package/dist/plugin/react-client/restartWorker.js.map +1 -1
  142. package/dist/plugin/react-client/server.d.ts +2 -13
  143. package/dist/plugin/react-client/server.d.ts.map +1 -1
  144. package/dist/plugin/react-client/server.js +112 -99
  145. package/dist/plugin/react-client/server.js.map +1 -1
  146. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  147. package/dist/plugin/react-server/plugin.js +18 -8
  148. package/dist/plugin/react-server/plugin.js.map +1 -1
  149. package/dist/plugin/react-server/server.d.ts.map +1 -1
  150. package/dist/plugin/react-server/server.js +28 -12
  151. package/dist/plugin/react-server/server.js.map +1 -1
  152. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
  153. package/dist/plugin/react-static/collectHtmlWorkerContent.js +9 -0
  154. package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -1
  155. package/dist/plugin/react-static/fileWriter.d.ts +1 -1
  156. package/dist/plugin/react-static/fileWriter.d.ts.map +1 -1
  157. package/dist/plugin/react-static/fileWriter.js.map +1 -1
  158. package/dist/plugin/react-static/plugin.d.ts.map +1 -1
  159. package/dist/plugin/react-static/plugin.js +19 -27
  160. package/dist/plugin/react-static/plugin.js.map +1 -1
  161. package/dist/plugin/root.d.ts +1 -0
  162. package/dist/plugin/root.d.ts.map +1 -1
  163. package/dist/plugin/root.js +3 -2
  164. package/dist/plugin/root.js.map +1 -1
  165. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +1 -10
  166. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +1 -1
  167. package/dist/plugin/transformer/upgradeCssModuleCode.js +40 -38
  168. package/dist/plugin/types.d.ts +57 -15
  169. package/dist/plugin/types.d.ts.map +1 -1
  170. package/dist/plugin/types.js +1 -1
  171. package/dist/plugin/utils/callServer.d.ts +1 -1
  172. package/dist/plugin/utils/callServer.d.ts.map +1 -1
  173. package/dist/plugin/utils/callServer.js +2 -16
  174. package/dist/plugin/utils/callServer.js.map +1 -1
  175. package/dist/plugin/utils/createCallServer.d.ts +2 -0
  176. package/dist/plugin/utils/createCallServer.d.ts.map +1 -0
  177. package/dist/plugin/utils/createCallServer.js +28 -0
  178. package/dist/plugin/utils/createCallServer.js.map +1 -0
  179. package/dist/plugin/utils/createReactFetcher.d.ts +3 -1
  180. package/dist/plugin/utils/createReactFetcher.d.ts.map +1 -1
  181. package/dist/plugin/utils/createReactFetcher.js +7 -5
  182. package/dist/plugin/utils/createReactFetcher.js.map +1 -1
  183. package/dist/plugin/utils/env.js.map +1 -1
  184. package/dist/plugin/utils/envUrls.d.ts +9 -0
  185. package/dist/plugin/utils/envUrls.d.ts.map +1 -0
  186. package/dist/plugin/utils/envUrls.js +7 -0
  187. package/dist/plugin/utils/envUrls.node.d.ts +7 -0
  188. package/dist/plugin/utils/envUrls.node.d.ts.map +1 -0
  189. package/dist/plugin/utils/envUrls.node.js +11 -0
  190. package/dist/plugin/utils/envUrls.node.js.map +1 -0
  191. package/dist/plugin/utils/index.d.ts +1 -1
  192. package/dist/plugin/utils/index.d.ts.map +1 -1
  193. package/dist/plugin/utils/index.js +1 -1
  194. package/dist/plugin/utils/moduleBaseURL.d.ts +3 -0
  195. package/dist/plugin/utils/moduleBaseURL.d.ts.map +1 -0
  196. package/dist/plugin/utils/moduleBaseURL.js +4 -0
  197. package/dist/plugin/utils/urls.d.ts +130 -0
  198. package/dist/plugin/utils/urls.d.ts.map +1 -0
  199. package/dist/plugin/utils/urls.js +87 -0
  200. package/dist/plugin/utils/urls.js.map +1 -0
  201. package/dist/plugin/utils.js +1 -1
  202. package/dist/plugin/vendor/index.d.ts +2 -0
  203. package/dist/plugin/vendor/index.d.ts.map +1 -0
  204. package/dist/plugin/vendor/index.js +1 -0
  205. package/dist/plugin/vendor/vendor.client.d.ts.map +1 -0
  206. package/dist/plugin/vendor/vendor.client.js.map +1 -0
  207. package/dist/plugin/vendor/vendor.d.ts +2 -0
  208. package/dist/plugin/vendor/vendor.d.ts.map +1 -0
  209. package/dist/plugin/vendor/vendor.js +15 -0
  210. package/dist/plugin/vendor/vendor.js.map +1 -0
  211. package/dist/plugin/vendor/vendor.server.d.ts.map +1 -0
  212. package/dist/plugin/vendor/vendor.server.js.map +1 -0
  213. package/dist/plugin/vendor.js +7 -0
  214. package/dist/plugin/vendor.js.map +1 -0
  215. package/dist/plugin/worker/createWorker.d.ts +3 -0
  216. package/dist/plugin/worker/createWorker.d.ts.map +1 -1
  217. package/dist/plugin/worker/createWorker.js +33 -20
  218. package/dist/plugin/worker/createWorker.js.map +1 -1
  219. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +1 -1
  220. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -1
  221. package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
  222. package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
  223. package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
  224. package/dist/plugin/worker/rsc/handleRender.js +4 -4
  225. package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
  226. package/dist/plugin/worker/rsc/messageHandler.d.ts +2 -1
  227. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
  228. package/dist/plugin/worker/rsc/messageHandler.js +41 -15
  229. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
  230. package/dist/plugin/worker/rsc/rsc-worker.development.js +16 -5
  231. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
  232. package/dist/plugin/worker/rsc/rsc-worker.production.js +16 -5
  233. package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
  234. package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
  235. package/dist/plugin/worker/sendMessage.js +45 -43
  236. package/dist/plugin/worker/sendMessage.js.map +1 -0
  237. package/dist/plugin/worker/types.d.ts +26 -4
  238. package/dist/plugin/worker/types.d.ts.map +1 -1
  239. package/dist/server.js +1 -1
  240. package/dist/server.js.map +1 -1
  241. package/dist/tsconfig.tsbuildinfo +1 -1
  242. package/package.json +34 -14
  243. package/plugin/{css-collector-elements.tsx → components/css-collector-elements.tsx} +1 -1
  244. package/plugin/{css-collector.tsx → components/css-collector.tsx} +1 -1
  245. package/plugin/{html.tsx → components/html.tsx} +1 -3
  246. package/{dist/plugin/components.d.ts → plugin/components/index.ts} +1 -1
  247. package/plugin/config/autoDiscover/index.ts +10 -0
  248. package/plugin/config/{resolveAutoDiscover.ts → autoDiscover/resolveAutoDiscover.ts} +16 -12
  249. package/plugin/config/autoDiscover/resolveBuildPages.ts +10 -11
  250. package/plugin/config/defaults.tsx +4 -3
  251. package/plugin/config/index.ts +1 -1
  252. package/plugin/config/resolveEnv.ts +156 -6
  253. package/plugin/config/resolveOptions.ts +13 -5
  254. package/plugin/config/resolveUrlOption.ts +2 -7
  255. package/plugin/config/resolveUserConfig.ts +87 -36
  256. package/plugin/env/index.ts +1 -0
  257. package/plugin/env/plugin.ts +78 -0
  258. package/plugin/error/toError.ts +19 -0
  259. package/plugin/file-preserver/plugin.ts +117 -0
  260. package/plugin/helpers/createRscStream.tsx +1 -1
  261. package/plugin/helpers/formatMetrics.ts +2 -2
  262. package/plugin/helpers/getRouteFiles.ts +3 -1
  263. package/plugin/helpers/index.ts +38 -0
  264. package/plugin/helpers/requestInfo.ts +10 -0
  265. package/plugin/{resolvePage.ts → helpers/resolvePage.ts} +19 -4
  266. package/plugin/helpers/resolvePageAndProps.ts +7 -4
  267. package/plugin/{resolveProps.ts → helpers/resolveProps.ts} +8 -6
  268. package/plugin/helpers/serializeUserOptions.ts +1 -1
  269. package/plugin/helpers/tryManifest.ts +0 -1
  270. package/plugin/loader/createBuildLoader.ts +1 -1
  271. package/plugin/loader/env-loader.development.ts +84 -0
  272. package/plugin/plugin.client.ts +2 -0
  273. package/plugin/plugin.server.ts +3 -0
  274. package/plugin/plugin.ts +1 -3
  275. package/plugin/process-env.ts +13 -0
  276. package/plugin/react-client/createMessageHandlers.ts +13 -1
  277. package/plugin/react-client/createWorkerStream.ts +69 -15
  278. package/plugin/react-client/handleWorkerRscStream.ts +57 -0
  279. package/plugin/react-client/plugin.ts +29 -13
  280. package/plugin/react-client/restartWorker.ts +15 -7
  281. package/plugin/react-client/server.ts +115 -124
  282. package/plugin/react-server/plugin.ts +26 -13
  283. package/plugin/react-server/server.ts +33 -15
  284. package/plugin/react-static/collectHtmlWorkerContent.ts +13 -1
  285. package/plugin/react-static/fileWriter.ts +1 -1
  286. package/plugin/react-static/plugin.ts +21 -34
  287. package/plugin/root.ts +7 -1
  288. package/plugin/transformer/upgradeCssModuleCode.ts +39 -39
  289. package/plugin/types/env.d.ts +7 -0
  290. package/plugin/types.ts +68 -20
  291. package/plugin/utils/callServer.ts +2 -24
  292. package/plugin/utils/createCallServer.ts +26 -0
  293. package/plugin/utils/createReactFetcher.ts +10 -6
  294. package/plugin/utils/envUrls.node.ts +19 -0
  295. package/plugin/utils/envUrls.ts +8 -0
  296. package/plugin/utils/index.ts +1 -1
  297. package/plugin/utils/moduleBaseURL.ts +7 -0
  298. package/plugin/utils/urls.ts +217 -0
  299. package/plugin/vendor/index.ts +1 -0
  300. package/plugin/vendor/vendor.ts +6 -0
  301. package/plugin/worker/createWorker.ts +38 -22
  302. package/plugin/worker/html/createHtmlWorkerRenderState.tsx +1 -1
  303. package/plugin/worker/html/html-worker.development.tsx +2 -1
  304. package/plugin/worker/html/html-worker.production.tsx +2 -1
  305. package/plugin/worker/rsc/handleRender.ts +4 -5
  306. package/plugin/worker/rsc/messageHandler.tsx +53 -17
  307. package/plugin/worker/rsc/rsc-worker.development.ts +22 -8
  308. package/plugin/worker/rsc/rsc-worker.production.ts +23 -7
  309. package/plugin/worker/types.ts +28 -4
  310. package/dist/plugin/components.d.ts.map +0 -1
  311. package/dist/plugin/config/resolveAutoDiscover.d.ts.map +0 -1
  312. package/dist/plugin/config/resolveAutoDiscover.js.map +0 -1
  313. package/dist/plugin/copy.d.ts +0 -7
  314. package/dist/plugin/copy.d.ts.map +0 -1
  315. package/dist/plugin/copy.js +0 -30
  316. package/dist/plugin/css-collector-elements.d.ts.map +0 -1
  317. package/dist/plugin/css-collector-elements.js.map +0 -1
  318. package/dist/plugin/css-collector.d.ts.map +0 -1
  319. package/dist/plugin/css-collector.js.map +0 -1
  320. package/dist/plugin/getCondition.d.ts +0 -2
  321. package/dist/plugin/getCondition.d.ts.map +0 -1
  322. package/dist/plugin/html.d.ts +0 -4
  323. package/dist/plugin/html.d.ts.map +0 -1
  324. package/dist/plugin/html.js +0 -18
  325. package/dist/plugin/html.js.map +0 -1
  326. package/dist/plugin/manifest.d.ts +0 -6
  327. package/dist/plugin/manifest.d.ts.map +0 -1
  328. package/dist/plugin/manifest.js +0 -13
  329. package/dist/plugin/moduleRefs.d.ts.map +0 -1
  330. package/dist/plugin/moduleRefs.js.map +0 -1
  331. package/dist/plugin/resolvePage.d.ts.map +0 -1
  332. package/dist/plugin/resolvePage.js.map +0 -1
  333. package/dist/plugin/resolveProps.d.ts.map +0 -1
  334. package/dist/plugin/resolveProps.js.map +0 -1
  335. package/dist/plugin/utils/pageURL.d.ts +0 -5
  336. package/dist/plugin/utils/pageURL.d.ts.map +0 -1
  337. package/dist/plugin/utils/pageURL.js +0 -33
  338. package/dist/plugin/utils/pageURL.js.map +0 -1
  339. package/dist/plugin/vendor.client.d.ts.map +0 -1
  340. package/dist/plugin/vendor.client.js.map +0 -1
  341. package/dist/plugin/vendor.server.d.ts.map +0 -1
  342. package/dist/plugin/vendor.server.js.map +0 -1
  343. package/plugin/copy.ts +0 -39
  344. package/plugin/getCondition.ts +0 -0
  345. package/plugin/manifest.ts +0 -24
  346. package/plugin/utils/pageURL.ts +0 -33
  347. /package/dist/plugin/{css-collector-elements.js → components/css-collector-elements.js} +0 -0
  348. /package/dist/plugin/{css-collector.js → components/css-collector.js} +0 -0
  349. /package/{plugin/components.ts → dist/plugin/components/index.js} +0 -0
  350. /package/dist/plugin/{moduleRefs.d.ts → helpers/moduleRefs.d.ts} +0 -0
  351. /package/dist/plugin/{moduleRefs.js → helpers/moduleRefs.js} +0 -0
  352. /package/dist/plugin/{resolvePage.d.ts → helpers/resolvePage.d.ts} +0 -0
  353. /package/dist/plugin/{resolveProps.d.ts → helpers/resolveProps.d.ts} +0 -0
  354. /package/dist/plugin/{getCondition.js → process-env.js} +0 -0
  355. /package/dist/plugin/{vendor.client.d.ts → vendor/vendor.client.d.ts} +0 -0
  356. /package/dist/plugin/{vendor.client.js → vendor/vendor.client.js} +0 -0
  357. /package/dist/plugin/{vendor.server.d.ts → vendor/vendor.server.d.ts} +0 -0
  358. /package/dist/plugin/{vendor.server.js → vendor/vendor.server.js} +0 -0
  359. /package/plugin/{moduleRefs.ts → helpers/moduleRefs.ts} +0 -0
  360. /package/plugin/{vendor.client.ts → vendor/vendor.client.ts} +0 -0
  361. /package/plugin/{vendor.server.ts → vendor/vendor.server.ts} +0 -0
package/README.md CHANGED
@@ -5,7 +5,9 @@ A Vite plugin that enables React Server Components (RSC) streaming and static HT
5
5
  ## Example Projects
6
6
 
7
7
  - [The official demo](https://github.com/nicobrinkkemper/vite-plugin-react-server-demo-official)
8
+ - [Github Pages](https://nicobrinkkemper.github.io/vite-plugin-react-server-demo-official/)
8
9
  - [The mmcelebration.com project](https://github.com/nicobrinkkemper/mmc)
10
+ - [Github Pages](https://nicobrinkkemper.github.io/mmc/)
9
11
 
10
12
  ## Installation
11
13
 
@@ -15,7 +17,7 @@ npm install -D vite-plugin-react-server
15
17
 
16
18
  ## Open Source and Work in Progress
17
19
 
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:
20
+ 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:
19
21
 
20
22
  ```sh
21
23
  npm install -D patch-package react@experimental react-dom@experimental react-server-dom-esm
@@ -50,29 +52,163 @@ This ensures the patch is applied after every `npm install`. If errors arise rel
50
52
  This plugin uses environment detection to determine the execution context. It achieves this by checking the `NODE_OPTIONS` environment variable:
51
53
 
52
54
  ```typescript
53
- import { getCondition } from "vite-plugin-react-server"
55
+ import { getCondition } from "vite-plugin-react-server/config";
54
56
 
55
- if(getCondition() !== 'react-server'){
56
- throw new Error('-10 poision damage')
57
+ if (getCondition() !== "react-server") {
58
+ throw new Error("-10 poision damage");
57
59
  }
58
60
  ```
61
+
59
62
  Alternatively, you can pass the argument for the `react-` prefix to just get client or server back.
60
63
 
61
64
  ```typescript
62
- import { getCondition } from "vite-plugin-react-server"
65
+ import { getCondition } from "vite-plugin-react-server/config";
63
66
 
64
- import(`plugin.${getCondition('')}.js`)
67
+ import(`plugin.${getCondition("")}.js`);
65
68
  ```
66
69
 
67
70
  The main entry point adapts based on the environment:
68
71
 
69
72
  - **Client Mode** (default) → Does not require the react-server condition, uses a worker thread for RSC requests
73
+ Benefits:
74
+ - log errors to console
75
+ - onMetric event for each page
76
+ - worker thread
70
77
  - **Server Mode** (`NODE_OPTIONS="--conditions react-server"`) → Does not need worker thread for RSC requests
78
+ - Direct pipeline from vite to react
71
79
 
72
80
  ### Custom composition
73
81
 
74
82
  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.
75
83
 
84
+ ### Page & prop setup
85
+
86
+ The minimal config is
87
+
88
+ ```tsx
89
+ // vite.config.tsx
90
+ import type { StreamPluginOptions } from "vite-plugin-react-server/types";
91
+ import { join } from "node:path";
92
+ import { defineConfig } from "vite";
93
+ import { vitePluginReactServer } from "vite-plugin-react-server";
94
+ import { config } from "./vite.react.config.js";
95
+
96
+ export default defineConfig(() => {
97
+ return {
98
+ plugins: vitePluginReactServer({
99
+ moduleBase: "src",
100
+ Page: "src/page.tsx",
101
+ }),
102
+ };
103
+ });
104
+ ```
105
+
106
+ And our Page file.
107
+
108
+ ```tsx
109
+ // src/page.tsx
110
+ import React from "react";
111
+ export function Page({ url }) {
112
+ return <div>You are on {url}</div>;
113
+ }
114
+ ```
115
+
116
+ Of course we need a client file as well, and the vite index.html pointing to it,
117
+
118
+ ```tsx
119
+ import React, { use } from "react";
120
+ import { createRoot } from "react-dom/client";
121
+ import { createReactFetcher } from "vite-plugin-react-server/utils";
122
+ // src/client.tsx
123
+ const Shell: React.FC<{
124
+ data: React.Usable<React.ReactNode>;
125
+ }> = ({ data: initialServerData }) => {
126
+ const content = use(initialServerData);
127
+ return content as React.ReactNode;
128
+ };
129
+ // Initialize the app
130
+ const rootElement = document.getElementById("root");
131
+ if (!rootElement) throw new Error("Root element not found");
132
+
133
+ const intitalData = createReactFetcher();
134
+
135
+ createRoot(rootElement).render(<Shell data={intitalData} />);
136
+ ```
137
+
138
+ index.html for completeness sake
139
+
140
+ ```html
141
+ <!DOCTYPE html>
142
+ <html lang="en">
143
+ <head>
144
+ <meta charset="utf-8" />
145
+ <body>
146
+ <div id="root"></div>
147
+ <script type="module" src="/src/client.tsx"></script>
148
+ </body>
149
+ </html>
150
+ ```
151
+
152
+ By default, without any prop configurations, the Page receives a normalized url.
153
+
154
+ With custom "get prop" function, we can enrich the props with more information.
155
+
156
+ ```tsx
157
+ import React from "react";
158
+
159
+ export const props = (url) => ({ title: "Hello World", file: import.meta.url, url });
160
+
161
+ export type Props = ReturnType<typeof props>
162
+
163
+ export function Page({ file, title, url }: Props) {
164
+ return <>
165
+ <title>{title}<title>
166
+ <div>This file is here: {file}</div>;
167
+ <div>You are on: {url}</div>;
168
+ </>
169
+ }
170
+ ```
171
+
172
+ You can also define a router specifically for the props file.
173
+
174
+ ```tsx
175
+ {
176
+ moduleBase: "src",
177
+ Page: "src/page.tsx",
178
+ // define the props router
179
+ props: "src/props.ts",
180
+ }
181
+ ```
182
+
183
+ Move prop lines from `src/page.tsx` to `src/props.ts`
184
+
185
+ ```tsx
186
+ export const props = (url) => ({
187
+ title: "Hello World",
188
+ file: import.meta.url,
189
+ url,
190
+ });
191
+
192
+ export type Props = ReturnType<typeof props>;
193
+ ```
194
+
195
+ We can also make a static build for these pages, which will render them to index.html and headless index.rsc files, which can be used to make a static RSC site.
196
+
197
+ ```tsx
198
+ {
199
+ moduleBase: "src",
200
+ Page: "src/page.tsx",
201
+ props: "src/props.ts"
202
+ // define the routes we want to render
203
+ build: [
204
+ pages: ['/', '/404']
205
+ ]
206
+ };
207
+ ```
208
+
209
+ And that's how you can work with react server components using a familiar vite workflow.
210
+ If your app grows and you need more control, see the [docs](./docs) - check out the source code - and have fun building.
211
+
76
212
  ### Worker support
77
213
 
78
214
  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 plugin without the `react-server` condition. If you don't want to use the `html-worker` simply don't configure the `build.pages` option.
@@ -83,9 +219,6 @@ Both workers can be customized using the `htmlWorkerPath` and `rscWorkerPath` re
83
219
 
84
220
  Keep in mind that, using your custom worker means interacting with the message system of this plugin during development/static generation process.
85
221
 
86
- For more information on creating your custom workers, see [docs](/docs)
87
-
88
-
89
222
  ## Plugin Usage
90
223
 
91
224
  ```ts
@@ -96,17 +229,13 @@ import type { StreamPluginOptions } from "vite-plugin-react-server/server";
96
229
 
97
230
  const createRouter = (file: "props.ts" | "page.tsx") => (url: string) => {
98
231
  switch (url) {
232
+ case "/":
233
+ return `src/page/${file}`;
99
234
  case "/bidoof":
100
- case "/bidoof/index.rsc":
101
235
  return `src/page/bidoof/${file}`;
102
236
  case "/404":
103
- case "/404/index.rsc":
104
- return `src/page/404/${file}`;
105
- case "/":
106
- case "/index.rsc":
107
- return `src/page/${file}`;
108
237
  default:
109
- throw new Error(`Unknown route: ${url}`);
238
+ return `src/page/404/${file}`;
110
239
  }
111
240
  };
112
241
 
@@ -116,7 +245,7 @@ export const config = {
116
245
  props: createRouter("props.ts"),
117
246
  Html: Html,
118
247
  build: {
119
- pages: ["/", "/bidoof", "/404" ],
248
+ pages: ["/", "/bidoof", "/404"],
120
249
  },
121
250
  } satisfies StreamPluginOptions;
122
251
 
@@ -125,34 +254,52 @@ export default defineConfig({
125
254
  });
126
255
  ```
127
256
 
257
+ This will mirror your directory structure for new static routes. If you need to handle
258
+ dynamic requests, like pointing /:theme/ to a certain folder, you need to parse this yourself
259
+ using code.
260
+
261
+ ### Async build pages
262
+
263
+ If you have a large amount of pages that needs async operations to fetch, you can pass a async function to build pages.
264
+
265
+ ```tsx
266
+ build:{
267
+ pages: async ()=>await import('my-pages')
268
+ }
269
+ ```
128
270
  ### Built-in React Server Components
129
271
 
130
- This plugin has two built-in React Component, each can be configured through the options to be your own component. Defining your custom React server components will affect the final production output, they won't be used during development.
131
- - Html - used as the wrapper for production pages (use vite's `index.html` for the development wrapper and entry point for client files)
272
+ This plugin built-in React Component that can be configured through the options to be your own component. Direct server component config inputs are not yet supported through worker threads.
273
+
274
+ - Html - used as the wrapper for production pages (use vite's `index.html` for the development wrapper and entry point for client files & global css)
132
275
  - CssCollector - used to emit `<link>` and `<style>` tags based on `css` config
133
276
 
277
+ Defining your custom Html React server component will affect the final production output.
278
+
134
279
  #### Build Steps
135
280
 
136
281
  ```sh
137
282
  vite build
138
283
  ```
284
+
139
285
  Targets browsers, outputs to `dist/static`.
140
286
 
141
287
  ```sh
142
288
  vite build --ssr
143
289
  ```
290
+
144
291
  Targets non-`react-server` node environment, used for server-side-rendering, outputs to `dist/client`.
145
292
 
146
293
  ```sh
147
294
  NODE_OPTIONS="--conditions=react-server" vite build
148
295
  ```
296
+
149
297
  Targets `react-server`-only environment, outputs to `dist/server`. In this case, `ssr` is implied and defaults to true.
150
298
 
151
299
  ---
152
300
 
153
301
  ### vite-plugin-react-server
154
302
 
155
-
156
303
  ```ts
157
304
  import { defineConfig, Plugin } from "vite";
158
305
  import { vitePluginReactServer } from "vite-plugin-react-server";
@@ -168,17 +315,21 @@ export default defineConfig({
168
315
  ```sh
169
316
  NODE_OPTIONS="--conditions=react-server" vite
170
317
  ```
171
- Is the recommended way for a more direct server pipeline that doesn't require a `rsc-worker`.
318
+
319
+ A direct server pipeline that doesn't require a `rsc-worker`.
172
320
 
173
321
  To develop the app using the `rsc-worker`, simply run
322
+
174
323
  ```sh
175
324
  vite
176
325
  ```
177
- without the `react-server` condition.
326
+
327
+ without the `react-server` condition. This will work a little bit differently under the hood, it can provide additional development support like error logging, metric events and custom rsc worker development.
178
328
 
179
329
  ## Static Site Generation
180
330
 
181
331
  Single-out the static generation step by only inluding the static plugin. Expects client and server folders to be there.
332
+
182
333
  ```ts
183
334
  import { defineConfig, Plugin } from "vite";
184
335
  import { reactStaticPlugin } from "vite-plugin-react-server/static";
@@ -209,43 +360,57 @@ This plugin is included by default when the `react-server` condition is set.
209
360
  ```ts
210
361
  const config = {
211
362
  moduleBase: "src",
212
- }
363
+ };
213
364
  ```
365
+
214
366
  Defines the root directory for project modules. This can be customized.
215
367
 
216
368
  ### moduleBasePath
217
369
 
218
370
  ```ts
219
- moduleBasePath: "",
371
+ moduleBasePath: "/",
220
372
  ```
373
+
221
374
  Passed as the second argument to `renderToPipeableStream` for server-side rendering.
222
375
 
223
376
  ### moduleBaseURL
224
377
 
225
378
  ```ts
226
- moduleBaseURL: "https://github.com/my-gh-pages",
379
+ moduleBaseURL: "/",
227
380
  ```
381
+
228
382
  Defines asset URL resolution for CSS collectors and bootstrapModule.
229
383
 
384
+ ```ts
385
+ publicOrigin: "https://github.com",
386
+ ```
387
+
230
388
  ### Page and props Mapping
231
389
 
232
390
  ```ts
233
- Page: (id) => join(id.replace('index.rsc',''), 'page.tsx')
391
+ Page: (id) => join(id.replace("index.rsc", ""), "page.tsx");
234
392
  ```
393
+
235
394
  Defines how pages are mapped to file paths.
395
+
236
396
  ```ts
237
- props: (id) => join(id.replace('index.rsc',''), 'props.ts')
397
+ props: (id) => join(id.replace("index.rsc", ""), "props.ts");
238
398
  ```
399
+
239
400
  Defines how to load the initial props of the page file.
240
401
 
241
402
  If you do not want prop files, just don't define it.
403
+
242
404
  ```ts
243
405
  pageExportName: 'Page',
244
406
  ```
407
+
245
408
  Changes the default name "Page"
409
+
246
410
  ```ts
247
411
  propsExportName: 'props',
248
412
  ```
413
+
249
414
  Changes the default name "props"
250
415
 
251
416
  ---
@@ -272,15 +437,31 @@ Changes the default name "props"
272
437
  export const Page = ({ name }) => {
273
438
  return <div>Hello {name}</div>;
274
439
  };
440
+ // src/async-page.tsx
441
+ export const Page = async ({ name }) => {
442
+ return <div>Hello {name}</div>;
443
+ };
275
444
  ```
276
445
 
277
446
  ### Sample Props File
278
447
 
448
+ All of the below are valid
449
+
279
450
  ```ts
280
451
  // src/my-props.ts
281
452
  export const props = {
282
453
  name: "John Doe",
283
454
  };
455
+ export const props = (url)=>{
456
+ name: "John Doe",
457
+ };
458
+ export const props = async (url)=>{
459
+ name: "John Doe",
460
+ }
461
+ // enum bonus
462
+ export const props = ['key']; // -> {key: "key"}
463
+ // Object.fromEntries()
464
+ export const props = [['key',{value: 'some value'}]]
284
465
  ```
285
466
 
286
467
  ## Contributions
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-react-server",
3
- "version": "1.1.10",
3
+ "version": "1.1.12",
4
4
  "description": "Vite plugin for React Server Components (RSC)",
5
5
  "type": "module",
6
6
  "main": "./dist/plugin/index.js",
@@ -25,10 +25,14 @@
25
25
  "./package.json": "./package.json",
26
26
  "./patch": "./scripts/patch.mjs",
27
27
  "./check-react-version": "./scripts/check-react-version.mjs",
28
- "./components": "./dist/plugin/components.js",
28
+ "./components": "./dist/plugin/components/index.js",
29
29
  "./types": "./dist/plugin/types.js",
30
30
  "./utils": "./dist/plugin/utils/index.js",
31
- "./metrics": "./dist/plugin/metrics/index.js"
31
+ "./metrics": "./dist/plugin/metrics/index.js",
32
+ "./env": "./dist/plugin/env/plugin.js",
33
+ "./config": "./dist/plugin/config/index.js",
34
+ "./vendor": "./dist/plugin/vendor/index.js",
35
+ "./file-preserver": "./dist/plugin/file-preserver/plugin.js"
32
36
  },
33
37
  "typesVersions": {
34
38
  "*": {
@@ -48,13 +52,25 @@
48
52
  "./dist/plugin/worker/worker.d.ts"
49
53
  ],
50
54
  "components": [
51
- "./dist/plugin/components.d.ts"
55
+ "./dist/plugin/components/index.d.ts"
52
56
  ],
53
57
  "utils": [
54
58
  "./dist/plugin/utils/index.d.ts"
55
59
  ],
56
60
  "metrics": [
57
61
  "./dist/plugin/metrics/index.d.ts"
62
+ ],
63
+ "config": [
64
+ "./dist/plugin/config/index.d.ts"
65
+ ],
66
+ "env": [
67
+ "./dist/plugin/env/plugin.d.ts"
68
+ ],
69
+ "vendor": [
70
+ "./dist/plugin/vendor/index.d.ts"
71
+ ],
72
+ "file-preserver": [
73
+ "./dist/plugin/file-preserver/plugin.d.ts"
58
74
  ]
59
75
  }
60
76
  },
@@ -70,18 +86,22 @@
70
86
  "prepublishOnly": "npm run build",
71
87
  "lint": "eslint ./src --fix",
72
88
  "setup:test-fixtures": "npx tsx test/setup.ts",
73
- "test:server": "npm run setup:test-fixtures && NODE_OPTIONS='--conditions react-server' vitest run",
74
- "test:client": "npm run setup:test-fixtures && vitest run",
89
+ "test:server": "NODE_ENV=development NODE_OPTIONS='--conditions react-server' vitest run test/server",
90
+ "test:client": "NODE_ENV=development vitest run test/client",
75
91
  "test:build": "npm run setup:test-fixtures && npm test test/server/build.test.ts",
92
+ "test:unit": "vitest run test/unit",
76
93
  "test:llm": "rm -f build.log && npm run test:build 2>&1 | tee build.log",
77
- "test:streams": "npm run build && npm run setup:test-fixtures && NODE_OPTIONS='--conditions react-server' vitest run test/server/renderStreams.test.ts -no-watch",
78
- "test:renders": "npm run build && npm run setup:test-fixtures && NODE_OPTIONS='--conditions react-server' vitest run test/server/renderPages.test.ts -no-watch",
79
- "test:html-worker": "npm run build && npm run setup:test-fixtures && NODE_OPTIONS='--conditions react-server' vitest run test/server/rscToHtmlStream.test.ts -no-watch",
80
- "test:large-html": "npm run build && npm run setup:test-fixtures && NODE_OPTIONS='--conditions react-server' vitest run test/server/large-html.test.ts --reporter=verbose -no-watch",
81
- "test:metrics": "npm run build && npm run setup:test-fixtures && NODE_OPTIONS='--conditions react-server' vitest run test/server/metrics.test.ts --reporter=verbose -no-watch",
82
- "test:hooks": "npm run build && npm run setup:test-fixtures && NODE_OPTIONS='--conditions react-server' vitest run test/server/hooks.test.ts --reporter=verbose -no-watch",
83
- "test:inline-css": "npm run build && npm run setup:test-fixtures && NODE_OPTIONS='--conditions react-server' vitest run test/server/inline-css.test.ts --reporter=verbose -no-watch",
84
- "test": "npm run build && npm run setup:test-fixtures && npm run test:client && NODE_ENV=development npm run test:server",
94
+ "test:streams": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/renderStreams.test.ts",
95
+ "test:renders": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/renderPages.test.ts",
96
+ "test:html-worker": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/rscToHtmlStream.test.ts",
97
+ "test:large-html": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/large-html.test.ts --reporter=verbose",
98
+ "test:metrics": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/metrics.test.ts --reporter=verbose",
99
+ "test:hooks": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/hooks.test.ts --reporter=verbose",
100
+ "test:inline-css": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/inline-css.test.ts --reporter=verbose",
101
+ "test:dev-server-env": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/dev-server-env.test.ts --reporter=verbose",
102
+ "test:rsc-server": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/rsc-server.test.ts --reporter=verbose",
103
+ "test:client-env": "npm run build && vitest run test/client/dev-client-server-env.test.ts --reporter=verbose",
104
+ "test": "npm run build && npm run test:server && npm run test:client && npm run test:unit",
85
105
  "test:coverage": "npm run setup:test-fixtures && vitest run --coverage",
86
106
  "test:ui": "npm run setup:test-fixtures && vitest --ui",
87
107
  "experimental:clean-install": "npm install react-server-dom-esm react@experimental react-dom@experimental react-server-dom-esm --save-peer",
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
- import type { CssCollectorProps } from "./types.js";
2
+ import type { CssCollectorProps } from "../types.js";
3
3
  export declare const CssCollectorElements: ({ cssFiles, }: Pick<CssCollectorProps, "cssFiles">) => React.JSX.Element[];
4
4
  //# sourceMappingURL=css-collector-elements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-collector-elements.d.ts","sourceRoot":"","sources":["../../../plugin/components/css-collector-elements.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAc,MAAM,aAAa,CAAC;AAGjE,eAAO,MAAM,oBAAoB,kBAE9B,IAAI,CACL,iBAAiB,EACjB,UAAU,CACX,wBAWG,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-collector-elements.js","sources":["../../../plugin/components/css-collector-elements.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CssCollectorProps, CssContent } from \"../types.js\";\n\n// Create link elements for each CSS file\nexport const CssCollectorElements = ({\n cssFiles,\n}: Pick<\n CssCollectorProps,\n \"cssFiles\"\n>) =>\n Array.from(cssFiles?.values() ?? []).map((cssFile: CssContent) => {\n // Emit style tag for inline CSS\n const { as: As, id, children, precedence, type, ...rest } = cssFile;\n if(As !== \"link\" && (typeof children === \"string\" || React.isValidElement(children))) {\n // style tag\n // since we can't bubble up the style tags, we need to be creative\n return <As {...rest} type={type ?? \"text/css\"} key={cssFile.id}>{children}</As>;\n }\n // link tag\n return <As {...rest} key={cssFile.id} precedence={precedence} />;\n });\n"],"names":["React"],"mappings":";;;;;;;AAIO,MAAM,uBAAuB,CAAC;AAAA,EACnC;AACF,CAIE,KAAA,KAAA,CAAM,IAAK,CAAA,QAAA,EAAU,MAAO,EAAA,IAAK,EAAE,CAAA,CAAE,GAAI,CAAA,CAAC,OAAwB,KAAA;AAEhE,EAAM,MAAA,EAAE,IAAI,EAAI,EAAA,EAAA,EAAI,UAAU,UAAY,EAAA,IAAA,EAAM,GAAG,IAAA,EAAS,GAAA,OAAA;AAC5D,EAAG,IAAA,EAAA,KAAO,WAAW,OAAO,QAAA,KAAa,YAAYA,cAAM,CAAA,cAAA,CAAe,QAAQ,CAAI,CAAA,EAAA;AAGpF,IAAO,uBAAAA,cAAA,CAAA,aAAA,CAAC,EAAI,EAAA,EAAA,GAAG,IAAM,EAAA,IAAA,EAAM,QAAQ,UAAY,EAAA,GAAA,EAAK,OAAQ,CAAA,EAAA,EAAA,EAAK,QAAS,CAAA;AAAA;AAG5E,EAAA,oDAAQ,EAAI,EAAA,EAAA,GAAG,MAAM,GAAK,EAAA,OAAA,CAAQ,IAAI,UAAwB,EAAA,CAAA;AAChE,CAAC;;;;"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import type { CssCollectorProps } from "./types.js";
2
+ import type { CssCollectorProps } from "../types.js";
3
3
  /**
4
4
  * A component that emits <link> tags for CSS files during streaming.
5
5
  * The high precedence ensures they bubble up to the document head.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-collector.d.ts","sourceRoot":"","sources":["../../../plugin/components/css-collector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAe,EACf,QAAoB,EACpB,EAAE,EAAE,EAAmB,EACvB,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC,qBAezD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-collector.js","sources":["../../../plugin/components/css-collector.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CssCollectorProps } from \"../types.js\";\nimport { CssCollectorElements } from \"./css-collector-elements.js\";\n\n/**\n * A component that emits <link> tags for CSS files during streaming.\n * The high precedence ensures they bubble up to the document head.\n */\nexport function CssCollector({\n children = null,\n cssFiles = new Map(),\n as: As = React.Fragment,\n ...props\n}: Pick<CssCollectorProps, \"children\" | \"cssFiles\" | \"as\">) {\n if (As === React.Fragment) {\n return (\n <>\n {children}\n <CssCollectorElements cssFiles={cssFiles} />\n </>\n );\n }\n return (\n <As {...props}>\n {children}\n <CssCollectorElements cssFiles={cssFiles} />\n </As>\n );\n}\n"],"names":["React"],"mappings":";;;;;;;;AAQO,SAAS,YAAa,CAAA;AAAA,EAC3B,QAAW,GAAA,IAAA;AAAA,EACX,QAAA,uBAAe,GAAI,EAAA;AAAA,EACnB,EAAA,EAAI,KAAKA,cAAM,CAAA,QAAA;AAAA,EACf,GAAG;AACL,CAA4D,EAAA;AAC1D,EAAI,IAAA,EAAA,KAAOA,eAAM,QAAU,EAAA;AACzB,IAAA,uBAEKA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA,EAAA,QAAA,kBACAA,cAAA,CAAA,aAAA,CAAA,oBAAA,EAAA,EAAqB,UAAoB,CAC5C,CAAA;AAAA;AAGJ,EACE,uBAAAA,cAAA,CAAA,aAAA,CAAC,MAAI,GAAG,KAAA,EAAA,EACL,0BACAA,cAAA,CAAA,aAAA,CAAA,oBAAA,EAAA,EAAqB,UAAoB,CAC5C,CAAA;AAEJ;;;;"}
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { HtmlProps } from "../types.js";
3
+ export declare const Html: ({ children, CssCollector, cssFiles, globalCss, }: React.PropsWithChildren<HtmlProps>) => React.JSX.Element;
4
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../plugin/components/html.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,IAAI,qDAKd,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,sBAWpC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * vite-plugin-react-server
3
+ * Copyright (c) Nico Brinkkemper
4
+ * MIT License
5
+ */
6
+ import React__default from 'react';
7
+ import { CssCollectorElements } from './css-collector-elements.js';
8
+
9
+ const Html = ({
10
+ children,
11
+ CssCollector,
12
+ cssFiles,
13
+ globalCss
14
+ }) => /* @__PURE__ */ React__default.createElement("html", null, /* @__PURE__ */ React__default.createElement("head", null, /* @__PURE__ */ React__default.createElement(CssCollectorElements, { cssFiles: globalCss })), /* @__PURE__ */ React__default.createElement("body", null, /* @__PURE__ */ React__default.createElement(CssCollector, { as: "div", id: "root", cssFiles }, children)));
15
+
16
+ export { Html };
17
+ //# sourceMappingURL=html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.js","sources":["../../../plugin/components/html.tsx"],"sourcesContent":["import React from \"react\";\nimport type { HtmlProps } from \"../types.js\";\nimport { CssCollectorElements } from \"./css-collector-elements.js\";\nexport const Html = ({\n children,\n CssCollector,\n cssFiles,\n globalCss,\n}: React.PropsWithChildren<HtmlProps>) => (\n <html>\n <head>\n <CssCollectorElements cssFiles={globalCss} />\n </head>\n <body>\n <CssCollector as={\"div\"} id=\"root\" cssFiles={cssFiles}>\n {children}\n </CssCollector>\n </body>\n </html>\n);\n"],"names":["React"],"mappings":";;;;;;;;AAGO,MAAM,OAAO,CAAC;AAAA,EACnB,QAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CACE,qBAAAA,cAAA,CAAA,aAAA,CAAC,8BACEA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,+CACE,oBAAqB,EAAA,EAAA,QAAA,EAAU,WAAW,CAC7C,CAAA,+CACC,MACC,EAAA,IAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,gBAAa,EAAI,EAAA,KAAA,EAAO,IAAG,MAAO,EAAA,QAAA,EAAA,EAChC,QACH,CACF,CACF;;;;"}
@@ -0,0 +1,5 @@
1
+ export { Html } from "./html.js";
2
+ export { CssCollector } from "./css-collector.js";
3
+ export { CssCollectorElements } from "./css-collector-elements.js";
4
+ export type { HtmlProps, CssCollectorProps, CssCollectorElementsProps } from "../types.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugin/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC"}
@@ -1,3 +1,9 @@
1
- export { Html } from "./html.js";
2
- export { CssCollector } from "./css-collector.js";
3
- export { CssCollectorElements } from "./css-collector-elements.js";
1
+ /**
2
+ * vite-plugin-react-server
3
+ * Copyright (c) Nico Brinkkemper
4
+ * MIT License
5
+ */
6
+ export { Html } from './components/html.js';
7
+ export { CssCollector } from './components/css-collector.js';
8
+ export { CssCollectorElements } from './components/css-collector-elements.js';
9
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,6 @@
1
+ export * from "./resolveAutoDiscover.js";
2
+ export * from "./resolveBuildPages.js";
3
+ export * from "./customWorkerFiles.js";
4
+ export * from "./pageAndPropFiles.js";
5
+ export * from "./createGlobAutoDiscover.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../plugin/config/autoDiscover/index.ts"],"names":[],"mappings":"AACA,cAAc,0BAA0B,CAAC;AAGzC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,8 @@
1
+ // Main auto-discovery resolver
2
+ export * from "./resolveAutoDiscover.js";
3
+ // Build page resolution
4
+ export * from "./resolveBuildPages.js";
5
+ // File discovery utilities
6
+ export * from "./customWorkerFiles.js";
7
+ export * from "./pageAndPropFiles.js";
8
+ export * from "./createGlobAutoDiscover.js";
@@ -1,5 +1,5 @@
1
1
  import type { ConfigEnv, UserConfig } from "vite";
2
- import type { ResolvedUserOptions, AutoDiscoveredFiles } from "../types.js";
2
+ import type { ResolvedUserOptions, AutoDiscoveredFiles } from "../../types.js";
3
3
  type ResolveAutoDiscoverProps = {
4
4
  config: UserConfig;
5
5
  configEnv: ConfigEnv;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveAutoDiscover.d.ts","sourceRoot":"","sources":["../../../../plugin/config/autoDiscover/resolveAutoDiscover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAe/E,KAAK,wBAAwB,GAAG;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,mBAAmB,CAAC;IACjC,SAAS,EAAE,cAAc,GAAG,cAAc,CAAC;CAC5C,CAAC;AAEF,KAAK,yBAAyB,GAC1B;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB,CAAC,EAAE,KAAK,CAAC;CAC7B,CAAC;AAEN,wBAAsB,mBAAmB,CAAC,EACxC,MAAM,EACN,SAAS,EACT,WAAW,EACX,SAAS,GACV,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAqI/D"}
@@ -4,12 +4,12 @@
4
4
  * MIT License
5
5
  */
6
6
  import { join } from 'path';
7
- import { resolveBuildPages } from './autoDiscover/resolveBuildPages.js';
8
- import { resolvePages } from './resolvePages.js';
9
- import { tryManifest } from '../helpers/tryManifest.js';
10
- import { createGlobAutoDiscover } from './autoDiscover/createGlobAutoDiscover.js';
11
- import { customWorkerFiles } from './autoDiscover/customWorkerFiles.js';
12
- import { pageAndPropFiles } from './autoDiscover/pageAndPropFiles.js';
7
+ import { resolveBuildPages } from './resolveBuildPages.js';
8
+ import { resolvePages } from '../resolvePages.js';
9
+ import { tryManifest } from '../../helpers/tryManifest.js';
10
+ import { createGlobAutoDiscover } from './createGlobAutoDiscover.js';
11
+ import { customWorkerFiles } from './customWorkerFiles.js';
12
+ import { pageAndPropFiles } from './pageAndPropFiles.js';
13
13
 
14
14
  const clientFiles = createGlobAutoDiscover("**/*.client.*");
15
15
  const serverFiles = createGlobAutoDiscover("**/*.server.*");
@@ -58,9 +58,10 @@ async function resolveAutoDiscover({
58
58
  });
59
59
  if (staticManifestResult.type === "success") {
60
60
  staticManifest = staticManifestResult.manifest;
61
- } else {
62
- console.warn("Error getting static manifest", staticManifestResult.error);
63
- console.warn("Build may be out of date");
61
+ } else if (configEnv.command === "build") {
62
+ console.error(staticManifestResult.error);
63
+ console.warn("Continuing without static manifest");
64
+ staticManifest = {};
64
65
  }
65
66
  }
66
67
  const customWorkerInputs = customWorkerFiles({