vite-plugin-react-server 1.1.12 → 1.1.13

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 (373) hide show
  1. package/dist/package.json +10 -8
  2. package/dist/plugin/components/css-collector-elements.d.ts +4 -2
  3. package/dist/plugin/components/css-collector-elements.d.ts.map +1 -1
  4. package/dist/plugin/components/css-collector-elements.js +21 -7
  5. package/dist/plugin/components/css-collector-elements.js.map +1 -1
  6. package/dist/plugin/components/css-collector.d.ts +4 -5
  7. package/dist/plugin/components/css-collector.d.ts.map +1 -1
  8. package/dist/plugin/components/css-collector.js +5 -9
  9. package/dist/plugin/components/css-collector.js.map +1 -1
  10. package/dist/plugin/components/html.d.ts +1 -1
  11. package/dist/plugin/components/html.d.ts.map +1 -1
  12. package/dist/plugin/components/html.js +14 -3
  13. package/dist/plugin/components/html.js.map +1 -1
  14. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts +4 -4
  15. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -1
  16. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js +14 -9
  17. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +1 -1
  18. package/dist/plugin/config/defaults.d.ts +66 -12
  19. package/dist/plugin/config/defaults.d.ts.map +1 -1
  20. package/dist/plugin/config/defaults.js +69 -15
  21. package/dist/plugin/config/defaults.js.map +1 -1
  22. package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts +5 -0
  23. package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts.map +1 -0
  24. package/dist/plugin/config/resolveAutoDiscoverMatcher.js +25 -0
  25. package/dist/plugin/config/resolveAutoDiscoverMatcher.js.map +1 -0
  26. package/dist/plugin/config/resolveEnv.d.ts.map +1 -1
  27. package/dist/plugin/config/resolveEnv.js +16 -5
  28. package/dist/plugin/config/resolveEnv.js.map +1 -1
  29. package/dist/plugin/config/resolveOptions.d.ts +3 -3
  30. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  31. package/dist/plugin/config/resolveOptions.js +59 -87
  32. package/dist/plugin/config/resolveOptions.js.map +1 -1
  33. package/dist/plugin/config/resolveUserConfig.d.ts +4 -4
  34. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  35. package/dist/plugin/config/resolveUserConfig.js +8 -1
  36. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  37. package/dist/plugin/error/toError.d.ts +3 -0
  38. package/dist/plugin/error/toError.d.ts.map +1 -1
  39. package/dist/plugin/error/toError.js +33 -4
  40. package/dist/plugin/error/toError.js.map +1 -1
  41. package/dist/plugin/helpers/cleanObject.d.ts.map +1 -1
  42. package/dist/plugin/helpers/cleanObject.js +19 -5
  43. package/dist/plugin/helpers/cleanObject.js.map +1 -1
  44. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +3 -3
  45. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
  46. package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -1
  47. package/dist/plugin/helpers/createCssProps.d.ts +4 -3
  48. package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
  49. package/dist/plugin/helpers/createCssProps.js +7 -2
  50. package/dist/plugin/helpers/createCssProps.js.map +1 -1
  51. package/dist/plugin/helpers/createHandler.d.ts +4 -3
  52. package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
  53. package/dist/plugin/helpers/createHandler.js +1 -1
  54. package/dist/plugin/helpers/createHandler.js.map +1 -1
  55. package/dist/plugin/helpers/createRscStream.d.ts +2 -2
  56. package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
  57. package/dist/plugin/helpers/createRscStream.js +15 -5
  58. package/dist/plugin/helpers/createRscStream.js.map +1 -1
  59. package/dist/plugin/helpers/index.d.ts +2 -2
  60. package/dist/plugin/helpers/index.d.ts.map +1 -1
  61. package/dist/plugin/helpers/index.js +2 -2
  62. package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
  63. package/dist/plugin/helpers/inputNormalizer.js +4 -1
  64. package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
  65. package/dist/plugin/helpers/moduleResolver.d.ts +3 -0
  66. package/dist/plugin/helpers/moduleResolver.d.ts.map +1 -0
  67. package/dist/plugin/helpers/moduleResolver.js +25 -0
  68. package/dist/plugin/helpers/requestInfo.d.ts +18 -3
  69. package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
  70. package/dist/plugin/helpers/requestInfo.js +75 -11
  71. package/dist/plugin/helpers/requestInfo.js.map +1 -1
  72. package/dist/plugin/helpers/resolvePage.d.ts.map +1 -1
  73. package/dist/plugin/helpers/resolvePage.js +2 -3
  74. package/dist/plugin/helpers/resolvePage.js.map +1 -1
  75. package/dist/plugin/helpers/resolvePageAndProps.d.ts +4 -3
  76. package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
  77. package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -1
  78. package/dist/plugin/helpers/serializeUserOptions.d.ts +3 -2
  79. package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -1
  80. package/dist/plugin/helpers/serializeUserOptions.js +13 -1
  81. package/dist/plugin/helpers/serializeUserOptions.js.map +1 -1
  82. package/dist/plugin/helpers/sourceMap.d.ts +8 -0
  83. package/dist/plugin/helpers/sourceMap.d.ts.map +1 -0
  84. package/dist/plugin/helpers/sourceMap.js +136 -0
  85. package/dist/plugin/helpers.js +1 -1
  86. package/dist/plugin/loader/createBuildLoader.d.ts +7 -22
  87. package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
  88. package/dist/plugin/loader/createBuildLoader.js +79 -65
  89. package/dist/plugin/loader/createBuildLoader.js.map +1 -1
  90. package/dist/plugin/loader/createDefaultLoader.d.ts +13 -0
  91. package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -0
  92. package/dist/plugin/loader/createDefaultLoader.js +47 -0
  93. package/dist/plugin/loader/css-loader.development.d.ts +1 -0
  94. package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
  95. package/dist/plugin/loader/css-loader.development.js +1 -1
  96. package/dist/plugin/loader/css-loader.development.js.map +1 -1
  97. package/dist/plugin/loader/handleExports.d.ts +33 -0
  98. package/dist/plugin/loader/handleExports.d.ts.map +1 -0
  99. package/dist/plugin/loader/handleExports.js +174 -0
  100. package/dist/plugin/loader/handleExports.js.map +1 -0
  101. package/dist/plugin/loader/index.d.ts +1 -1
  102. package/dist/plugin/loader/index.d.ts.map +1 -1
  103. package/dist/plugin/loader/index.js +4 -1
  104. package/dist/plugin/loader/parse.d.ts +6 -0
  105. package/dist/plugin/loader/parse.d.ts.map +1 -0
  106. package/dist/plugin/loader/parse.js +23 -0
  107. package/dist/plugin/loader/parse.js.map +1 -0
  108. package/dist/plugin/loader/react-loader.client.d.ts +2 -0
  109. package/dist/plugin/loader/react-loader.client.d.ts.map +1 -0
  110. package/dist/plugin/loader/react-loader.client.js +2 -0
  111. package/dist/plugin/loader/react-loader.d.ts +1 -12
  112. package/dist/plugin/loader/react-loader.d.ts.map +1 -1
  113. package/dist/plugin/loader/react-loader.js +5 -687
  114. package/dist/plugin/loader/react-loader.js.map +1 -1
  115. package/dist/plugin/loader/react-loader.server.d.ts +21 -0
  116. package/dist/plugin/loader/react-loader.server.d.ts.map +1 -0
  117. package/dist/plugin/loader/react-loader.server.js +69 -0
  118. package/dist/plugin/loader/sourceMap.d.ts +35 -0
  119. package/dist/plugin/loader/sourceMap.d.ts.map +1 -0
  120. package/dist/plugin/loader/sourceMap.js +105 -0
  121. package/dist/plugin/loader/temporaryReferences.d.ts +1 -1
  122. package/dist/plugin/loader/temporaryReferences.d.ts.map +1 -1
  123. package/dist/plugin/loader/transformModuleIfNeeded.d.ts +2 -0
  124. package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -0
  125. package/dist/plugin/loader/transformModuleIfNeeded.js +27 -0
  126. package/dist/plugin/loader/transformModuleIfNeeded.js.map +1 -0
  127. package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts +27 -0
  128. package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +1 -0
  129. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +52 -0
  130. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +1 -0
  131. package/dist/plugin/loader/types.d.ts +8 -0
  132. package/dist/plugin/loader/types.d.ts.map +1 -0
  133. package/dist/plugin/loader/types.js +1 -0
  134. package/dist/plugin/plugin.client.d.ts +2 -2
  135. package/dist/plugin/plugin.client.d.ts.map +1 -1
  136. package/dist/plugin/plugin.client.js +2 -3
  137. package/dist/plugin/plugin.client.js.map +1 -1
  138. package/dist/plugin/plugin.server.d.ts +2 -2
  139. package/dist/plugin/plugin.server.d.ts.map +1 -1
  140. package/dist/plugin/plugin.server.js +2 -2
  141. package/dist/plugin/plugin.server.js.map +1 -1
  142. package/dist/plugin/preserver/plugin.d.ts +2 -2
  143. package/dist/plugin/preserver/plugin.d.ts.map +1 -1
  144. package/dist/plugin/preserver/plugin.js +6 -2
  145. package/dist/plugin/preserver/plugin.js.map +1 -1
  146. package/dist/plugin/react-client/{server.d.ts → configureWorkerRequestHandler.d.ts} +4 -4
  147. package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -0
  148. package/dist/plugin/react-client/{server.js → configureWorkerRequestHandler.js} +11 -8
  149. package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +1 -0
  150. package/dist/plugin/react-client/createMessageHandlers.d.ts +1 -1
  151. package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
  152. package/dist/plugin/react-client/createMessageHandlers.js +18 -11
  153. package/dist/plugin/react-client/createMessageHandlers.js.map +1 -1
  154. package/dist/plugin/react-client/createWorkerStream.d.ts +5 -3
  155. package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
  156. package/dist/plugin/react-client/createWorkerStream.js +61 -27
  157. package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
  158. package/dist/plugin/react-client/handleWorkerRscStream.d.ts +1 -1
  159. package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
  160. package/dist/plugin/react-client/handleWorkerRscStream.js +14 -4
  161. package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -1
  162. package/dist/plugin/react-client/plugin.d.ts +2 -2
  163. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  164. package/dist/plugin/react-client/plugin.js +7 -8
  165. package/dist/plugin/react-client/plugin.js.map +1 -1
  166. package/dist/plugin/react-client/restartWorker.d.ts +1 -1
  167. package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
  168. package/dist/plugin/react-client/restartWorker.js +9 -3
  169. package/dist/plugin/react-client/restartWorker.js.map +1 -1
  170. package/dist/plugin/react-server/configureReactServer.d.ts +9 -0
  171. package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -0
  172. package/dist/plugin/react-server/{server.js → configureReactServer.js} +26 -8
  173. package/dist/plugin/react-server/configureReactServer.js.map +1 -0
  174. package/dist/plugin/react-server/handleServerAction.d.ts +5 -0
  175. package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -0
  176. package/dist/plugin/react-server/handleServerAction.js +145 -0
  177. package/dist/plugin/react-server/handleServerAction.js.map +1 -0
  178. package/dist/plugin/react-server/plugin.d.ts +2 -2
  179. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  180. package/dist/plugin/react-server/plugin.js +1 -1
  181. package/dist/plugin/react-server/plugin.js.map +1 -1
  182. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +2 -2
  183. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
  184. package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -1
  185. package/dist/plugin/react-static/collectRscContent.d.ts +2 -2
  186. package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -1
  187. package/dist/plugin/react-static/collectRscContent.js.map +1 -1
  188. package/dist/plugin/react-static/configurePreviewServer.d.ts +3 -3
  189. package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
  190. package/dist/plugin/react-static/configurePreviewServer.js +18 -7
  191. package/dist/plugin/react-static/configurePreviewServer.js.map +1 -1
  192. package/dist/plugin/react-static/plugin.d.ts +2 -2
  193. package/dist/plugin/react-static/plugin.d.ts.map +1 -1
  194. package/dist/plugin/react-static/plugin.js +28 -12
  195. package/dist/plugin/react-static/plugin.js.map +1 -1
  196. package/dist/plugin/react-static/renderPage.d.ts +2 -2
  197. package/dist/plugin/react-static/renderPage.d.ts.map +1 -1
  198. package/dist/plugin/react-static/renderPage.js.map +1 -1
  199. package/dist/plugin/react-static/renderPages.d.ts +2 -2
  200. package/dist/plugin/react-static/renderPages.d.ts.map +1 -1
  201. package/dist/plugin/react-static/renderPages.js.map +1 -1
  202. package/dist/plugin/react-static/renderStreams.d.ts +2 -2
  203. package/dist/plugin/react-static/renderStreams.d.ts.map +1 -1
  204. package/dist/plugin/react-static/renderStreams.js +4 -4
  205. package/dist/plugin/react-static/renderStreams.js.map +1 -1
  206. package/dist/plugin/source-map/createMappingsSerializer.d.ts +2 -0
  207. package/dist/plugin/source-map/createMappingsSerializer.d.ts.map +1 -0
  208. package/dist/plugin/source-map/createMappingsSerializer.js +159 -0
  209. package/dist/plugin/source-map/readMappings.d.ts +2 -0
  210. package/dist/plugin/source-map/readMappings.d.ts.map +1 -0
  211. package/dist/plugin/source-map/readMappings.js +201 -0
  212. package/dist/plugin/transformer/index.d.ts +0 -1
  213. package/dist/plugin/transformer/index.d.ts.map +1 -1
  214. package/dist/plugin/transformer/index.js +0 -1
  215. package/dist/plugin/transformer/plugin.client.d.ts +1 -3
  216. package/dist/plugin/transformer/plugin.client.d.ts.map +1 -1
  217. package/dist/plugin/transformer/plugin.client.js +1 -84
  218. package/dist/plugin/transformer/plugin.server.d.ts +2 -2
  219. package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
  220. package/dist/plugin/transformer/plugin.server.js +52 -20
  221. package/dist/plugin/transformer/plugin.server.js.map +1 -1
  222. package/dist/plugin/types.d.ts +89 -119
  223. package/dist/plugin/types.d.ts.map +1 -1
  224. package/dist/plugin/utils/callServer.d.ts +1 -1
  225. package/dist/plugin/utils/callServer.d.ts.map +1 -1
  226. package/dist/plugin/utils/createCallServer.d.ts +1 -1
  227. package/dist/plugin/utils/createCallServer.d.ts.map +1 -1
  228. package/dist/plugin/utils/createCallServer.js +13 -4
  229. package/dist/plugin/utils/createCallServer.js.map +1 -1
  230. package/dist/plugin/utils/index.d.ts +1 -0
  231. package/dist/plugin/utils/index.d.ts.map +1 -1
  232. package/dist/plugin/utils/index.js +1 -0
  233. package/dist/plugin/utils.js +1 -0
  234. package/dist/plugin/utils.js.map +1 -1
  235. package/dist/plugin/vendor/vendor.client.d.ts +2 -1
  236. package/dist/plugin/vendor/vendor.client.d.ts.map +1 -1
  237. package/dist/plugin/vendor/vendor.client.js +2 -1
  238. package/dist/plugin/vendor/vendor.client.js.map +1 -1
  239. package/dist/plugin/vendor/vendor.server.d.ts.map +1 -1
  240. package/dist/plugin/vendor/vendor.server.js +1 -1
  241. package/dist/plugin/vendor/vendor.server.js.map +1 -1
  242. package/dist/plugin/worker/createWorker.d.ts.map +1 -1
  243. package/dist/plugin/worker/createWorker.js +17 -22
  244. package/dist/plugin/worker/createWorker.js.map +1 -1
  245. package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -1
  246. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +25 -4
  247. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -1
  248. package/dist/plugin/worker/html/html-worker.development.js +15 -13
  249. package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
  250. package/dist/plugin/worker/html/html-worker.production.js +2 -12
  251. package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
  252. package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
  253. package/dist/plugin/worker/html/messageHandler.js +2 -2
  254. package/dist/plugin/worker/html/messageHandler.js.map +1 -1
  255. package/dist/plugin/worker/rsc/handleRender.d.ts +2 -1
  256. package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
  257. package/dist/plugin/worker/rsc/handleRender.js +8 -8
  258. package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
  259. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
  260. package/dist/plugin/worker/rsc/messageHandler.js +166 -107
  261. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
  262. package/dist/plugin/worker/rsc/rsc-worker.development.js +112 -52
  263. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
  264. package/dist/plugin/worker/rsc/rsc-worker.production.js +1 -1
  265. package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
  266. package/dist/plugin/worker/rsc/state.d.ts +5 -64
  267. package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
  268. package/dist/plugin/worker/rsc/state.js +5 -1
  269. package/dist/plugin/worker/rsc/state.js.map +1 -1
  270. package/dist/plugin/worker/sendMessage.d.ts +2 -0
  271. package/dist/plugin/worker/sendMessage.d.ts.map +1 -1
  272. package/dist/plugin/worker/sendMessage.js +2 -1
  273. package/dist/plugin/worker/sendMessage.js.map +1 -1
  274. package/dist/plugin/worker/types.d.ts +52 -53
  275. package/dist/plugin/worker/types.d.ts.map +1 -1
  276. package/dist/tsconfig.tsbuildinfo +1 -1
  277. package/package.json +10 -8
  278. package/plugin/components/css-collector-elements.tsx +30 -9
  279. package/plugin/components/css-collector.tsx +13 -22
  280. package/plugin/components/html.tsx +12 -5
  281. package/plugin/config/autoDiscover/resolveAutoDiscover.ts +31 -13
  282. package/plugin/config/defaults.tsx +72 -16
  283. package/plugin/config/resolveAutoDiscoverMatcher.ts +23 -0
  284. package/plugin/config/resolveEnv.ts +20 -12
  285. package/plugin/config/resolveOptions.ts +152 -155
  286. package/plugin/config/resolveUserConfig.ts +20 -5
  287. package/plugin/error/toError.ts +35 -1
  288. package/plugin/helpers/cleanObject.ts +79 -15
  289. package/plugin/helpers/collectViteModuleGraphCss.ts +4 -3
  290. package/plugin/helpers/createCssProps.tsx +26 -9
  291. package/plugin/helpers/createHandler.ts +7 -4
  292. package/plugin/helpers/createRscStream.tsx +20 -14
  293. package/plugin/helpers/index.ts +2 -2
  294. package/plugin/helpers/inputNormalizer.ts +4 -2
  295. package/plugin/helpers/moduleResolver.ts +36 -0
  296. package/plugin/helpers/requestInfo.ts +117 -23
  297. package/plugin/helpers/resolvePage.ts +2 -3
  298. package/plugin/helpers/resolvePageAndProps.ts +7 -6
  299. package/plugin/helpers/serializeUserOptions.ts +20 -2
  300. package/plugin/helpers/sourceMap.ts +182 -0
  301. package/plugin/loader/createBuildLoader.ts +124 -104
  302. package/plugin/loader/createDefaultLoader.ts +62 -0
  303. package/plugin/loader/css-loader.development.ts +3 -2
  304. package/plugin/loader/handleExports.ts +276 -0
  305. package/plugin/loader/index.ts +6 -1
  306. package/plugin/loader/parse.ts +22 -0
  307. package/plugin/loader/react-loader.client.ts +1 -0
  308. package/plugin/loader/react-loader.server.ts +107 -0
  309. package/plugin/loader/react-loader.ts +4 -1002
  310. package/plugin/loader/sourceMap.ts +118 -0
  311. package/plugin/loader/transformModuleIfNeeded.ts +33 -0
  312. package/plugin/loader/transformModuleWithPreservedFunctions.ts +119 -0
  313. package/plugin/loader/types.ts +10 -0
  314. package/plugin/plugin.client.ts +18 -11
  315. package/plugin/plugin.server.ts +6 -3
  316. package/plugin/preserver/plugin.ts +37 -17
  317. package/plugin/react-client/{server.ts → configureWorkerRequestHandler.ts} +22 -12
  318. package/plugin/react-client/createMessageHandlers.ts +21 -13
  319. package/plugin/react-client/createWorkerStream.ts +71 -33
  320. package/plugin/react-client/handleWorkerRscStream.ts +15 -5
  321. package/plugin/react-client/plugin.ts +18 -13
  322. package/plugin/react-client/restartWorker.ts +17 -5
  323. package/plugin/react-server/{server.ts → configureReactServer.ts} +40 -9
  324. package/plugin/react-server/handleServerAction.ts +177 -0
  325. package/plugin/react-server/plugin.ts +8 -3
  326. package/plugin/react-static/collectHtmlWorkerContent.ts +11 -3
  327. package/plugin/react-static/collectRscContent.ts +17 -9
  328. package/plugin/react-static/configurePreviewServer.ts +37 -17
  329. package/plugin/react-static/plugin.ts +45 -22
  330. package/plugin/react-static/renderPage.ts +12 -6
  331. package/plugin/react-static/renderPages.ts +15 -4
  332. package/plugin/react-static/renderStreams.ts +13 -12
  333. package/plugin/source-map/createMappingsSerializer.ts +182 -0
  334. package/plugin/source-map/readMappings.ts +195 -0
  335. package/plugin/transformer/README.md +295 -29
  336. package/plugin/transformer/index.ts +0 -1
  337. package/plugin/transformer/plugin.client.ts +0 -111
  338. package/plugin/transformer/plugin.server.ts +94 -25
  339. package/plugin/types/react-server-dom-esm.d.ts +183 -24
  340. package/plugin/types/sourceMap.d.ts +2 -0
  341. package/plugin/types/webpack-sources.d.ts +24 -0
  342. package/plugin/types.ts +169 -132
  343. package/plugin/utils/createCallServer.ts +21 -6
  344. package/plugin/utils/index.ts +2 -1
  345. package/plugin/vendor/vendor.client.ts +2 -1
  346. package/plugin/vendor/vendor.server.ts +1 -1
  347. package/plugin/worker/createWorker.ts +21 -24
  348. package/plugin/worker/html/createHtmlWorkerRenderState.tsx +31 -7
  349. package/plugin/worker/html/html-worker.development.tsx +16 -16
  350. package/plugin/worker/html/html-worker.production.tsx +3 -19
  351. package/plugin/worker/html/messageHandler.tsx +2 -4
  352. package/plugin/worker/rsc/handleRender.ts +15 -12
  353. package/plugin/worker/rsc/messageHandler.tsx +191 -120
  354. package/plugin/worker/rsc/rsc-worker.development.ts +148 -77
  355. package/plugin/worker/rsc/rsc-worker.production.ts +1 -1
  356. package/plugin/worker/rsc/state.ts +10 -0
  357. package/plugin/worker/sendMessage.ts +32 -14
  358. package/plugin/worker/types.ts +99 -64
  359. package/dist/plugin/react-client/server.d.ts.map +0 -1
  360. package/dist/plugin/react-client/server.js.map +0 -1
  361. package/dist/plugin/react-server/server.d.ts +0 -9
  362. package/dist/plugin/react-server/server.d.ts.map +0 -1
  363. package/dist/plugin/react-server/server.js.map +0 -1
  364. package/dist/plugin/transformer/plugin.client.js.map +0 -1
  365. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +0 -2
  366. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +0 -1
  367. package/dist/plugin/transformer/upgradeCssModuleCode.js +0 -40
  368. package/dist/plugin/worker/loader.d.ts +0 -5
  369. package/dist/plugin/worker/loader.d.ts.map +0 -1
  370. package/dist/plugin/worker/loader.js +0 -11
  371. package/dist/plugin/worker/loader.js.map +0 -1
  372. package/plugin/transformer/upgradeCssModuleCode.ts +0 -42
  373. package/plugin/worker/loader.ts +0 -7
package/plugin/types.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type { Readable } from "node:stream";
2
- import type { MessagePort, Worker } from "node:worker_threads";
2
+ import type { Worker } from "node:worker_threads";
3
3
  import type React from "react";
4
- import type { PropsWithChildren } from "react";
5
4
  import type {
6
5
  NormalizedOutputOptions,
7
6
  OutputBundle,
@@ -66,6 +65,7 @@ export type AutoDiscoveredFiles = ResolvedBuildPages & {
66
65
  clientEntry: Record<string, string>;
67
66
  inputs: Record<string, string>;
68
67
  staticManifest: Manifest;
68
+ serverActions: Record<string, string>;
69
69
  };
70
70
  export type FileWriterOptions = Pick<
71
71
  CreateHandlerOptions,
@@ -118,6 +118,7 @@ export type ResolvedUserConfig = Required<
118
118
  | "ssrManifest"
119
119
  | "manifest"
120
120
  | "rollupOptions"
121
+ | "modulePreload"
121
122
  >
122
123
  >
123
124
  > &
@@ -151,10 +152,11 @@ export interface StreamPluginOptionsClient {
151
152
  }
152
153
 
153
154
  export type ResolvedUserOptions<
154
- InlineCSS extends boolean | undefined = boolean | undefined
155
+ T extends PagePropOpt = PagePropOpt,
156
+ InlineCSS extends InlineCssOpt = InlineCssOpt
155
157
  > = Required<
156
158
  Pick<
157
- StreamPluginOptions,
159
+ StreamPluginOptions<T, InlineCSS>,
158
160
  | "moduleBase"
159
161
  | "moduleBasePath"
160
162
  | "moduleBaseURL"
@@ -171,7 +173,7 @@ export type ResolvedUserOptions<
171
173
  | "loaderPath"
172
174
  | "clientEntry"
173
175
  | "serverEntry"
174
- | "moduleBaseExceptions"
176
+ // | "moduleBaseExceptions"
175
177
  | "pipeableStreamOptions"
176
178
  | "onMetrics"
177
179
  | "onEvent"
@@ -187,10 +189,14 @@ export type ResolvedUserOptions<
187
189
  | string
188
190
  | ((url: string) => string)
189
191
  | ((url: string) => Promise<string>);
190
- build: NonNullable<Required<StreamPluginOptions<InlineCSS>["build"]>>;
191
- css: NonNullable<Required<StreamPluginOptions<InlineCSS>["css"]>>;
192
+ build: NonNullable<Required<StreamPluginOptions<T, InlineCSS>["build"]>>;
193
+ css: NonNullable<Required<StreamPluginOptions<T, InlineCSS>["css"]>> & {
194
+ inlineCss: InlineCSS;
195
+ };
192
196
  autoDiscover: {
193
197
  moduleExtension: RegExp;
198
+ serverDirective: RegExp;
199
+ clientDirective: RegExp;
194
200
  modulePattern: (path: string) => boolean;
195
201
  cssPattern: (path: string) => boolean;
196
202
  jsonPattern: (path: string) => boolean;
@@ -205,6 +211,8 @@ export type ResolvedUserOptions<
205
211
  nodeOnly: (path: string) => boolean;
206
212
  dotFiles: (path: string) => boolean;
207
213
  virtualPattern: (path: string) => boolean;
214
+ isServerFunction: (code: string) => boolean;
215
+ isClientComponent: (code: string) => boolean;
208
216
  };
209
217
  };
210
218
 
@@ -231,14 +239,70 @@ export interface RenderMetrics {
231
239
  rscSizes: Map<string, number>;
232
240
  }
233
241
 
234
- export interface CssCollectorOptions {
235
- inlineCss?: boolean;
236
- purgeCss?: boolean;
242
+ export interface CssCollectorOptions<
243
+ InlineCSS extends InlineCssOpt = InlineCssOpt
244
+ > {
245
+ inlineCss?: InlineCSS;
237
246
  inlineThreshold?: number;
238
247
  inlinePatterns?: RegExp[];
239
248
  linkPatterns?: RegExp[];
240
249
  }
241
250
 
251
+ export type CssContent<InlineCSS extends InlineCssOpt = InlineCssOpt> =
252
+ InlineCSS extends true
253
+ ? StyleCssProps
254
+ : InlineCSS extends false
255
+ ? LinkCssProps
256
+ : InlineCSS extends undefined | boolean
257
+ ? StyleCssProps | LinkCssProps
258
+ : never;
259
+
260
+ /**
261
+ * Boxed component type for the CssCollector
262
+ */
263
+ export type CssCollectorBoxedType<
264
+ _T extends PagePropOpt = PagePropOpt,
265
+ _InlineCSS extends InlineCssOpt = InlineCssOpt,
266
+ _As extends AsOpt = AsOpt
267
+ > = <
268
+ T extends _T = _T,
269
+ InlineCSS extends _InlineCSS = _InlineCSS,
270
+ As extends _As = _As
271
+ >(
272
+ props: CssCollectorProps<T, InlineCSS, As>
273
+ ) => React.ReactElement;
274
+
275
+ export type CssCollectorProps<
276
+ T extends PagePropOpt = PagePropOpt,
277
+ InlineCSS extends InlineCssOpt = InlineCssOpt,
278
+ As extends AsOpt = AsOpt
279
+ > = {
280
+ as: As;
281
+ cssFiles?: Map<string, CssContent<InlineCSS>>;
282
+ pageProps?: T;
283
+ Page: PageComponentType<T>;
284
+ id?: string;
285
+ } & React.ComponentPropsWithoutRef<As>;
286
+
287
+ export type CssCollectorComponent = (
288
+ props: CssCollectorProps
289
+ ) => React.ReactElement;
290
+
291
+ /**
292
+ * Boxed component type for the Html component
293
+ */
294
+ export type HtmlBoxedType<
295
+ _T extends PagePropOpt = PagePropOpt,
296
+ _InlineCSS extends InlineCssOpt = InlineCssOpt,
297
+ _As extends AsOpt = "div"
298
+ > = <
299
+ T extends _T = _T,
300
+ InlineCSS extends _InlineCSS = _InlineCSS,
301
+ As extends _As = _As
302
+ >(
303
+ props: HtmlProps<T, InlineCSS, As> & { key?: string }
304
+ ) => React.ReactNode;
305
+
242
306
  export type FileWriteEvent = {
243
307
  type: "file.write";
244
308
  data: {
@@ -362,7 +426,8 @@ export type PluginEvent =
362
426
  export type PluginEventType = PluginEvent["type"];
363
427
 
364
428
  export interface StreamPluginOptions<
365
- InlineCSS extends boolean | undefined = boolean | undefined
429
+ T extends PagePropOpt = PagePropOpt,
430
+ InlineCSS extends InlineCssOpt = InlineCssOpt
366
431
  > {
367
432
  projectRoot?: string; // defaults to process.cwd()
368
433
  moduleBase: string; // defaults to 'src'
@@ -375,35 +440,44 @@ export interface StreamPluginOptions<
375
440
  // Auto-discovery (zero-config)
376
441
  autoDiscover?:
377
442
  | {
443
+ // default: /\.(m|c)?(j|t)sx?$/
378
444
  moduleExtension?: RegExp;
445
+ // default: /^"use server"[\s;]*\n?/m
446
+ serverDirective?: RegExp;
447
+ // default: /^"use client"[\s;]*\n?/m
448
+ clientDirective?: RegExp;
379
449
  // default: /\.(m|c)?(j|t)sx?$/
380
- modulePattern?: string | RegExp | ((path: string) => boolean);
450
+ modulePattern?: RegExpOpt;
381
451
  // default: [Pp]age.tsx
382
- pagePattern?: string | RegExp | ((path: string) => boolean);
452
+ pagePattern?: RegExpOpt;
383
453
  // default: [Pp]rops.ts
384
- propsPattern?: string | RegExp | ((path: string) => boolean);
454
+ propsPattern?: RegExpOpt;
385
455
  // default: "use client" and .client./\.(m|c)?(j|t)sx?$/
386
- clientComponents?: string | RegExp | ((path: string) => boolean);
456
+ clientComponents?: RegExpOpt;
387
457
  // default: "use server" and .server./\.(m|c)?(j|t)sx?$/
388
- serverFunctions?: string | RegExp | ((path: string) => boolean);
458
+ serverFunctions?: RegExpOpt;
389
459
  // default: /\.css$/
390
- cssPattern?: string | RegExp | ((path: string) => boolean);
460
+ cssPattern?: RegExpOpt;
391
461
  // default: /\.json$/
392
- jsonPattern?: string | RegExp | ((path: string) => boolean);
462
+ jsonPattern?: RegExpOpt;
393
463
  // default: /\.html$/
394
- htmlPattern?: string | RegExp | ((path: string) => boolean);
464
+ htmlPattern?: RegExpOpt;
395
465
  // default: /\.css\.js/
396
- cssModulePattern?: string | RegExp | ((path: string) => boolean);
466
+ cssModulePattern?: RegExpOpt;
397
467
  // default: /node_modules|(_virtual)/
398
- vendorPattern?: string | RegExp | ((path: string) => boolean);
468
+ vendorPattern?: RegExpOpt;
399
469
  // default: /\.node\.js$/
400
- nodeOnly?: string | RegExp | ((path: string) => boolean);
470
+ nodeOnly?: RegExpOpt;
401
471
  // default: /\.node\.js$/
402
- dotFiles?: string | RegExp | ((path: string) => boolean);
472
+ dotFiles?: RegExpOpt;
403
473
  // default: /^\/_virtual\//
404
- virtualPattern?: string | RegExp | ((path: string) => boolean);
474
+ virtualPattern?: RegExpOpt;
405
475
  // default: /\.rsc$/
406
- rscPattern?: string | RegExp | ((path: string) => boolean);
476
+ rscPattern?: RegExpOpt;
477
+ // default serverDirective regex
478
+ isServerFunction?: RegExpOpt;
479
+ // default clientDirective regex
480
+ isClientComponent?: RegExpOpt;
407
481
  }
408
482
  | undefined;
409
483
  // Manual configuration
@@ -419,13 +493,11 @@ export interface StreamPluginOptions<
419
493
  loaderPath?: string;
420
494
  pageExportName?: string;
421
495
  propsExportName?: string;
422
- Html?: React.FC<PropsWithChildren<HtmlProps>>;
423
- CssCollector?: React.FC<
424
- React.PropsWithChildren<CssCollectorProps<InlineCSS>>
425
- >;
496
+ Html?: React.FC<HtmlProps<T, InlineCSS>>;
497
+ CssCollector?: CssCollectorBoxedType<T, InlineCSS>;
426
498
  build?: BuildConfig;
427
- css?: CssCollectorOptions;
428
- moduleBaseExceptions?: string[];
499
+ css?: CssCollectorOptions<InlineCSS>;
500
+ // moduleBaseExceptions?: string[];
429
501
  pipeableStreamOptions?: ReactServerDomEsmOptions;
430
502
  onMetrics?: (metrics: RenderMetrics) => void;
431
503
  onEvent?: (event: PluginEvent) => void;
@@ -434,8 +506,11 @@ export interface StreamPluginOptions<
434
506
  verbose?: boolean;
435
507
  }
436
508
 
437
- export type MultiPageHandlerOptions = Omit<
438
- CreateHandlerOptions,
509
+ export type MultiPageHandlerOptions<
510
+ T extends PagePropOpt = PagePropOpt,
511
+ InlineCSS extends InlineCssOpt = InlineCssOpt
512
+ > = Omit<
513
+ CreateHandlerOptions<T, InlineCSS>,
439
514
  | "pagePath"
440
515
  | "route"
441
516
  | "cssFiles"
@@ -445,11 +520,10 @@ export type MultiPageHandlerOptions = Omit<
445
520
  >;
446
521
 
447
522
  export type CreateHandlerOptions<
448
- T = unknown,
449
- C extends React.ComponentType<T> = React.ComponentType<T>,
450
- InlineCSS extends boolean | undefined = undefined
523
+ T extends PagePropOpt = PagePropOpt,
524
+ InlineCSS extends InlineCssOpt = InlineCssOpt
451
525
  > = Pick<
452
- ResolvedUserOptions<InlineCSS>,
526
+ ResolvedUserOptions<T, InlineCSS>,
453
527
  | "autoDiscover"
454
528
  | "css"
455
529
  | "pageExportName"
@@ -470,16 +544,16 @@ export type CreateHandlerOptions<
470
544
  pagePath: string;
471
545
  propsPath?: string;
472
546
  pageProps?: T;
473
- PageComponent?: C;
547
+ PageComponent?: PageComponentType<T>;
474
548
  route: string;
475
549
  manifest: Manifest;
476
550
  worker?: Worker;
477
551
  server?: ViteDevServer;
478
552
  importedCss?: Set<string>;
479
- cssFiles: Map<string, CssContent>;
480
- globalCss: Map<string, CssContent>;
553
+ cssFiles: Map<string, CssContent<InlineCSS>>;
554
+ globalCss: Map<string, CssContent<InlineCSS>>;
481
555
  build: Pick<
482
- ResolvedUserOptions["build"],
556
+ ResolvedUserOptions<T, InlineCSS>["build"],
483
557
  | "outDir"
484
558
  | "pages"
485
559
  | "server"
@@ -667,24 +741,28 @@ export type ResolvedBuildPages = {
667
741
  errors: Error[];
668
742
  };
669
743
 
670
- // Add strict type checking for worker messages
671
- export type WorkerMessage =
672
- | { type: "READY" }
673
- | { type: "ERROR"; error: string | Error }
674
- | { type: "RSC_CHUNK"; id: string; chunk: Buffer }
675
- | { type: "RSC_END"; id: string }
676
- | { type: "SHUTDOWN"; id: string }
677
- | { type: "SHUTDOWN_COMPLETE" }
678
- | { type: "CHUNK_PROCESSED"; id: string; success: boolean }
679
- | { type: "CHUNK_ERROR"; id: string; error: string }
680
- | { type: "METRICS"; metrics: StreamMetrics };
681
-
682
744
  // Add branded types for safety
683
745
  export type ModuleId = string & { readonly __brand: unique symbol };
684
746
  export type PagePath = string & { readonly __brand: unique symbol };
685
747
 
686
- export type HtmlProps = {
687
- pageProps: any;
748
+ export type InlineCssOpt = undefined | boolean;
749
+ export type PagePropOpt = Record<string, unknown> | undefined;
750
+ export type RegExpOpt = RegExp | string | ((path: string) => boolean);
751
+
752
+ export type AsOpt = Exclude<
753
+ keyof React.JSX.IntrinsicElements,
754
+ "symbol" | "object"
755
+ >;
756
+ export type PageComponentType<T extends PagePropOpt = PagePropOpt> =
757
+ React.ComponentType<T & React.PropsWithChildren<{}>>;
758
+
759
+ export type HtmlProps<
760
+ T extends PagePropOpt = PagePropOpt,
761
+ InlineCSS extends InlineCssOpt = InlineCssOpt,
762
+ As extends AsOpt = AsOpt
763
+ > = {
764
+ pageProps?: T;
765
+ Page: PageComponentType<T>;
688
766
  route: string;
689
767
  url: string;
690
768
  projectRoot: string;
@@ -692,10 +770,12 @@ export type HtmlProps = {
692
770
  moduleBaseURL: string;
693
771
  moduleBasePath: string;
694
772
  moduleRootPath: string;
695
- cssFiles: Map<string, CssContent>;
773
+ cssFiles: Map<string, CssContent<InlineCSS>>;
696
774
  manifest: Manifest;
697
- CssCollector: React.FC<React.PropsWithChildren<CssCollectorProps>>;
698
- globalCss: Map<string, CssContent>;
775
+ CssCollector: CssCollectorBoxedType<T, InlineCSS, As>;
776
+ globalCss: Map<string, CssContent<InlineCSS>>;
777
+ children?: React.ReactNode;
778
+ as: As;
699
779
  };
700
780
 
701
781
  export interface PageAsset {
@@ -709,16 +789,17 @@ type BaseCssProps = {
709
789
  id: string;
710
790
  };
711
791
 
712
- type CssProps = BaseCssProps & {
792
+ export type LinkCssProps = BaseCssProps & {
713
793
  as: "link";
714
794
  type?: never;
715
- children?: InlineCssProps extends false ? never : React.ReactNode;
795
+ children?: never;
716
796
  id: string;
717
797
  href: string;
718
798
  rel: "stylesheet";
719
799
  precedence?: string;
720
800
  };
721
- type InlineCssProps = BaseCssProps & {
801
+
802
+ export type StyleCssProps = BaseCssProps & {
722
803
  as: "style";
723
804
  type: "text/css";
724
805
  children?: React.ReactNode;
@@ -727,60 +808,8 @@ type InlineCssProps = BaseCssProps & {
727
808
  href?: never;
728
809
  };
729
810
 
730
- export type CssContent<InlineCSS extends boolean | undefined = undefined> =
731
- InlineCSS extends true
732
- ? InlineCssProps
733
- : InlineCSS extends false
734
- ? CssProps
735
- : CssProps | InlineCssProps;
736
-
737
- export interface JsContent {
738
- type?: string;
739
- content: string;
740
- key?: string;
741
- path: string;
742
- id?: string;
743
- }
744
-
745
- export type CssCollectorProps<
746
- InlineCSS extends boolean | undefined = undefined
747
- > = {
748
- as?: React.ElementType; // defaults to react fragment
749
- children?: React.ReactNode; // the children containing the css content
750
- /** A map containing all the css files imported by the route and their proxy values
751
- * - when inlineCss is true, will contain the `content` property
752
- * - when prugeCss is true, will contain the module proxy which includes a `userClasses`
753
- * @example ```tsx
754
- * import styles from './styles.module.css';
755
- * export const Page = () => {
756
- * return <div className={styles.userClass}>Hello World</div>
757
- * }
758
- * ```
759
- * then the module will basically contain whatever `styles` exported here. But how does it track css class usages
760
- * during streaming?
761
- *
762
- * const tags = Array.from(importedCss?.values() ?? []).map(cssFile => {
763
- * return <link rel="stylesheet" href={cssFile.path} />
764
- * })
765
- * ```
766
- *
767
- *
768
- * */
769
- cssFiles?: Map<string, CssContent<InlineCSS>>;
770
- } & React.HTMLAttributes<HTMLElement>;
771
-
772
- export interface InlineCssCollectorProps {
773
- cssFiles: Map<string, CssContent>;
774
- moduleBaseURL: string;
775
- moduleRootPath: string;
776
- moduleBasePath: string;
777
- route?: string;
778
- purgeCss?: boolean;
779
- children?: React.ReactNode;
780
- }
781
-
782
811
  export type CssCollectorElementsProps<
783
- InlineCSS extends boolean | undefined = undefined
812
+ InlineCSS extends InlineCssOpt = InlineCssOpt
784
813
  > = {
785
814
  cssFiles: Map<string, CssContent<InlineCSS>>;
786
815
  };
@@ -840,27 +869,28 @@ export type RenderPagesResult =
840
869
  >;
841
870
  };
842
871
 
843
- export type HandlerAssets = {
844
- css: CssContent[];
872
+ export type HandlerAssets<InlineCSS extends InlineCssOpt = InlineCssOpt> = {
873
+ css: CssContent<InlineCSS>[];
845
874
  js: string[];
846
875
  bootstrapModules: string[];
847
876
  };
848
877
 
849
- export type CreateHandlerResult =
850
- | {
851
- type: "success";
852
- controller: AbortController;
853
- stream: any;
854
- assets: {
855
- css: CssContent[];
856
- js: string[];
857
- bootstrapModules: string[];
858
- };
859
- route: string;
860
- metrics: StreamMetrics;
861
- }
862
- | { type: "error"; error: Error }
863
- | { type: "skip" };
878
+ export type CreateHandlerResult<InlineCSS extends InlineCssOpt = InlineCssOpt> =
879
+
880
+ | {
881
+ type: "success";
882
+ controller: AbortController;
883
+ stream: any;
884
+ assets: {
885
+ css: CssContent<InlineCSS>[];
886
+ js: string[];
887
+ bootstrapModules: string[];
888
+ };
889
+ route: string;
890
+ metrics: StreamMetrics;
891
+ }
892
+ | { type: "error"; error: Error }
893
+ | { type: "skip" };
864
894
 
865
895
  export type ReactStaticEvent =
866
896
  | FileWriteEvent
@@ -874,7 +904,14 @@ export type ReactStaticEvent =
874
904
 
875
905
  // Define LoaderContext interface locally
876
906
  export interface LoaderContext {
877
- data?: { port?: MessagePort };
907
+ format?: string;
908
+ importAttributes?: Record<string, string>;
909
+ conditions?: string[];
910
+ env?: {
911
+ targetEnvironment?: "client" | "server" | "browser";
912
+ };
913
+ url: string;
914
+ userOptions?: any; // Add userOptions to the context
878
915
  }
879
916
  // Add type declaration for import.meta.cssModules
880
917
  declare global {
@@ -1,17 +1,23 @@
1
1
  import {
2
2
  createFromFetch,
3
3
  encodeReply,
4
- // @ts-ignore
5
4
  } from "react-server-dom-esm/client.browser";
6
5
 
7
- type ServerResponse = { returnValue: unknown };
6
+ interface ServerActionResponse {
7
+ returnValue: unknown;
8
+ type: 'server-action-response';
9
+ error?: string;
10
+ }
8
11
 
9
12
  export const createCallServer = (moduleBaseURL: string) => {
10
- const callServer = async (_id: string, args: unknown[]): Promise<unknown> => {
13
+ const callServer = async (id: string, args: unknown[]): Promise<unknown> => {
11
14
  const response = await createFromFetch(
12
15
  fetch(moduleBaseURL, {
13
16
  method: "POST",
14
- body: await encodeReply(args),
17
+ body: await encodeReply({
18
+ id,
19
+ args
20
+ }),
15
21
  headers: {
16
22
  Accept: "application/json",
17
23
  "Content-Type": "application/json",
@@ -19,8 +25,17 @@ export const createCallServer = (moduleBaseURL: string) => {
19
25
  }),
20
26
  { callServer, moduleBaseURL }
21
27
  );
22
- const returnValue = (response as ServerResponse).returnValue;
23
- return returnValue;
28
+
29
+ // Check if this is a server action response
30
+ if (response && typeof response === 'object' && 'returnValue' in response) {
31
+ const serverResponse = response as ServerActionResponse;
32
+ if (serverResponse.error) {
33
+ throw new Error(serverResponse.error);
34
+ }
35
+ return serverResponse.returnValue;
36
+ }
37
+
38
+ return response;
24
39
  };
25
40
  return callServer;
26
41
  };
@@ -1,4 +1,5 @@
1
1
  export * from "./createReactFetcher.js";
2
2
  export * from "./callServer.js";
3
3
  export * from "./urls.js";
4
- export * from "./env.js";
4
+ export * from "./env.js";
5
+ export * from "./createCallServer.js";
@@ -7,6 +7,7 @@ const nodeRequire = createRequire(join(projectRoot, "package.json"));
7
7
 
8
8
  // Import ReactDOM from the project's node_modules
9
9
  const ReactDOMServer = nodeRequire("react-dom/server");
10
+ const ReactDOMClient = nodeRequire("react-server-dom-esm/client");
10
11
  const React = nodeRequire("react");
11
12
 
12
- export { ReactDOMServer, React };
13
+ export { ReactDOMServer, React, ReactDOMClient };
@@ -6,7 +6,7 @@ const projectRoot = workerData?.projectRoot || process.env["npm_config_local_pre
6
6
  const nodeRequire = createRequire(join(projectRoot, "package.json"));
7
7
 
8
8
  // Import ReactDOM from the project's node_modules
9
- const ReactDOMServer = nodeRequire("react-server-dom-esm/server");
9
+ const ReactDOMServer = nodeRequire("react-server-dom-esm/server.node");
10
10
  const React = nodeRequire("react");
11
11
 
12
12
  export { ReactDOMServer, React };
@@ -12,6 +12,7 @@ import { DEFAULT_CONFIG } from "../config/defaults.js";
12
12
  import { createLogger, type Logger } from "vite";
13
13
  import type { HtmlWorkerOutputMessage } from "./types.js";
14
14
  import type { RscWorkerOutputMessage } from "./types.js";
15
+ import { toError } from "../error/toError.js";
15
16
 
16
17
  export type CreateWorkerOptions = {
17
18
  projectRoot?: string;
@@ -73,14 +74,11 @@ export async function createWorker(
73
74
  logger = createLogger(),
74
75
  verbose = false,
75
76
  } = options;
77
+ const id = reverseCondition === "react-server" ? "worker/rsc" : "worker/html";
76
78
  let workerPathWithDefault =
77
79
  typeof workerPath === "string" ? workerPath : undefined;
78
80
  if (!workerPathWithDefault) {
79
- if (currentCondition === "react-server") {
80
- workerPathWithDefault = join(pluginRoot, `worker/rsc`);
81
- } else {
82
- workerPathWithDefault = join(pluginRoot, `worker/html`);
83
- }
81
+ workerPathWithDefault = join(pluginRoot, id);
84
82
  }
85
83
  if (!workerPathWithDefault.startsWith("/")) {
86
84
  workerPathWithDefault = join("./", workerPathWithDefault);
@@ -89,6 +87,7 @@ export async function createWorker(
89
87
  const workerData = {
90
88
  ...options.workerData,
91
89
  reactVersion: React.version,
90
+ id: id,
92
91
  };
93
92
 
94
93
  try {
@@ -147,24 +146,25 @@ export async function createWorker(
147
146
  workerPath: workerPathWithDefault,
148
147
  } satisfies CreateWorkerSkip);
149
148
  } else {
150
- const error = new Error(`Worker exited with code ${code}`);
151
- logger.error(`worker exited with code ${code}`, { error });
152
- reject({
153
- type: "error",
154
- error,
149
+ const error = `[create:${id}] exited with code ${code}`;
150
+ resolve({
151
+ type: "skip",
152
+ reason: error,
155
153
  workerPath: workerPathWithDefault,
156
- } satisfies CreateWorkerError);
154
+ } satisfies CreateWorkerSkip);
157
155
  }
158
156
  };
159
- const messageHandler = (msg: HtmlWorkerOutputMessage | RscWorkerOutputMessage) => {
160
- if (verbose) logger.info(`Initial worker message ${msg.type}`);
157
+ const messageHandler = (
158
+ msg: HtmlWorkerOutputMessage | RscWorkerOutputMessage
159
+ ) => {
160
+ if (verbose) logger.info(`[create:${id}] Initial worker message ${msg.type}`);
161
161
  if (msg.type === "READY") {
162
- if (verbose) logger.info(`Worker running for ${msg.env}`);
162
+ if (verbose) logger.info(`[create:${id}] Worker running for ${msg.env}`);
163
163
  clearTimeout(timeout);
164
164
  worker.removeListener("message", messageHandler);
165
165
  worker.removeListener("exit", exitHandler);
166
166
  if (msg.env !== nodeEnv) {
167
- if (verbose) logger.info(`Worker environment mismatch.`);
167
+ if (verbose) logger.info(`[create:${id}] Worker environment mismatch.`);
168
168
  reject({
169
169
  type: "error",
170
170
  error: new Error(
@@ -179,19 +179,16 @@ export async function createWorker(
179
179
  workerPath: workerPathWithDefault,
180
180
  } satisfies CreateWorkerSuccess);
181
181
  }
182
- }
182
+ };
183
183
  worker.once("message", messageHandler);
184
184
  worker.once("exit", exitHandler);
185
185
  }
186
186
  );
187
187
  } catch (error) {
188
- if (error instanceof Error) {
189
- return {
190
- type: "error",
191
- workerPath: workerPathWithDefault,
192
- error: error,
193
- } satisfies CreateWorkerError;
194
- }
195
- return error as CreateWorkerError;
188
+ return {
189
+ type: "error",
190
+ error: toError(error),
191
+ workerPath: workerPathWithDefault,
192
+ };
196
193
  }
197
194
  }